-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(agent-core-v2): add full compaction to the human agent domain #3703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/agent-core-v2/src/human/compaction/compaction-instruction.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| You are about to run out of context. Create a handoff summary for the | ||
| model that will resume this task after the earlier conversation is cleared. | ||
|
|
||
| --- This message is a direct task, not part of the above conversation --- | ||
|
|
||
| Do not impose rigid section headings; let the shape follow the task. Write it | ||
| in the same language the conversation has been using — do not switch to English | ||
| just because these instructions happen to be in English. | ||
|
|
||
| Make the summary self-sufficient: the next turn will see only the preserved | ||
| messages and this summary — every other assistant message, tool call, and tool | ||
| result above will be gone. In your own words, preserve what you genuinely need | ||
| to continue: | ||
|
|
||
| - What the latest request is actually asking for: your reading of its intent and | ||
| any ambiguity you have already resolved — not a re-transcription, since what | ||
| fits is kept verbatim in the preserved messages. But those kept messages are | ||
| size-capped, so a long request is truncated there: if the latest request is | ||
| large (a big paste or file), preserve the parts at risk of being dropped — | ||
| above all the actual ask. If several requests are in play, say which one governs | ||
| the next move, and re-quote any still-relevant earlier request that may have | ||
| scrolled out of the kept messages. | ||
| - The instructions and constraints currently in force (user preferences, | ||
| project rules, environment and tooling limits) — condensed to what still | ||
| matters, keeping decisions you have already settled (what you chose and why) | ||
| separate from questions still open, so you neither silently reopen a closed | ||
| choice nor treat an undecided point as decided. | ||
| - What has actually been done, at high fidelity: keep the exact commands that | ||
| were run, the exact file paths touched, and whether each succeeded or failed — | ||
| and the results themselves, not just the commands: the concrete values | ||
| returned, the key lines or error text, the schema or signature a lookup | ||
| revealed, since re-running to recover them may be slow or impossible. Keep only | ||
| the final working version of any code; drop intermediate attempts and | ||
| already-resolved errors. | ||
| - What you still don't know: context the next step depends on that this | ||
| conversation never established — files or paths referenced but not yet read, | ||
| schemas or APIs assumed but unseen, questions the user has not answered. Name | ||
| these gaps so the next turn goes and checks them instead of assuming. | ||
| - The forward plan — and this is the moment to invest in it. Right now you | ||
| hold more context on this task than you ever will again; the next turn | ||
| resumes with less, so the plan you commit here is the one it will follow. | ||
| Give the exact next command or tool call, but don't stop at the next step: | ||
| set out the remaining sequence to finish, the decisions you have already | ||
| made for those upcoming steps (so the next turn doesn't reopen them), the | ||
| obstacles or edge cases you can already foresee and how you mean to handle | ||
| them, and any work you can commit to now — the exact patch, query, or shape | ||
| of the final answer you already know you will produce. Anything you settle | ||
| here is one less thing the next turn must rediscover. Include any required | ||
| format for the final answer. | ||
|
|
||
| This conversation's event log stays on disk and a recovery pointer is appended below this summary automatically, so you need not reproduce long outputs verbatim — keep exact identifiers, key values and error lines, and name anything the next turn should look up. | ||
|
|
||
| Your TODO list is re-attached automatically below this summary from its live | ||
| source, so do not transcribe it — copying it wastes space and can contradict the | ||
| live version. What that list cannot hold is the reasoning between tasks — why one | ||
| was reordered or dropped, or a decision on one that constrains another — so | ||
| record that instead. | ||
|
|
||
| Be honest about uncertainty. If an earlier step claimed something was done but | ||
| was never verified (tests "passing", a fix "working", a file "created"), say so | ||
| plainly and treat it as unverified rather than fact — re-check before relying | ||
| on it. | ||
|
|
||
| Be concise, and keep the summary proportional to the task: a long multi-step | ||
| task warrants detail, but a trivial or nearly finished exchange needs only a | ||
| sentence or two — do not pad it out. Include the critical data, identifiers, and | ||
| references needed to continue, and omit anything that does not change the next | ||
| move. | ||
|
|
||
| Respond with text only. Do not call any tools — you already have everything you | ||
| need in the conversation history. | ||
|
|
||
| ${custom_instruction_block} |
1 change: 1 addition & 0 deletions
1
packages/agent-core-v2/src/human/compaction/compaction-summary-prefix.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The conversation so far has been compacted to free up context. What follows is your own working summary of this task — use it to continue your train of thought rather than starting over. Treat it as notes, not proof: where it says a step was done, tests passed, or a fix worked, verify that yourself before relying on it. Any user messages earlier in this context are preserved verbatim from the compacted conversation; where a system-reminder note among them marks an omitted middle section, the user messages it replaced are covered by this summary. The summary records which earlier requests were already addressed. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the budget hook rejects, this transition completes the turn as
donewith no response while compaction is only scheduled asynchronously. If the automatic compaction then fails—for example because the summary request times out—the cancellation path merely unpauses the agent; the initiating prompt has already been drained into history, there is no pending work, and no new turn starts, so the user receives neither an answer nor a turn failure. Preserve/retry the blocked turn or propagate the hook failure unless compaction successfully schedules its continuation.Useful? React with 👍 / 👎.