Repository navigation
fix(claude): stop re-attaching the token footer as a user turn - #6714
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughWith prompt-cache stabilization enabled, recognized trailing token footers are removed from translated Claude instructions and are not added as user input. TaskCreate nudges remain available as trailing user messages. Tests cover translated requests and unchanged native passthrough. ChangesClaude inbound prompt-cache stabilization
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Recognized token footers no longer become translated user input, while TaskCreate notices and native passthrough retain their documented behavior. No material merge-blocking risk is evident. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (7 skipped: 7 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04b5e3118f
ℹ️ 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".
| route. Pass `"haiku"` as the model placeholder. | ||
|
|
||
| Set `claudeCode.stabilizePromptCache` to `true` in `config.json` to relocate supported trailing Claude harness notices from system instructions to a trailing user message on translated routes. The default is `false`. Enable it only when this role change is appropriate for your clients. It preserves fenced examples and unmatched text; native Anthropic passthrough is unchanged. The metadata-less prompt-cache key then follows stabilized instructions. This does not create conversation identity or guarantee upstream cache hits. | ||
| Set `claudeCode.stabilizePromptCache` to `true` in `config.json` to peel supported trailing Claude harness notices from system instructions on translated routes. Recognized `<total_tokens>N tokens left</total_tokens>` footers are dropped, including repeated footers. TaskCreate reminders still move to a trailing user message; if only token footers were peeled, no input message is added. The default is `false`. Enable it only when this role change is appropriate for your clients. It preserves fenced examples and unmatched text; native Anthropic passthrough is unchanged. The metadata-less prompt-cache key then follows stabilized instructions. This does not create conversation identity or guarantee upstream cache hits. |
There was a problem hiding this comment.
Synchronize the localized cache-stabilization documentation
The Korean, Russian, French, Traditional Chinese, Japanese, Simplified Chinese, and Turkish versions of this guide still state that every supported trailing notice is moved to a final user message. With this change, <total_tokens> footers are instead discarded, so users reading those locales receive instructions that directly contradict both the updated English page and runtime behavior. Update the corresponding localized paragraphs to distinguish dropped token footers from relocated TaskCreate reminders.
AGENTS.md reference: docs-site/AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
|
Maintainer integration into
|
Summary
claudeCode.stabilizePromptCache: true, keep peeling recognized trailing<total_tokens>N tokens left</total_tokens>footers from Claude Messages system instructions, but drop them instead of re-attaching them as a trailing user message. Tool-result requests therefore no longer acquire a synthetic user turn from the token footer.layout.json(1,998 lines).Closes #6646
Verification
6095abb78f6ee3bd1d4e1296a8f72702b3da4da4: updated only the stabilization paragraph in the Korean, French, Japanese, Russian, Turkish, Simplified Chinese, and Traditional Chinese guides. All seven now document removal of recognized token footers (including repeats), preservation of TaskCreate reminders in the trailing user message, and no added input message for footer-only notices. Existing runtime regression tests and both layout registrations are unchanged.bun test ./tests/claude-integration/claude-inbound-token-footer.test.ts ./tests/claude-integration/claude-inbound-cache-stabilize.test.ts ./tests/claude-integration/claude-inbound.test.ts ./tests/claude-integration/claude-native-passthrough.test.ts ./tests/test-layout.test.ts ./tests/test-layout-tooling.test.ts ./tests/ci-workflows/file-size-ratchet.test.ts— 213 pass / 0 fail across 7 files.bun run typecheckandbun run structure:check— both exit 0; structure SSOT checks passed.git diff --cached --check— exit 0.wc -l scripts/test-layout/layout.json— 1,998 lines (below 2,000).bun install --frozen-lockfileindocs-site/— exit 0, no changes;bun run buildindocs-site/— exit 0, 561 pages and 78,111 internal links checked.bun test ./tests/claude-integration/claude-inbound-token-footer.test.ts— 0 pass / 4 fail. All four failures showed the extra footer user item or footer contamination of the TaskCreate notice.bun test ./tests/claude-integration/claude-inbound-token-footer.test.ts ./tests/claude-integration/claude-inbound-cache-stabilize.test.ts ./tests/claude-integration/claude-inbound.test.ts ./tests/claude-integration/claude-native-passthrough.test.ts ./tests/test-layout.test.ts ./tests/test-layout-tooling.test.ts ./tests/ci-workflows/file-size-ratchet.test.ts— 213 pass / 0 fail across 7 files, including footer-only, repeated and mixed notices, tool-result pairing, fences/unmatched text, cache keys, explicit opt-out and live local native passthrough with opt-in enabled.bun run typecheck— exit 0.bun run structure:check— exit 0, SSOT checks passed.bun run privacy:scan— exit 0.bun run --cwd docs-site build— initial exit 127 because the docs-site Astro dependency was absent. Afterbun install --cwd docs-site --frozen-lockfile(exit 0, no lockfile change), the same build passed: 561 pages and 78,111 internal links checked.git diff --cached --check— exit 0.Checklist
Summary by CodeRabbit