Skip to content

fix(roadmap): cap the output of a Claude group and name a length stop - #4224

Merged
dan-petty merged 5 commits into
mainfrom
fix/4220-claude-stage-reply-output-cap
Nov 9, 2026
Merged

dan-petty merged 5 commits into
mainfrom
fix/4220-claude-stage-reply-output-cap

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A request to a Claude group set no max_tokens, so the gateway used the Anthropic default of 4096. A long stage reply was cut, and the run showed it as 0 schema violation(s). The group model now sends an output cap of 32000 tokens (a named constant, far under the model limit of 128000 and about eight times the default). A stop on the output limit now raises an error that names the output token limit and the max_tokens setting.

Closes #4220

Change: openspec/changes/archive/2026-11-09-4220-claude-stage-reply-output-cap/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 9, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record

Fail-to-pass (devops ci fail-to-pass --base origin/main, before the fix): 8 tests fail on base, 140 pass, 0 error, in tests/ai/test_pydantic_ai_profiles_and_providers.py, tests/roadmap/refine/test_roadmap_refine_investigation.py and tests/roadmap/stage/test_roadmap_stage_toolbox.py. Output: .data/agent/state/4220-fail-to-pass.txt in the work area. The CI job "Fail-to-Pass Check" passes on this pull request.

Full devops ci run (one run, under the shared lock): all rows passed except test-tree. The cause was my own test assertions (opaque tuples). I fixed it in e70af200, and devops ci --only test-tree then passed (12 cases, 0 failed). The pytest row took 10m 21s, over the 5 minute budget. This is the known class of #3593 and this change does not cause it. All required GitHub checks pass on this pull request.

Output cap

  • max_tokens is 32000 (CONST_AI_CLAUDE_GROUP_MAX_OUTPUT_TOKENS). It is about 8 times the Anthropic default of 4096, far under the 128000 output limit of claude-sonnet-5-5, and it leaves room for thinking tokens, which count in max_tokens. The wire key is max_completion_tokens.
  • The cap is in the client only. It is not copied into k8s/llm/gateway/config.yaml.
  • Whether LiteLLM applies litellm_params.max_tokens as a default: NOT verified. LiteLLM is not installed in the venv, and a live check needs a reply of more than 4096 tokens, which is not a tiny call. No setting is added, so no ConfigMap rollout is needed.

Live check (one stage plan through the gateway)

Command: DEVOPS_CLI_AI_TASK_STAGE_MODEL=claude-sonnet-5-5 devops roadmap stage --plan --item 4062. Time: 7 min 56 s. Cost: not read (the repository has no spend command; the run is under the 1 USD cap by my estimate only, NOT measured).

Result: the run did NOT end with a plan. It failed with StructuredOutputValidationError: 0 schema violation(s). This is not the output-limit error of this change, so the run had no length stop. But it is not a clean end either. The gateway log (Loki, container litellm) of the same minutes holds 8 warnings "Failed to parse tool call arguments for tool 'search_code' ... Extra data": the arguments of several parallel tool calls were joined into one JSON text. I did not prove that this is the cause of the stop, because the failure line holds no reason. Filed as #4228.

So this pull request does not prove that a Claude stage plan completes. It proves the cap (tests) and the named error (tests). A person decides whether to put the stage task back on Sonnet only after #4228 and #4221 are fixed.

Second factor

The window estimate that removes the function tools too early (1.4 times the real count, and "Unknown tool name: read_file" using the one retry) is already filed as #4221 (filed 12:53Z, covers the full text of the observation). I filed nothing new for it.

@dan-petty
dan-petty marked this pull request as ready for review November 9, 2026 13:26
@dan-petty
dan-petty merged commit 7e84a13 into main Nov 9, 2026
26 checks passed
@dan-petty
dan-petty deleted the fix/4220-claude-stage-reply-output-cap branch November 9, 2026 13:29
dan-petty pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.100.2](v0.100.1...v0.100.2)
(2026-11-09)


### Bug Fixes

* **ai:** guard urlsplit in cost report for unparseable backend
([#4226](#4226))
([961f406](961f406))
* **k8s:** list helm repo and upgrade in deploy-stack dry-run
([#4227](#4227))
([09bde83](09bde83))
* **roadmap:** cap the output of a Claude group and name a length stop
([#4224](#4224))
([7e84a13](7e84a13))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Nov 9, 2026
…4260)

The stage job kept only the last problem of a refused reply and kept no
refused reply, so a failed plan could not be read. A reply of
placeholders in every text also used the second request and gave the
same reply. The job now logs each refused reply with the request number,
the input tokens and the tool offer, keeps the first and second refused
reply with their problems in a file beside the plan file until the item
is staged, and ends a placeholder reply at once as the new result
degenerate (metric and stage eval). Other changes removed the causes of
the placeholder replies: #4215, #4216, #4224, #4238 and #4243.

Closes #4204

Change:
`openspec/changes/archive/2026-11-09-4204-keep-refused-stage-reply/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): a Claude stage reply stops at 4096 tokens

1 participant