fix: Strip system references footer from conversation history (closes #146) - #147
Conversation
…146) Prior bot replies re-entered the model's context verbatim, footer included — after a few turns the model imitated the house format and emitted its own references block + react-line mid-answer, producing the doubled footer seen in production threads. buildConversationHistory now strips everything from the footer marker onward on assistant turns (user turns untouched; footer-only bot messages vanish rather than becoming empty turns). The marker is exported from references.ts and used by both format and strip, with a round-trip test so the pair can never drift. The compaction transcript is cleaned transitively since it builds from the same history. Verified: keyless behavior-eval replay 5/5 — no cassette drift. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds an exported ChangesFooter Marker and Stripping
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
PR Summary by QodoFix footer echo by stripping references block from assistant history
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/thread-filter.ts`:
- Around line 88-96: `extractTranscriptTail` is still passing assistant replies
with the references footer into the classifier transcript, so update the
transcript-building logic to strip that footer for assistant turns the same way
`m.text` is handled in the main message path. Reuse `stripReferencesFooter`
inside `extractTranscriptTail` for assistant messages, alongside the existing
`@mention` cleanup, so the classifier only sees cleaned assistant text before
truncation and filtering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ff4b1ce0-cc8e-41cc-b361-a8eab3753541
📒 Files selected for processing (4)
src/lib/references.test.tssrc/lib/references.tssrc/lib/thread-filter.test.tssrc/lib/thread-filter.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…review) Same #146 rule applied to extractTranscriptTail — bot entries reach the shouldReply/effort classifier footer-free, so reference bullets can't consume the 500-char per-entry budget or skew the gate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Fixes the doubled references-block + 👍/👎 hint observed in production multi-turn threads (#146). The system appends its footer exactly once — but
buildConversationHistorywas feeding prior bot replies back to the model with their footers, so after a few turns the model learned the footer as part of the house answer format and emitted its own copy mid-answer, ahead of the genuine one.REFERENCES_FOOTER_MARKERexported fromreferences.tsand used by bothformatReferencesand the newstripReferencesFooter— a round-trip test (strip(answer + format(refs)) === answer) makes the pair drift-proofbuildConversationHistorystrips from the marker onward on assistant turns only; user messages quoting footer-lookalike text pass through untouched; a footer-only bot message vanishes instead of becoming an empty turnTesting
TDD: 8 new tests RED-first (round-trip drift guard, marker-in-output pairing, assistant-strip, user-passthrough, footer-only-skip). Full suite 960 passing, typecheck clean, and keyless behavior-eval replay verified 5/5 — no cassette drift.
Closes #146
🤖 Generated with Claude Code
Summary by CodeRabbit