Skip to content

Rewrite the compaction summary as a handoff with fold rules - #68

Merged
mcheemaa merged 4 commits into
mainfrom
compaction-prompt
Sep 6, 2026
Merged

mcheemaa merged 4 commits into
mainfrom
compaction-prompt

Conversation

@mcheemaa

@mcheemaa mcheemaa commented Sep 6, 2026

Copy link
Copy Markdown
Owner

The compaction summary was a checklist template: goal, constraints, done and in-progress boxes, decisions, next steps, and a "critical context" bucket. It kept facts by narrating every step, which made summaries long on routine work and thin on the things a resuming model actually needs, and it had no rule for what happens when a later checkpoint folds new messages into an earlier summary.

The summary is now a handoff in seven fixed sections: the goal and the requests that shaped the work, quoted in the user's words and marked done or open; constraints; exact facts and references, current values only; decisions with reasons; progress as one line per step with its result and figures; open failures; and the current work with the single next step. The summarizer is told it is the record, not a reviewer: it reports what the user, the assistant, and the tools said as theirs and does not re-check, discount, or qualify it. Later checkpoints start from the previous summary and keep its lines verbatim, changing only what the new messages change or finish, so a fold cannot quietly rewrite earlier work. The replay preface presents the result as a handoff written by another model from the full transcript. The reply is the summary; nothing is extracted from it.

Measured with the compaction eval against the committed baseline, matched compacted cells at size S, the CI tier, two repetitions per cell:

model probes changed continuation unsupported resumability rejected
claude-sonnet-5 91% -> 91% (+0 pts) 96% -> 85% 100% -> 85% 7.9 -> 4.3 3.8 -> 4.0 0% -> 0%
gpt-5.6-sol 93% -> 93% (+0 pts) 100% -> 100% 85% -> 100% 1.6 -> 2.9 4.6 -> 4.0 0% -> 0%
gemini-2.5-flash 84% -> 86% (+2 pts) 93% -> 89% 71% -> 100% 2.7 -> 2.9 3.2 -> 3.4 0% -> 0%

The eval comparison also had a bug: scenario digests are per size, but the comparison keyed them by scenario name, so a baseline holding S and M rows read a candidate that had only finished S as three changed scenarios and found nothing comparable. It now tracks digests per scenario and size.

Verified with the full suite on Ruby 3.2 and 3.3, RuboCop, and the eval runs above.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 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-09-06T21:16:10.055569Z d762783 PR opened
ℹ️ 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.

@codecov

