Skip to content

Conversation

@Jesssullivan
Copy link

@Jesssullivan Jesssullivan commented Oct 24, 2025

Adds support for provider_options.extra_fields to pass custom parameters through Fantasy to OpenAI-compatible providers.

Changes

  • internal/config/load.go: Preserve ProviderOptions field when configuring known providers
  • internal/agent/coordinator.go: Extract extra_fields from provider_options and map to Fantasy's ExtraFields mechanism
  • Works alongside existing extra_body (SDK-level defaults) for complementary behavior

Config

{
  "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

@Jesssullivan Jesssullivan force-pushed the testing/extra-fantasy-args branch 4 times, most recently from 05f24e9 to 85a75b2 Compare October 24, 2025 14:41
@Jesssullivan Jesssullivan marked this pull request as ready for review October 24, 2025 14:42
@Jesssullivan Jesssullivan requested a review from a team as a code owner October 24, 2025 14:42
@Jesssullivan Jesssullivan requested review from andreynering and meowgorithm and removed request for a team October 24, 2025 14:42
…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 <[email protected]>
@Jesssullivan Jesssullivan force-pushed the testing/extra-fantasy-args branch from 85a75b2 to cd1dad9 Compare October 24, 2025 15:45
@Jesssullivan Jesssullivan changed the title Feat: add ExtraBody arg support via Fantasy for ZAI GLM thinking modes Feat: Add provider_options.extra_fields support complementing extra_body Oct 24, 2025
….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.
@Jesssullivan Jesssullivan marked this pull request as draft October 24, 2025 16:22
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.
@Jesssullivan Jesssullivan marked this pull request as ready for review October 24, 2025 16:43
@andreynering andreynering deleted the branch charmbracelet:crush-fantasy October 27, 2025 14:48
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.

2 participants