Repository navigation
Description
Problem
_resolve_remote_inferred_model in src/devops_cli/ai/pydantic_ai_bridge.py gives the Claude request profile only to a name that starts with openai-chat:claude-. The name anthropic/claude-sonnet-5-5 resolves to openai-chat:anthropic/claude-sonnet-5-5, so it gets no profile. CONST_AI_GATEWAY_HOSTED_MODELS and the gateway alias map accept that name.
Reproduction
Resolve both names with ai.provider: gateway. Read the profile and the settings of the model inside the retry wrapper.
claude-sonnet-5-5:supports_forced_tool_choiceFalse,max_tokens32000,parallel_tool_callsFalse.anthropic/claude-sonnet-5-5:supports_forced_tool_choiceat its default True, no settings.
Effect
An agent with a tool output sends tool_choice: required, which a Claude model refuses with 400 (#4205), and a gateway fallback hides it. The reply also gets the 4096 token default (#4220) and joined tool arguments (#4228).
Expected
Each accepted name of a Claude group gets the same profile and settings.
Source
Source: #7909
Alternatives check of 2026-11-30: in-use.
The repository already uses this tool.
Tool: BerriAI/litellm (https://github.com/BerriAI/litellm), NOASSERTION, last activity 2026-11-30, maintained.
Reason: LiteLLM's model cost map supplies max output tokens and tool-choice flags per provider-prefixed name, so it covers the capability data, not the gateway alias to profile wiring.
Covers:
- Per-model max output tokens and context window in one maintained map
- Capability flags for tool choice and parallel function calls
- Lookup by provider-prefixed names such as anthropic/claude-sonnet-4
Lacks:
- Does not say which tool_choice values a model accepts
- Does not map gateway aliases such as claude-sonnet-5-5
- Does not wire the project's request profile or retry wrapper
Proposed design
Problem statement
The bridge gives the Claude request profile only to a name that starts with openai-chat:claude-. The gateway accepts anthropic/claude-sonnet-5-5, and that name gets no profile. It sends tool_choice: required and a Claude model refuses it with 400 (#4205). It also gets the 4096 token default (#4220) and joined tool arguments (#4228). The change gives each accepted name of a Claude group the same profile and settings.
Acceptance criteria
Requirement: Profile on a provider-prefixed Claude name
The bridge SHALL give the Claude request profile to each accepted name of a Claude group that a gateway serves.
Scenario: Provider-prefixed Claude name
- WHEN
resolve_pydantic_ai_model("anthropic/claude-sonnet-5-5")runs withai.providerset togatewayand a gateway URL. - THEN The profile of the model inside the retry wrapper has
supports_forced_tool_choiceequal toFalse.
Requirement: Request settings on a provider-prefixed Claude name
The bridge SHALL give each accepted name of a Claude group the request settings of the Claude group.
Scenario: Max tokens and parallel tool calls
- WHEN
resolve_pydantic_ai_model("anthropic/claude-sonnet-5-5")runs withai.providerset togatewayand a gateway URL. - THEN The settings of the model inside the retry wrapper hold
max_tokensequal toCONST_AI_CLAUDE_GROUP_MAX_OUTPUT_TOKENSandparallel_tool_callsequal toFalse.
Requirement: Alias and provider-prefixed name agree
The bridge SHALL give the same profile and the same settings to each accepted name of one Claude model.
Scenario: Alias and provider-prefixed name
- WHEN
resolve_pydantic_ai_modelresolvesclaude-sonnet-5-5andanthropic/claude-sonnet-5-5withai.providerset togatewayand a gateway URL. - THEN The two models inside the retry wrapper have the same
supports_forced_tool_choice,max_tokensandparallel_tool_callsvalues.
Requirement: No Claude profile on another gateway route
The bridge MUST NOT give the Claude request profile to a gateway route that is not a Claude group.
Scenario: OpenAI route on the gateway
- WHEN
resolve_pydantic_ai_model("openai/gpt-4o")runs withai.providerset togatewayand a gateway URL. - THEN The model inside the retry wrapper has
supports_forced_tool_choiceat its defaultTrueand holds nomax_tokenssetting.
Requirement: No Claude profile without a gateway
The bridge MUST keep the Claude request profile on the gateway path only.
Scenario: Direct Anthropic provider
- WHEN
resolve_pydantic_ai_model("anthropic:claude-sonnet-5-5")runs withai.providerset toanthropic. - THEN The resolved model holds no
supports_forced_tool_choicevalue and nomax_tokenssetting.
Existing Tool Considered
BerriAI/litellm, verdict in-use (see the alternatives check in the issue body for what it covers and lacks). The block names the gap: the tool does not wire the project's request profile or the retry wrapper. This change does that wiring. It maps each accepted gateway name of a Claude model to the profile and the settings in _resolve_remote_inferred_model.
Key questions
- Which names must get the Claude request profile?: Each name that resolves to a Claude model on a gateway:
claude-sonnet-5-5alone, a provider-prefixed name such asanthropic/claude-sonnet-5-5, and a gateway-prefixed name such aslitellm:claude-sonnet-5-5. Under providergateway,_model_prefix_and_targetsends the whole name as the route, and_resolve_remote_provider_endpointmakes itopenai-chat:<route>. [sources: src/devops_cli/ai/pydantic_ai_bridge.py:145, src/devops_cli/ai/pydantic_ai_bridge.py:120, src/devops_cli/config/constants.py:3429] - How does the bridge detect the name of a Claude group?: Test the last path segment of the route for the prefix
claude-. Strip the text before the first colon, take the text after the last/, and compare it withclaude-. (best practice) [sources: src/devops_cli/ai/pydantic_ai_bridge.py:145]- Chosen: Last path segment starts with
claude-. One rule covers the bare alias, the provider-prefixed name and the gateway-prefixed name. The gateway gets the full route unchanged. - Rejected: List each accepted alias in a constant. Each new alias needs a code change, and the list drifts from the gateway alias map.
- Rejected: Read the LiteLLM cost map at run time. The map does not map the gateway aliases, as the alternatives block records, and it adds a data dependency to model resolution.
- Chosen: Last path segment starts with
- Where do the profile and the settings sit on the resolved model?:
_claude_group_modelbuilds aClaudeGroupChatModelwith the profile{"supports_forced_tool_choice": False}andModelSettings(max_tokens=CONST_AI_CLAUDE_GROUP_MAX_OUTPUT_TOKENS, parallel_tool_calls=False)._gateway_call_modelwraps that model after it is built, and the reproduction in the issue reads the values inside the retry wrapper. [sources: src/devops_cli/ai/pydantic_ai_bridge.py:120, src/devops_cli/ai/pydantic_ai_bridge.py:122, tests/ai/test_pydantic_ai_profiles_and_providers.py:515] - Does the change also give the profile to a direct Anthropic provider?: No. The Claude group is a gateway group, and the code applies the profile only when
to_gatewayis true. The issue reproduces the defect withai.provider: gatewayonly. (best practice) [sources: src/devops_cli/ai/pydantic_ai_bridge.py:145]- Chosen: Keep the gateway-only gate. The profile exists because the gateway maps the request to Anthropic, and the issue names the gateway path only.
- Rejected: Apply the profile under every provider. It widens the change past the defect and the issue gives no evidence for a non-gateway failure.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 30, 2026
The bug causes 400 errors and wrong token limits for Claude model calls, increasing error rates for users.Both fix name-based parameter selection in the AI client, but #888 targets reasoning parameters and this candidate targets the Claude profile (tool_choice, max_tokens, parallel_tool_calls).feat(k8s): run plan and implement jobs on claude-sonnet-5-5 (#7912)
devops-cli-service commentedon Nov 30, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (9)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Dec 1, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
9 remaining items
docs(spec): plan #7910 give Claude names the Claude request profile (#…
dan-petty commentedon Dec 1, 2026
Review of #8011 on 2026-12-01: the acceptance criterion for the direct Anthropic provider is false. In pydantic-ai 2.77.0 the native profile already sets
supports_forced_tool_choiceto False forclaude-sonnet-5-5. The merged plan tests the request settings and the cache break in its place. Since #8030, no Service task names a Claude group, so the defect reaches only a caller that passes a prefixed name on the gateway.devops-cli-service commentedon Dec 1, 2026
The draft pull request #8037 holds the final title and body. In mode
onofroadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.Spend: 27 model requests, 1619868 input tokens, 14236 output tokens.
devops-cli-service commentedon Dec 1, 2026
Released in v0.270.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.270.1
devops-cli-service commentedon Dec 1, 2026
Live since 2026-12-01 16:44 UTC