codecov Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.37%. Comparing base (7a7b416) to head (55eddb0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #68   +/-   ##
=======================================
  Coverage   94.37%   94.37%           
=======================================
  Files          93       93           
  Lines        7697     7701    +4     
  Branches     1604     1604           
=======================================
+ Hits         7264     7268    +4     
  Misses        101      101           
  Partials      332      332           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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: d762783305

ℹ️ 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 lib/mistri/compactor.rb
Comment on lines +102 to +104
- Start from the previous summary and keep its lines verbatim, including every step
and its figures, except where the new messages change or finish something. Do not
rewrite, merge, or compress what you carry forward.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow carried summaries to be compressed to the word cap

When a previous summary is already near 1,000 words and a later fold adds a request or completed step without superseding anything, these rules require every existing line to remain verbatim while LENGTH_RULE still requires the result to stay under 1,000 words and forbids cutting requests, constraints, or exact values. No output can satisfy both requirements, so the summarizer must either discard required state or let the checkpoint grow across folds until it stops shrinking context or hits the provider output limit and is rejected. Permit older completed progress and narrative to be consolidated when needed to preserve the fixed bound.

Useful? React with 👍 / 👎.

Comment thread lib/mistri/compaction.rb
Comment on lines +25 to +28
SUMMARY_PREFACE = "The earlier part of this conversation was compacted. Another model " \
"wrote the handoff summary below from the full transcript; the " \
"messages after it are the most recent turns, kept intact. Build on the " \
"work already done, do not repeat it, and treat the user's most recent " \

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 Stop claiming the summary came from the full transcript

For every compaction, Compactor.call sends the summarizer only head, the messages before the retained cut; on subsequent compactions it sends the prior lossy summary plus part of the replay rather than the durable original transcript. The synthetic preface therefore gives the resumed model a false completeness guarantee by saying the handoff was written from the full transcript, even though unsummarized recent turns merely follow it and previously omitted details cannot be recovered. Describe the summary as covering the earlier compacted portion instead.

Useful? React with 👍 / 👎.

Comment thread lib/mistri/compactor.rb
Comment on lines +81 to +85
Write the handoff summary for another model that will resume this work with only your
summary and the last few turns. It must be able to continue without asking the user to
repeat anything. Write these sections in this order, with these exact headings:

#{FORMAT}
#{SECTIONS}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge State the latency impact of the larger compaction request

This substantially expands every compaction request with the seven-section specification and fold rules, increasing provider input processing and potentially summary-generation latency, but neither the CHANGELOG nor the compaction documentation states that latency impact. Add the required latency assessment so hosts can evaluate the cost of this hot-path request change.

AGENTS.md reference: AGENTS.md:L18-L19

Useful? React with 👍 / 👎.

Comment thread eval/compaction/report.rb
Comment on lines +198 to 200
digests.call(candidate).filter_map do |workload, digest|
workload if before.key?(workload) && before[workload] != digest
end

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 scenario-size pairing in changed-workload output

When a digest differs, this now returns a two-element [scenario, size] array, but coverage still interpolates the collection with changed.join(", "); Ruby recursively joins the nested arrays, so one changed workload renders as account_research, M and several render as an ambiguous flat sequence such as account_research, M, ledger_export, S. The comparison correctly excludes the cells, but its diagnostic no longer identifies which scenario/size pairs need a new baseline; format each pair explicitly (for example, scenario/size).

Useful? React with 👍 / 👎.

Comment thread lib/mistri/compactor.rb
your summary and the last few turns, using the same seven sections and headings as the
previous summary:

#{HEADINGS}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Carry the section invariants into later folds

On a second or later checkpoint, the summarizer receives only the seven heading names here, not the definitions in SECTIONS. The fold rules say how to retain or replace existing lines but never tell it to add newly introduced constraints, decisions, unresolved failures, or exact identifiers from the new transcript, nor do they preserve the requirements for attribution and exact error text. Consequently, a user constraint or tool-produced ID first appearing after the initial checkpoint can be omitted even when the model follows the update instructions; include the full section definitions, or equivalent addition rules, in UPDATE_PROMPT.

Useful? React with 👍 / 👎.

Repository owner deleted a comment from github-actions Bot Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Compaction eval comparison

baseline 6ed9d01 (prompt 558eb0bcb2d4) vs candidate 55eddb0 (prompt 80fd19384428)

Baseline cells the candidate did not run (not compared): claude-sonnet-5/account_research/S/full, claude-sonnet-5/account_research/S/tail, claude-sonnet-5/incident_debugging/S/full, claude-sonnet-5/incident_debugging/S/tail, claude-sonnet-5/ledger_export/S/full, claude-sonnet-5/ledger_export/S/tail, claude-sonnet-5/account_research/M/compacted, claude-sonnet-5/incident_debugging/M/compacted, claude-sonnet-5/ledger_export/M/compacted, gpt-5.6-sol/account_research/S/full, gpt-5.6-sol/account_research/S/tail, gpt-5.6-sol/incident_debugging/S/full, gpt-5.6-sol/incident_debugging/S/tail, gpt-5.6-sol/ledger_export/S/full, gpt-5.6-sol/ledger_export/S/tail, gpt-5.6-sol/account_research/M/compacted, gpt-5.6-sol/incident_debugging/M/compacted, gpt-5.6-sol/ledger_export/M/compacted, gemini-2.5-flash/account_research/S/full, gemini-2.5-flash/account_research/S/tail, gemini-2.5-flash/incident_debugging/S/full, gemini-2.5-flash/incident_debugging/S/tail, gemini-2.5-flash/ledger_export/S/full, gemini-2.5-flash/ledger_export/S/tail, gemini-2.5-flash/account_research/M/compacted, gemini-2.5-flash/incident_debugging/M/compacted, gemini-2.5-flash/ledger_export/M/compacted.

Per model, matched compacted cells

model probes changed continuation unsupported resumability rejected
claude-sonnet-5 91% -> 92% (+1 pts) 96% -> 85% 100% -> 71% 7.9 -> 6.5 3.8 -> 4.0 0% -> 0%
gpt-5.6-sol 93% -> 92% (-1 pts) 100% -> 92% 85% -> 100% 1.6 -> 3.7 4.6 -> 4.0 0% -> 0%
gemini-2.5-flash 84% -> 87% (+3 pts) 93% -> 100% 71% -> 100% 2.7 -> 3.4 3.2 -> 3.4 0% -> 0%

Per cell

model scenario size mode reps probes changed continuation summary tok
claude-sonnet-5 account_research S compacted 2 -> 1 +0 pts +0 pts +0 pts 1066 -> 1362
claude-sonnet-5 incident_debugging S compacted 2 -> 1 +3 pts -50 pts -100 pts 1651 -> 1788
claude-sonnet-5 ledger_export S compacted 2 -> 1 +0 pts +10 pts +0 pts 1848 -> 1865
gpt-5.6-sol account_research S compacted 2 -> 1 +0 pts +0 pts +0 pts 925 -> 1133
gpt-5.6-sol incident_debugging S compacted 2 -> 1 +3 pts +0 pts +50 pts 994 -> 1534
gpt-5.6-sol ledger_export S compacted 2 -> 1 -4 pts -20 pts +0 pts 1186 -> 1283
gemini-2.5-flash account_research S compacted 2 -> 1 +3 pts +0 pts +50 pts 615 -> 967
gemini-2.5-flash incident_debugging S compacted 2 -> 1 +11 pts +25 pts +50 pts 760 -> 1510
gemini-2.5-flash ledger_export S compacted 2 -> 1 -2 pts +0 pts +0 pts 1257 -> 1413

Passed: no model loses more than 3 points of aggregate probe accuracy or rejects more compactions, over matched cells.

@mcheemaa
mcheemaa merged commit d41f1fd into main Sep 6, 2026
14 checks passed

This branch was successfully deployed

1 active deployment
eval — 55eddb04 Deployed Sep 6, 2026 by mcheemaa via eval (claude-sonnet-5) #6
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