Skip to content

feat: support extra_body in role configuration#1491

Open
kyochou wants to merge 1 commit intosigoden:mainfrom
kyochou:feat/extra-body
Open

feat: support extra_body in role configuration#1491
kyochou wants to merge 1 commit intosigoden:mainfrom
kyochou:feat/extra-body

Conversation

@kyochou
Copy link

@kyochou kyochou commented Mar 11, 2026

This PR adds support for a new extra_body field in the Role configuration.

It allows users to send arbitrary custom parameters (such as enable_thinking, vendor specific parameters, etc.) to the underlying LLM API by merging it into the payload just before sending the request.

With the proliferation of different LLM providers branching out their models with new experimental parameters, this extra parameter solves the issue by forwarding everything inside extra_body directly to the request body using a JSON merge patch. This adds forward-compatibility for future API parameters without requiring changes to the rust client implementations.

Supported syntax in Role Config YAML:

---
model: your-model
extra_body:
  enable_thinking: false
  custom_param: value
---

Changes:

  • Add extra_body (Option<Value>) to the Role struct.
  • Pass extra_body through ChatCompletionsData.
  • Merge extra_body at the end of the HTTP json body payload construction for OpenAI (and compatible), Claude, Bedrock, Gemini/VertexAI, and Cohere (Cohere inherits the openai_build_chat_completions_body macro/function, so it works too).
  • Session and Agent will skip extra_body as it shouldn't be forwarded to global states implicitly unless properly synced or customized later.

All tests (21/21) passing smoothly.

This adds support for passing custom parameters down to the LLM API via `extra_body` in the YAML frontmatter. Supported by OpenAI, Claude, Bedrock, VertexAI/Gemini, and Cohere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant