Feat: Add provider_options.extra_fields support complementing extra_body#1295
Closed
Jesssullivan wants to merge 4 commits intocharmbracelet:crush-fantasyfrom
Closed
Feat: Add provider_options.extra_fields support complementing extra_body#1295Jesssullivan wants to merge 4 commits intocharmbracelet:crush-fantasyfrom
Jesssullivan wants to merge 4 commits intocharmbracelet:crush-fantasyfrom
Conversation
Closed
2 tasks
Jesssullivan
commented
Oct 24, 2025
05f24e9 to
85a75b2
Compare
…a_body
This change enables passing custom parameters to OpenAI-compatible API
providers through Fantasy's ExtraFields mechanism, working alongside
Kujtim's SDK-level extra_body support.
Key changes:
- Extract extra_fields from provider_options (not extra_body)
- Apply via Fantasy's ExtraFields (per-call level)
- Works alongside extra_body (SDK level) for complementary behavior
- Merged with upstream/crush-fantasy parameter update fix
This creates two complementary mechanisms:
1. extra_body: SDK-level defaults (Kujtim's approach) - provider-wide
2. provider_options.extra_fields: Fantasy-level per-call (this PR)
Example config for Z.AI GLM thinking mode:
{
"providers": {
"z.ai": {
"provider_options": {
"extra_fields": {
"thinking": {
"type": "enabled",
"budget_tokens": 26214
}
}
}
}
}
}
The extra_fields are passed through Fantasy's ExtraFields to the
OpenAI SDK's SetExtraFields() method, enabling per-call customization.
Co-authored-by: Kujtim Hoxha <kujtimii.h@gmail.com>
85a75b2 to
cd1dad9
Compare
….extra_fields Uses github.com/Jesssullivan/fantasy v0.0.0-20251024030914-17cbc171a710 which includes the refactored ExtraFields support that accommodates both PRs.
Removed replace directive to make PR mergeable. Depends on Fantasy ExtraFields support being merged upstream.
This ensures provider_options.extra_fields is properly preserved during provider configuration, enabling Fantasy's ExtraFields integration for custom OpenAI-compatible API parameters (e.g., Z.AI GLM thinking mode). Without this fix, ProviderOptions would be lost when creating the prepared ProviderConfig for known providers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for
provider_options.extra_fieldsto pass custom parameters through Fantasy to OpenAI-compatible providers.Changes
internal/config/load.go: PreserveProviderOptionsfield when configuring known providersinternal/agent/coordinator.go: Extractextra_fieldsfromprovider_optionsand map to Fantasy'sExtraFieldsmechanismextra_body(SDK-level defaults) for complementary behaviorConfig
{ "provider_options": { "extra_fields": { "thinking": { "type": "enabled", "budget_tokens": 26214 } } } }Testing
HTTP logs confirm fields sent correctly to Z.AI GLM thinking mode.
Dependencies
Depends on Fantasy ExtraFields support charmbracelet/fantasy#45