Repository navigation
fix(provider): honor YAML integer provider_opts - #5120
jacobvduncan wants to merge 1 commit into
Conversation
aheritier
left a comment
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
[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.
|
Please mark this PR ready for review once you’ve addressed the requested changes. Thanks! |
Signed-off-by: jacobvduncan <jacobvduncan@gmail.com>
2ab90ae to
6c6122b
Compare
|
Thanks good catch, should be addressed now . |
Summary
goccy/go-yaml decodes an unquoted positive integer as
uint64, whichGetProviderOptInt64andGetProviderOptFloat64inproviderutildon't accept, so thoseprovider_optsare ignored.top_k: 40never reaches Anthropic, Bedrock or Gemini,top_kandseednever reach OpenAI-compatible Chat Completions, andexamples/rag/gemini_embeddings.yamlfails withprovider_opts.output_dimensionality must be a positive integer, got 768. Same class as #4596 and #4646.Both helpers now accept
uint64, andGetProviderOptInt64rejects values abovemath.MaxInt64. Other numeric types are handled as before.With integers read,
top_kwould also be sent alongside thinking, which Anthropic and Bedrock document as incompatible. A decimaltop_k: 40.0already does this on main. Liketemperatureandtop_p,top_kis 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
uint64rows inTestGetProviderOptInt64andTestGetProviderOptFloat64, including themath.MaxInt64boundary, andTestNumericProviderOptsFromYAML. The rows that expect a value and the YAML test fail without the fix.TestTopKOnlyWithThinkingOff(Anthropic standard and Beta) andTestBuildAdditionalModelRequestFields_TopKOnlyWithThinkingOff(Bedrock). The thinking-on cases fail without the change.TestValidateFallbackRequestShaperows fortop_kwith thinking on, which fails without the change, and fortop_kandtemperaturewith a token budget below 1024, which the builder ignores, so it still sends them.TestCloneVertexNativeDispatchchecked itstop_kprecision value on the original request, which thinks. It now checks it on the clone, which doesn't, and checks that the original has notop_k.config.Load: each client now sends the value, includingoutputDimensionality: 768, and with thinking on Anthropic and Bedrock send notop_k.sentRequestShapematched 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/...andgo mod tidy --diffpass.QA
agent.yaml: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.debug.loglogsprovider_opts type mismatch, ignoringwithkey=top_kandactual_type=uint64, and the logged request has notop_k. After it,debug.loglogsOpenAI provider_opts: forwarding sampling paramwithkey=top_k value=40, and the logged request includestop_k.