Rework: regenerate compaction instructions constantly in the background, surface instructions when prep-compact is called#2
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PRIVACY.md: clarify hook does bounded read of Glob/Grep tool_result blocks to extract path tokens (never persists content); does not read other tools' output. README.md: update How It Works paragraph to reflect v3 reminder copy and warm-handoff skill flow (no longer 4-bucket survey). check-context-size.sh: header comment updated for v3 informational reminder with handoff-aware variant.
Reviewer-agent caught README.md:66 still describing the v2.x 'reminder tells Claude to invoke the skill' behavior that v3 explicitly removed. Replace with v3-accurate description: reminder is informational, no auto-invoke, manual /prep-compact invocation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3edfa7e23
ℹ️ 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".
| 'in_progress_status': in_progress_status, | ||
| 'in_progress': in_progress, | ||
| 'recent_task_launches': task_launches, | ||
| 'recent_user_requests': user_requests, |
There was a problem hiding this comment.
Preserve prior user quotes when no new user text is present
prior_user_requests is read from the previous handoff but never merged back into recent_user_requests, so each Stop event rewrites the field from only the current tail scan. If a turn has no user text in the last 1 MB (for example after a long assistant/tool-output streak), this writes an empty list and drops the previously captured user intent even though the user has not provided a newer request.
Useful? React with 👍 / 👎.
| if total_chars + len(combined) > USER_REQUESTS_MAX_CHARS: | ||
| break |
There was a problem hiding this comment.
Skip oversized user messages instead of aborting quote collection
The quote loop stops immediately when the newest user message would exceed USER_REQUESTS_MAX_CHARS. Because iteration is newest-to-oldest, one large prompt (>20k chars) causes recent_user_requests to become empty, even when slightly older short requests would fit and should still anchor compaction intent.
Useful? React with 👍 / 👎.
L375: prior_user_requests was loaded but never merged into output. A turn with no user text in the 1MB tail (long assistant/tool-output streak) would write empty list and drop captured intent. Now: merge user_requests + prior_user_requests with dedup; cap at 5 msgs / 20000 chars. L265: oversized newest message broke the loop, emptying the field even when older shorter messages would fit. Now: skip oversized (continue), keep walking for messages that fit. Same for would-overflow accumulator. Privacy gate (PREP_COMPACT_NO_USER_QUOTES) still applies — both lists are emptied before merge. Adds T-32cap +1 (asserts 'short first' captured after oversized newest) and T-32prior +2 (prior preserved on no-user-text turn). 88->91 assertions.
Instead of waiting until /prep-compact gets called to generate the compaction instructions we now create a handoff file in the plugin directory that gets updated with every Claude Code response so that it remains up to date. This file is then read by the main session when /prep-compact is called to generate the actual compaction instructions. (Partly inspired by how Codex/Pi handle autocompaction)
This makes the existing /prep-compact call quicker and has the added benefit that the reminder can be made less pushy, users call /prep-compact when they like and CC can instantly make a good compaction summary from the handoff file. It HOPEFULLY also makes compaction perform better, especially during multiple rounds of compaction in a long session as the handoff file can remember context across compactions.