Skip to content

Rework: regenerate compaction instructions constantly in the background, surface instructions when prep-compact is called#2

Merged
koenvdheide merged 13 commits into
mainfrom
feat/v3.0-warm-handoff
Apr 26, 2026
Merged

Rework: regenerate compaction instructions constantly in the background, surface instructions when prep-compact is called#2
koenvdheide merged 13 commits into
mainfrom
feat/v3.0-warm-handoff

Conversation

@koenvdheide

@koenvdheide koenvdheide commented Apr 26, 2026

Copy link
Copy Markdown
Owner

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.

koenvdheide and others added 12 commits April 26, 2026 18:53
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread hooks/update-handoff.sh
'in_progress_status': in_progress_status,
'in_progress': in_progress,
'recent_task_launches': task_launches,
'recent_user_requests': user_requests,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread hooks/update-handoff.sh Outdated
Comment on lines +264 to +265
if total_chars + len(combined) > USER_REQUESTS_MAX_CHARS:
break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
@koenvdheide koenvdheide changed the title v3.0.0: warm handoff + informational reminder + skill repurpose Rework: regenerate compaction instructions constantly in the background, surface instructions when prep-compact is called Apr 26, 2026
@koenvdheide koenvdheide merged commit f33e44f into main Apr 26, 2026
2 checks passed
@koenvdheide koenvdheide deleted the feat/v3.0-warm-handoff branch April 26, 2026 20:23
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