Skip to content

fix(ai): give anthropic/claude names the Claude request profile #7910

Done

Description

@dan-petty

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_choice False, max_tokens 32000, parallel_tool_calls False.
  • anthropic/claude-sonnet-5-5: supports_forced_tool_choice at 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 with ai.provider set to gateway and a gateway URL.
  • THEN The profile of the model inside the retry wrapper has supports_forced_tool_choice equal to False.

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 with ai.provider set to gateway and a gateway URL.
  • THEN The settings of the model inside the retry wrapper hold max_tokens equal to CONST_AI_CLAUDE_GROUP_MAX_OUTPUT_TOKENS and parallel_tool_calls equal to False.

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_model resolves claude-sonnet-5-5 and anthropic/claude-sonnet-5-5 with ai.provider set to gateway and a gateway URL.
  • THEN The two models inside the retry wrapper have the same supports_forced_tool_choice, max_tokens and parallel_tool_calls values.

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 with ai.provider set to gateway and a gateway URL.
  • THEN The model inside the retry wrapper has supports_forced_tool_choice at its default True and holds no max_tokens setting.

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 with ai.provider set to anthropic.
  • THEN The resolved model holds no supports_forced_tool_choice value and no max_tokens setting.

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-5 alone, a provider-prefixed name such as anthropic/claude-sonnet-5-5, and a gateway-prefixed name such as litellm:claude-sonnet-5-5. Under provider gateway, _model_prefix_and_target sends the whole name as the route, and _resolve_remote_provider_endpoint makes it openai-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 with claude-. (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.
  • Where do the profile and the settings sit on the resolved model?: _claude_group_model builds a ClaudeGroupChatModel with the profile {"supports_forced_tool_choice": False} and ModelSettings(max_tokens=CONST_AI_CLAUDE_GROUP_MAX_OUTPUT_TOKENS, parallel_tool_calls=False). _gateway_call_model wraps 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_gateway is true. The issue reproduces the defect with ai.provider: gateway only. (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

  1. added
    type/bug
    scope/ai
    source/agent
    status/new
    effort/low
    value/high
    on Nov 30, 2026
  2. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p1-high
    on Nov 30, 2026
  4. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    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:

    • litellm model_prices_and_context_window.json supports_tool_choice supports_parallel_function_calling max_tokens, results: 5
    • open database of AI model capabilities context limits models.dev, results: 5
    • pydantic-ai ModelProfile supports tool choice default max_tokens anthropic, results: 5
    • models.dev model specifications API, results: 5
    • pydantic-ai model profiles documentation, results: 5
    • litellm model cost map capabilities, results: 5
    • pydantic-ai, results: 5
    • litellm, results: 5
    • models.dev, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  6. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. 9 remaining items

  8. added a commit that references this issue on Dec 1, 2026
  9. added
    status/planned
    owner/service
    status/in-progress
    and removed
    status/ready
    status/planned
    on Dec 1, 2026
  10. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor

    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_choice to False for claude-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.

  11. added
    status/in-review
    and removed
    status/in-progress
    on Dec 1, 2026
  12. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The draft pull request #8037 holds the final title and body. In mode on of roadmap.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.

  13. removed
    owner/service
    on Dec 1, 2026
  14. removed
    status/in-review
    on Dec 1, 2026
  15. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Live since 2026-12-01 16:44 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p1-highscope/aisource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions