-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(core): restore background agent roster #7459
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
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4f5bd98
feat(core): restore background agent roster
DragonnZhang 7b9efe5
fix(web-shell): add list_agents to TOOL_DISPLAY_NAMES
claude b4393dc
fix(cli): reload old-session background agents on failed resume rollback
claude ba4bf55
fix(web-shell): add zh translation for list_agents tool name
claude 7752b4f
fix(cli): resolve CI failures for background-agent roster restore
claude 473f2e2
refactor(core): extract incompatible-isolation blocked reason to a const
claude ddeb0e2
fix(core): preserve retained activity state on failed agent revive
claude 64aed9a
merge: resolve conflicts with main for background-agent roster restore
claude 0821d92
test(cli): cover interrupted-turn continuation not consuming recovere…
claude 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Background Agent Roster Restore | ||
|
|
||
| ## Context | ||
|
|
||
| Background-agent sidecars and JSONL transcripts persist logical identity and | ||
| history, while `BackgroundTaskRegistry` indexes the current session's | ||
| addressable tasks. The resume loader currently restores only sidecars left in | ||
| `running` state. Completed agents therefore disappear from the registry after | ||
| their parent session is restored, even though their transcripts remain | ||
| available. The model also has no tool for querying the registry. | ||
|
|
||
| ## Goals | ||
|
|
||
| - Restore recent completed background agents with their original task IDs. | ||
| - Add a model-callable `list_agents` tool for on-demand discovery. | ||
| - Keep `send_message(task_id)` as the continuation operation. | ||
| - Give the model one short, one-shot reminder after restoration. | ||
| - Apply the same restoration behavior to TUI, headless, and ACP entry points. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Persisting a live JavaScript runtime across process teardown. | ||
| - Replacing the Agent Teams `task_list` tool. | ||
| - Restoring failed or cancelled agents. | ||
| - Reconstructing temporary worktree isolation. | ||
|
|
||
| ## Design | ||
|
|
||
| The session-directory scan accepts both `running` and `completed` sidecars. | ||
| Running entries become paused, preserving the existing interrupted-work | ||
| behavior. Completed entries remain completed, are marked already notified, and | ||
| retain the transcript and metadata paths needed by `send_message` revival. | ||
|
|
||
| New sidecars persist whether the original launch was backgrounded. Completed | ||
| entries are restored only when this marker is explicitly true, so foreground | ||
| and legacy unmarked completed sidecars are not exposed as reusable background | ||
| agents. Legacy running sidecars retain the existing recovery behavior. | ||
|
|
||
| The loader verifies the sidecar filename and parent-session owner before | ||
| registration. A retained row with a missing transcript, mismatched transcript | ||
| identity, incompatible isolation, or conflicting working directory remains | ||
| visible but is marked non-continuable. Worktree-isolated rows are treated the | ||
| same way because their temporary ownership context cannot be reconstructed | ||
| safely. Only the newest retained completed entries are restored; running | ||
| entries are not subject to that limit. | ||
|
|
||
| `list_agents` reads the live registry and returns background agents with a | ||
| stable `task_id`, description, type, status, continuation capability, and any | ||
| blocking reason. It does not scan disk. The tool is caller-owned and excluded | ||
| from subagents and teammates. | ||
|
|
||
| After restoration, the next ordinary top-level user prompt receives a single | ||
| system reminder to call `list_agents` and then `send_message`. Slash commands | ||
| and interrupted-turn continuations do not consume this reminder. Bare mode | ||
| does not receive it. | ||
|
|
||
| Session switches clear the in-memory registry before loading a new roster. | ||
| Failed resume rollback clears partially restored entries before restoring the | ||
| old session, and branching is blocked while background work is still active. | ||
|
|
||
| ## Validation | ||
|
|
||
| - Running and completed sidecars restore with stable IDs and correct states. | ||
| - Foreground and wrong-owner sidecars are excluded. | ||
| - Unsafe retained state is visible but cannot be continued. | ||
| - Restored completed entries do not emit duplicate completion notifications. | ||
| - `send_message` can revive a compatible restored completed entry. | ||
| - TUI, headless, and ACP restore the roster and deliver the reminder once. | ||
| - New, clear, branch, and failed resume paths do not leak a prior roster. |
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.