Skip to content

fix(coderd/x/chatd): keep the chat output cap on compaction summaries - #31042

Open
ibetitsmike wants to merge 2 commits into
mainfrom
mike/compaction-summary-output-cap
Open

ibetitsmike wants to merge 2 commits into
mainfrom
mike/compaction-summary-output-cap

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Compaction summaries asked the provider for 1.5 times the model's configured output cap. When an admin adds a known model, the form fills max_output_tokens with the provider maximum, 128,000 for claude-opus-5-5, so each summary request sent max_tokens: 192000. Anthropic rejected it with HTTP 400 (max_tokens: 192000 > 128000, which is the maximum allowed number of output tokens for claude-opus-5-5), so compaction failed and the chat could not shrink its context.

compactionSummaryCall now keeps the chat call's cap. The 50% headroom came from #28886, which accepted the overshoot for caps set at a provider ceiling as a tradeoff. With catalog defaults, that case is the common one. GenerateCompaction still lowers the cap to the remaining context window when that is smaller.

Closes CODAGT-1428.

The ticket also shows "Your input exceeds the context window" on a summary request. That is a separate failure, which #30766 handles (merged after the ticket was filed), so this PR does not change it.

Tests

  • New TestActiveServer_ManualCompaction/summary keeps the configured output cap: a 128,000 cap reaches both the chat turn and the summary request unchanged. On the old code it fails with expected: 128000 actual: 192000.
  • TestBuildTurnEnvironmentClampsRequestedReasoningEffortToMax and the compaction hook tests now expect the unchanged default cap (32,000 instead of 48,000). test(coderd/x/chatd): fold the effort clamp fixture into the pending-user test #30942 rewrites the first test and keeps a 3 * defaultChatMaxOutputTokens / 2 expectation, so whichever PR merges second drops that factor.

Validation

  • go test ./coderd/x/chatd/ ./coderd/x/chatd/chatloop/ -count=1: passes
  • make pre-commit: passes
  • Remote dogfood UAT against claude-opus-5-5 with a 128,000 cap: on main, manual, automatic, and compaction-model-override summaries asked for 192,000 tokens and failed with the 400 above. On this branch, all 16 summary requests (the same flows plus an unset cap and a small context window) succeeded, and none asked for more than its configured cap. Chat turn max_tokens was the same on both. UAT ran on 9230a6e9fa1; the head 3633adef53e only adds a comment edit.
  • No new dependencies. The polish pass and the test audit changed no files.
  • Codex review on 3633adef53e: no findings.

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

Compaction summary requests asked for 1.5x the chat model's
max_output_tokens. When the configured cap equals the provider maximum
(as the known-model catalog seeds it), providers such as Anthropic
reject the summary with HTTP 400, so the chat can never compact.
Summaries now use the same output cap as chat turns; GenerateCompaction
still lowers it to the remaining context window.
@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

CODAGT-1428

@ibetitsmike

ibetitsmike commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum posted this comment on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T08:51:42.066692Z 3633ade Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 3633adef53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike marked this pull request as ready for review October 20, 2026 08:49

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant