feat(agent-core): sharpen the compaction handoff prompt - #1283
Conversation
Refine the first-person handoff note the model writes at compaction so it preserves what actually gets dropped instead of what already survives: - Lead with the intent of the latest request, not a verbatim re-transcription (the recent user messages are already kept verbatim beside the summary); name which request governs when several are in play. - Carry forward tool results — the concrete values, key lines, schemas — not just the commands that produced them. - Keep settled decisions separate from still-open questions, and name the context the next turn must go and re-check. - Write in the conversation's language, keep the note proportional to the task, and don't re-transcribe the auto-attached TODO list. Also correct the system prompt's description of the post-compaction shape: the recent user messages come first, followed by a first-person summary (not a rigidly sectioned report), and a newer kept message supersedes the summary. Update the affected inline snapshots and the compaction request token count.
🦋 Changeset detectedLatest commit: 8d36f25 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65fcacb53d
ℹ️ 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".
| any ambiguity you have already resolved — not a re-transcription, since the | ||
| request itself survives verbatim in the kept messages. If several requests are |
There was a problem hiding this comment.
Preserve oversized latest requests in the handoff
When the latest user request itself exceeds the 20k-token kept-message budget, selectRecentUserMessages keeps only a truncated prefix of that message, so telling the compaction model not to re-transcribe it because it “survives verbatim” can permanently drop the tail of the active request after compaction. This affects large prompts/files pasted by the user right before overflow; the summary is the only chance to carry forward the omitted details, so the instruction should still require preserving any parts of the current request that may not fit in the kept messages.
Useful? React with 👍 / 👎.
…note selectRecentUserMessages truncates a kept user message to the size cap, keeping only its prefix, so when the latest request itself exceeds the cap only its head survives verbatim beside the summary. Telling the summary "don't re-transcribe, it survives verbatim" then permanently dropped the tail — often the actual ask. Keep the intent-not-transcription guidance, but require preserving the at-risk parts of a long current request.
Summary
Improves the first-person handoff note the model writes when a conversation is compacted, so resumed sessions continue more reliably. Guiding principle: the summary should preserve what compaction drops (the assistant's reasoning and tool results), not re-transcribe what already survives beside it — the most recent user messages are kept verbatim next to the summary.
Changes
compaction-instruction.mdsystem.mdTests
agent-coresuite green (3402 passed).