Repository navigation
fix(claude): explicit Claude 5.x model table for request policy - #4657
Merged
Merged
Conversation
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…bilities Signed-off-by: Arnaud Héritier <aheritier@apache.org>
… table Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…actory applyModelDefaults turns a configured none into a nil budget plus WithNoThinking, so the Anthropic and Bedrock clients never saw it and Claude 5.x kept its default thinking. Restore the explicit none for the Claude 5.x table so it is sent as disabled or adaptive low. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…orts Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…retry A tool-mode reminder retry ends the request on the model's plain-text answer, which Claude 5.x rejects as an assistant prefill. Fail with the coded structured-output error after the first inference instead. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…and 0 budgets Signed-off-by: Arnaud Héritier <aheritier@apache.org>
…e thinking Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Importing vertexai for IsModelGardenConfig linked the OpenAI SDK into the lean embedder surface (e2e TestDependencies). Check the publisher directly. Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
… the factory level Signed-off-by: Arnaud Héritier <aheritier@apache.org>
This was referenced Oct 19, 2026
5 tasks
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-transport changes need human validation of the explicitly unverified Bedrock disabled-thinking and Vertex thinking-binding behavior.
No open issues 🎉
What changed in this PR
Adds an explicit nine-model Claude 5.x policy table for Anthropic, Vertex and Bedrock, while preserving existing behavior for other model IDs.
Changes:
- Aligns thinking, effort, sampling and prefix-check behavior with model capabilities.
- Rejects assistant prefills locally and avoids unsupported structured-output retries.
- Adds request-policy tests and updates provider documentation.
| File | Description |
|---|---|
pkg/runtime/structured_output.go |
Stops unsupported Claude 5.x reminder retries. |
pkg/runtime/structured_output_test.go |
Tests failure after one inference. |
pkg/runtime/loop.go |
Passes serving model to structured-output handling. |
pkg/modelinfo/thinking_levels.go |
Exposes all supported effort levels. |
pkg/modelinfo/modelinfo.go |
Uses table-based thinking capabilities. |
pkg/modelinfo/claude5.go |
Defines model policies and ID lookup. |
pkg/modelinfo/claude5_test.go |
Tests lookup and capabilities. |
pkg/model/provider/providerutil/prefill.go |
Detects final assistant prefills. |
pkg/model/provider/providerutil/prefill_test.go |
Tests prefill detection. |
pkg/model/provider/providers/claude5_requests_test.go |
Captures factory-built requests across transports. |
pkg/model/provider/factory.go |
Warns when configured thinking cannot be disabled. |
pkg/model/provider/factory_test.go |
Tests warning conditions. |
pkg/model/provider/bedrock/client.go |
Applies Claude 5.x Converse request rules. |
pkg/model/provider/bedrock/client_test.go |
Tests Bedrock policy handling. |
pkg/model/provider/anthropic/thinking.go |
Corrects disabled-thinking and effort handling. |
pkg/model/provider/anthropic/thinking_binding_test.go |
Updates binding expectations and warning tests. |
pkg/model/provider/anthropic/system_context_test.go |
Uses a legacy model for prefill coverage. |
pkg/model/provider/anthropic/features_integration_test.go |
Tests Claude 5.x requests and legacy behavior. |
pkg/model/provider/anthropic/client.go |
Rejects Claude 5.x prefills locally. |
pkg/model/provider/anthropic/capabilities.go |
Prioritizes explicit model policies. |
pkg/model/provider/anthropic/capabilities_test.go |
Tests all nine model policies. |
docs/providers/bedrock/index.md |
Documents Converse behavior and verification limits. |
docs/providers/anthropic/index.md |
Documents Claude 5.x request rules. |
agent-schema.json |
Updates prefix-mismatch policy documentation. |
Review effort: Balanced
aheritier
added this pull request to stack #4659
October 19, 2026 22:25
Signed-off-by: Arnaud Héritier <aheritier@apache.org>
dgageot
approved these changes
Oct 20, 2026
This was referenced Oct 20, 2026
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.
Closes #4651. Part of #4583 (Claude 5.x core) and epic #4580.
What
Replace the name-based guesses for Claude 5.x with an explicit table of the nine models (
modelinfo.LookupClaude5). Anthropic Direct, Vertex and Bedrock Converse now send each of them a request it accepts. IDs outside the table keep exactly today's behavior.All nine use adaptive thinking by default, reject token budgets and sampling params, and accept every effort level up to
max.Bugs fixed (each with a test that failed before)
thinking_budget: highwas sent asbudget_tokens, which every 5.x model rejects.budget_tokenson Sonnet 5/5.5, Haiku 5.5, Fable and Mythos.temperature/top_p/top_kwere sent to 5.x models.thinking_budget: nonenever reached the Claude clients through the factory.applyModelDefaultsturns it into a nil budget plusWithNoThinking, so on 5.x thinking stayed on at the server default, on Direct, Vertex and Bedrock. It is now sent asdisabledwhere the model allows it and as adaptive/lowotherwise.thinking: disabled, which they reject.xhigh/maxon Haiku 5.5, Sonnet 5 and Sonnet 5.5.Behavior changes to review
noneon a model that can't disable thinking (Opus/Sonnet 5.5, Fable, Mythos) is sent as adaptive withloweffort. When the value came from config, a startup warning says so. Internal calls (titles, MCP sampling) get the same mapping silently.max_tokensis not raised, and the warning now says the token ceiling is not enforced.ErrorCodeStructuredOutputFailedafter the first plain-text answer, instead of retrying with reminders. Each retry would end on the model's answer, which 5.x rejects. feat(Claude): Claude 5.x core — request policy and signed history #4583 asks for "one inference, then a graceful model error", with no role rewrite.drop_blockbinding. Haiku, Opus and Sonnet 5.5 now get it, the same way Fable 5.1 already did. The default policy itself (drop_blockvserror) is feat(anthropic): Claude 5.x safety defaults (prefix error, temporary fallback block, Mythos 5 on Converse) #4652.Tests
@date, Bedrockus.anthropic.…-v1:0, gateway prefixes and near-miss IDs.openai/claude-…IDs deliberately don't match.providers.NewDefaultRegistry()) for Direct standard, Direct Beta, Vertex Model Garden (path,anthropic_version, bearer auth, no API key, de-duplicated betas), Bedrock Converse and a title clone, plus legacy controls.References
Vendor documentation behind each change (all links checked on 2026-10-20). The per-model matrix these rules come from is in #4583.
budget_tokensrejected (token budgets coerced to adaptive)low…max, includingxhigh(TUI effort cycle)drop_blockbindingvertex-2023-10-16, OAuth)Validation
task buildpasses.golangci-lintv2.14.0 reports 0 issues, andgo run ./lint .reports no offenses.go test -race -shuffle=on ./pkg/modelinfo/ ./pkg/model/provider/... ./pkg/runtime/passes.go test ./e2e -run '^TestWasmProviderDependencies$|^TestDependencies$'passes.task test-wasm-providers: the WASM JS packages pass. Running it needed a minimal environment, because Node rejected my shell's environment size.task testfails onlypkg/teamloaderTestLoadExamples(10 Gemini examples,GOOGLE_API_KEY or GEMINI_API_KEY environment variable is requiredunder.env.test). The base commit7eedf8dfails identically on this machine.Not verified against live services: Bedrock
thinking: {"type":"disabled"}and the thinking-binding beta on Vertex. The docs say so.