Skip to content

fix(provider): honor YAML integer provider_opts - #5120

Open
jacobvduncan wants to merge 1 commit into
docker:mainfrom
jacobvduncan:fix/yaml-integer-provider-opts
Open

jacobvduncan wants to merge 1 commit into
docker:mainfrom
jacobvduncan:fix/yaml-integer-provider-opts

Conversation

@jacobvduncan

Copy link
Copy Markdown

Summary

goccy/go-yaml decodes an unquoted positive integer as uint64, which GetProviderOptInt64 and GetProviderOptFloat64 in providerutil don't accept, so those provider_opts are ignored. top_k: 40 never reaches Anthropic, Bedrock or Gemini, top_k and seed never reach OpenAI-compatible Chat Completions, and examples/rag/gemini_embeddings.yaml fails with provider_opts.output_dimensionality must be a positive integer, got 768. Same class as #4596 and #4646.

Both helpers now accept uint64, and GetProviderOptInt64 rejects values above math.MaxInt64. Other numeric types are handled as before.

With integers read, top_k would also be sent alongside thinking, which Anthropic and Bedrock document as incompatible. A decimal top_k: 40.0 already does this on main. Like temperature and top_p, top_k is now withheld while thinking is on, in the Anthropic (standard and Beta) and Bedrock clients. sentRequestShape, which the fallback check uses, mirrors this and now applies the request builder's 1024-token minimum before treating a budget as thinking. The thinking, Anthropic and Bedrock docs are updated to match.

Testing

  • uint64 rows in TestGetProviderOptInt64 and TestGetProviderOptFloat64, including the math.MaxInt64 boundary, and TestNumericProviderOptsFromYAML. The rows that expect a value and the YAML test fail without the fix.
  • TestTopKOnlyWithThinkingOff (Anthropic standard and Beta) and TestBuildAdditionalModelRequestFields_TopKOnlyWithThinkingOff (Bedrock). The thinking-on cases fail without the change.
  • TestValidateFallbackRequestShape rows for top_k with thinking on, which fails without the change, and for top_k and temperature with a token budget below 1024, which the builder ignores, so it still sends them.
  • TestCloneVertexNativeDispatch checked its top_k precision value on the original request, which thinks. It now checks it on the clone, which doesn't, and checks that the original has no top_k.
  • Captured requests locally from configs loaded with config.Load: each client now sends the value, including outputDimensionality: 768, and with thinking on Anthropic and Bedrock send no top_k. sentRequestShape matched the request actually sent across 10 models, 17 thinking budgets and both clients.
  • go test ./pkg/model/... ./pkg/config/..., golangci-lint run ./pkg/model/provider/... and go mod tidy --diff pass.

QA

  1. Save as agent.yaml:
agents:
  root:
    model: local
    instruction: Say hi.
models:
  local:
    provider: openai
    model: qwen3
    base_url: http://127.0.0.1:9/v1
    provider_opts:
      api_type: openai_chatcompletions
      top_k: 40
  1. Run OPENAI_API_KEY=x ./bin/docker-agent run --exec --debug --log-file debug.log agent.yaml hi. The request fails since nothing listens on port 9.
  2. Before the fix, debug.log logs provider_opts type mismatch, ignoring with key=top_k and actual_type=uint64, and the logged request has no top_k. After it, debug.log logs OpenAI provider_opts: forwarding sampling param with key=top_k value=40, and the logged request includes top_k.

@jacobvduncan
jacobvduncan requested a review from a team as a code owner December 4, 2026 06:33
@aheritier aheritier added area/docs Documentation changes area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/providers/bedrock AWS Bedrock provider support kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Dec 4, 2026

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One blocker: /btw fails with an Anthropic fallback configuration this PR newly accepts. Thanks for fixing the YAML integer handling.

return requestShape{
sampling: !thinking && !primaryRejects && (cfg.Temperature != nil || cfg.TopP != nil),
topK: topK && !primaryRejects,
topK: topK && !thinking && !primaryRejects,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] The top_k with thinking on config in fallbacks_test.go now passes for the main model, but /btw fails before sending a request. pkg/runtime/side_query.go:68 rebuilds the provider with WithNoThinking() and keeps both top_k: 5 and the claude-sonnet-5-5 fallback. On rebuild, this check sees thinking off and rejects the clone because the fallback doesn't accept top_k. Please make the no-thinking auxiliary clone retain the fallback list without sending the incompatible top_k, and add a regression test that constructs the clone and checks its request.

@aheritier
aheritier marked this pull request as draft December 4, 2026 12:44
@aheritier

Copy link
Copy Markdown
Collaborator

Please mark this PR ready for review once you’ve addressed the requested changes. Thanks!

Signed-off-by: jacobvduncan <jacobvduncan@gmail.com>
@jacobvduncan
jacobvduncan force-pushed the fix/yaml-integer-provider-opts branch from 2ab90ae to 6c6122b Compare December 5, 2026 00:47
@jacobvduncan

Copy link
Copy Markdown
Author

Thanks good catch, should be addressed now .

@jacobvduncan
jacobvduncan marked this pull request as ready for review December 5, 2026 01:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation changes area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/providers/bedrock AWS Bedrock provider support area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants