Skip to content

fix(roadmap): Sonnet tool calls reach the run with joined args #4228

Closed

Description

@dan-petty

Problem

A stage plan run on claude-sonnet-5-5 through the gateway ended with StructuredOutputValidationError: 0 schema violation(s) after the output cap of #4220 was in place. The cap works: the error is not the new output-limit error of #4220. The gateway log (container litellm, namespace llm) of the same run holds 8 warnings of this form from factory.py:

Failed to parse tool call arguments for tool 'search_code' (chat completions). Error: Extra data: line 1 column 92. Arguments: {"path": "...", "start_line": 930, "end_line": 1030}{"text": "..."}{"text": "..."}

The model asked for several tool calls in one reply. The gateway joined the arguments of those calls into one JSON text for one call, and the text does not parse. The run was DEVOPS_CLI_AI_TASK_STAGE_MODEL=claude-sonnet-5-5 devops roadmap stage --plan --item 4062 and took 7 min 56 s.

Not verified: whether these joined arguments are the cause of the stop. The stop reason is not logged (the failure line holds no reason). This issue asks to find the cause and fix it.

Expected

  • A reply with several tool calls reaches the stage run as several calls with valid arguments, or the request tells Anthropic to make one tool call at a time.
  • A run that stops because it broke the output rules states the reason in its failure line (the reply had no function tool call, or a tool call had no valid arguments), not only a violation count.

Acceptance criteria

  1. A test sends a reply with two tool calls through the layer that fails today and asserts that both calls arrive with valid JSON arguments (it fails today).
  2. A test for a run that stops on a tool call with invalid arguments asserts that the failure text names that cause.
  3. devops roadmap stage --plan --item <small item> on claude-sonnet-5-5 ends with a plan or a named cause, not "0 schema violation(s)".

Existing tool considered

The tool settings of the Anthropic API (tool_choice with disable_parallel_tool_use) and the LiteLLM conversion code in factory.py. Both exist already. Check the LiteLLM release notes for a fix before any code is built.

Related

#4220 (output cap), #4221 (window estimate), #3529.

Proposed design

Problem statement

A stage plan run on claude-sonnet-5-5 through the LiteLLM gateway ended with StructuredOutputValidationError: 0 schema violation(s). The gateway log of the run holds 8 factory.py warnings. In them the gateway joined the arguments of several tool calls into one JSON text that does not parse. It is not verified that these joined arguments caused the stop. The failure line gives only a violation count, so it hides the cause. The count is 0 because the run stopped on a reply with no function tool call, and no schema check ran. The change makes the failure line name the reason, and stops the joined arguments by asking the provider for one tool call per reply.

Acceptance criteria

Requirement: One tool call at a time for Claude groups

The model of a hosted Claude group on a gateway SHALL send parallel_tool_calls set to false and keep tool_choice auto, so the provider makes at most one tool call in each reply.

Scenario: Request settings for a Claude group

  • WHEN the client builds the model of the group claude-sonnet-5-5 on a gateway
  • THEN its settings hold parallel_tool_calls false and max_tokens, its profile still has supports_forced_tool_choice false, and a model of another group holds no parallel_tool_calls setting

Requirement: Several tool calls arrive with valid arguments

The layer that converts a reply with several tool calls SHALL deliver each call with its own valid JSON arguments.

Scenario: Reply with two tool calls

  • WHEN a recorded reply with two tool calls passes through the layer that joins the arguments today
  • THEN both calls arrive and the arguments of each call parse as JSON, and the test fails on the current code

Requirement: Failure line names a tool call with invalid arguments

A run that stops on a tool call with invalid arguments SHALL state that cause in its failure line.

Scenario: Tool call with arguments that do not parse

  • WHEN the run ends because the last reply holds a tool call whose arguments are not valid JSON
  • THEN the failure text names the tool and says that its arguments are invalid, and it does not show only a violation count

Requirement: Failure line names a reply with no function tool call

A run that stops because the reply had no function tool call SHALL state that cause in its failure line.

Scenario: Reply with no tool call

  • WHEN the run ends because the last model reply holds no function tool call and no schema check failed
  • THEN the failure text says that the reply had no function tool call, and it does not read '0 schema violation(s)'

Existing Tool Considered

Two existing means cover the need. (1) The Anthropic tool setting tool_choice with disable_parallel_tool_use; the project already sends the OpenAI field parallel_tool_calls through create_model_settings (src/devops_cli/ai/settings/__init__.py:16), and LiteLLM maps it for Anthropic. (2) A fix in the LiteLLM conversion code in factory.py. No source was found in this run for a fixed release: the web search returned nothing on the warning and the LiteLLM docs page could not be fetched. So the first task checks the LiteLLM release notes after the pinned v1.103.0 (.devops/research-watch.toml:33) for a fix. If one exists, the change raises the image version in addition to the client setting. The client setting is a few lines in _claude_group_model and costs little to build and keep. Code of the project that splits joined arguments would cost many tokens to build and fix until it matched the gateway, and it would hide a gateway fault, so it is not built. Whether LiteLLM v1.103.0 maps parallel_tool_calls to disable_parallel_tool_use with tool_choice auto is not verified by a source here; a test of the offline gateway request, or a run on the live gateway, must confirm it.

Key questions

  • Does the gateway join the arguments of several tool calls, and does this cause the stop?: The gateway log of the run shows 8 factory.py warnings with joined arguments. The stop reason is not logged, so the link to the stop is not proven. The stop is a StructuredOutputValidationError, which the code raises only when the last reply held no call to a function tool of the run, and with 0 violations no schema check failed. A joined call to the output tool does fit that state: its arguments do not parse, so it is no valid output. The change adds the failure reason first, and a repeated run then shows the cause. [sources: src/devops_cli/roadmap/refine/refine_investigation.py:423, src/devops_cli/roadmap/stage/stage_toolbox.py:217, src/devops_cli/roadmap/stage/stage.py:1500, k8s/llm/gateway/config.yaml]
  • How does the change stop the joined arguments?: Add parallel_tool_calls=False to the settings of the model that _claude_group_model builds, next to max_tokens and the profile supports_forced_tool_choice false. The agent keeps tool_choice auto, because Sonnet 5.5 refuses a forced tool call. The first task reads the LiteLLM release notes; if a newer image fixes the joined arguments, the change raises the image too. (best practice) [sources: src/devops_cli/ai/pydantic_ai_bridge.py:83, src/devops_cli/ai/settings/init.py:16, k8s/README.md, openspec/changes/archive/2026-11-09-4205-claude-group-sends-tool-choice-auto/design.md]
    • Chosen: Send parallel_tool_calls false from the client. It is an existing setting of the API and of pydantic-ai, it needs a line in the place that already sets max_tokens for the Claude groups, and it matches the expected result of the issue.
    • Rejected: Raise the LiteLLM image version. Done only if the release notes show a fix. It does not fix the stage run if no release has one.
    • Rejected: Split the joined arguments in project code. It is a new parser to build and keep, and it hides a fault that the gateway should fix.
    • Rejected: Patch factory.py in a gateway image of the project. It adds a fork to keep, and a setting of the request gives the same result.
  • Where does the failure line of the stage run come from, and how does it get the reason?: _stopped in stage_toolbox.py maps InvestigationStopped.schema_broken to StructuredOutputValidationError(message, violations=trace.violations). _failure_of in stage.py then makes the reason of the failure line from MESSAGES.roadmap.stage_violations, which says only the count. The fix adds a typed cause to InvestigationStopped (for example cause: no_tool_call or invalid_arguments), set in _stopped_outcome from the last ModelResponse: a ToolCallPart whose args do not parse as JSON gives invalid_arguments with the tool name, and a reply with no function tool call gives no_tool_call. StructuredOutputValidationError carries it as a field, and _failure_of uses a message of the cause when violations is 0 or a cause is set, and the count only when schema checks failed. New message strings go in src/devops_cli/lang/en/messages.py beside stage_violations. The cause is read from the typed message parts, as feat(roadmap): the stage job plans with a read-only investigation toolbox #3037 and fix(roadmap): a Claude stage reply stops at 4096 tokens #4220 do, and the text of the error is not parsed. The message names the tool and no argument text, since a failure line must not show a reply. (best practice) [sources: src/devops_cli/roadmap/stage/stage_toolbox.py:205, src/devops_cli/roadmap/stage/stage.py:1495, src/devops_cli/roadmap/refine/refine_investigation.py:150, src/devops_cli/roadmap/refine/refine_investigation.py:450, src/devops_cli/lang/en/messages.py:3356, openspec/changes/archive/2026-11-09-4220-claude-stage-reply-output-cap/design.md]
    • Chosen: Add a typed cause to InvestigationStopped and use it in the failure line. It follows the pattern of schema_broken and output_limit in the project, reads the library's typed parts and not the error text, and needs one field and two messages.
    • Rejected: Parse the error message text for the reason. The design of feat(roadmap): the stage job plans with a read-only investigation toolbox #3037 refuses to read the message text, which can quote the reply of the provider.
    • Rejected: Log the stop reason in a separate log line. The failure line is what the person reads, so the reason must be there.
  • How does a person check the result on the live gateway?: After the rollout of the client change, a person runs DEVOPS_CLI_AI_TASK_STAGE_MODEL=claude-sonnet-5-5 devops roadmap stage --plan --item <small item> and reads the container litellm of the namespace llm for Failed to parse tool call arguments warnings. The run must end with a plan or a failure line that names its cause, and the log must hold no such warning. This needs the live gateway and a key, so no offline test covers it; the offline tests cover criteria 1 to 4. (a person decides) [sources: k8s/README.md, docs/roadmap/stage.md]

Open questions

  • How does a person check the result on the live gateway? (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 9, 2026
  2. dan-petty commented on Nov 9, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The bug blocks stage runs on one model but does not affect all models or all runs.
    • Value: Medium. It restores a working stage run path for users of claude-sonnet-5-5 through the gateway.
    • Effort: Medium. It needs a gateway config or code change in factory.py plus two new tests.
    • Related: fix(roadmap): a Claude stage reply stops at 4096 tokens #4220, which asks for a different change. Both fix stage runs on claude-sonnet-5-5 that end with StructuredOutputValidationError, but #4220 fixes the output token cap while this fixes joined tool call arguments in the gateway.
  3. added
    priority/p2-medium
    owner/agent
    on Nov 9, 2026
  4. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 111adc5 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • How does a person check the result on the live gateway? (a person decides)
  5. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 9, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 9, 2026
  7. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 17: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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions