Skip to content

feat(subagent): add resume_from continuation chains to agent spawn - #5142

Merged
Hmbown merged 2 commits into
agent/v094-release-train-20260802from
copilot/add-resume-from-continuation-chains
Aug 3, 2026
Merged

feat(subagent): add resume_from continuation chains to agent spawn#5142
Hmbown merged 2 commits into
agent/v094-release-train-20260802from
copilot/add-resume-from-continuation-chains

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The agent tool had no way to continue a prior agent's transcript lineage — each spawn always started fresh, losing prefix-cache affinity and requiring the parent to manually relay context across role transitions (explore → implement → verify).

Changes

New resume_from parameter on action=start

Accepts a settled agent_id or session name. The source agent's full transcript is loaded and injected as the new child's fork context, enabling transcript-lineage continuation across role/profile transitions.

{
  "action": "start",
  "type": "implementer",
  "prompt": "Now implement what the scout found",
  "resume_from": "agent_abc123"
}

Validation gates

  • Running source → rejected with actionable error (suggests action=wait or action=interrupt)
  • Missing source → rejected with not found error
  • Cross-workspace source → rejected (transcript artifacts are workspace-relative)
  • fork_context=false + resume_from → rejected at spawn time as contradictory

Transcript loading with fallback

Loads the full on-disk transcript artifact for prefix-cache reuse. Falls back to checkpoint messages for legacy records, archived agents, and process-restart resume scenarios.

Receipt traceability

  • ChildLaunchManifest.resume_from_agent_id — persisted in the durable launch record
  • WorkflowTaskSpawnMetadata.resume_from_agent_id — stamped on the spawn receipt
  • New resume_from property added to the agent tool JSON schema

Tests (16 new)

Covers parse variants (resume_from/resumeFrom/absent/whitespace), all settled status variants (completed, interrupted, failed, cancelled), cross-workspace rejection, running-source rejection, transcript artifact load, checkpoint fallback, and session name resolution.

Copilot AI linked an issue Aug 3, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add task_id parameter to resume prior subagent feat(subagent): add resume_from continuation chains to agent spawn Aug 3, 2026
Copilot AI requested a review from Hmbown August 3, 2026 02:24
@Hmbown
Hmbown changed the base branch from main to agent/v094-release-train-20260802 August 3, 2026 11:58
Copilot AI added 2 commits August 3, 2026 05:03
Add `resume_from` parameter to the `agent` tool's `action=start` path,
implementing the continuation-chain contract from issue #425.

Semantics:
- `resume_from` accepts a settled child agent_id or session name.
- The source agent must not be running (completed, interrupted, failed,
  cancelled, or budget_exhausted are all accepted).
- The source must live in the same workspace as the spawning agent;
  cross-workspace sources are rejected with a clear error.
- The full transcript is loaded from the on-disk artifact. When the
  artifact is unavailable (legacy record, archived child, process-restart
  resume) the checkpoint messages are used as a fallback.
- The loaded transcript is injected into the child's `fork_context`,
  forcing `fork_context=true` so the new agent starts with the prior
  lineage and the provider can reuse prefix-cache entries.
- Explicitly setting `fork_context=false` together with `resume_from`
  is rejected at spawn time as contradictory.

Receipt traceability:
- `SubAgentSpawnOptions.resume_from_agent_id` carries the source id
  into `ChildLaunchManifest.resume_from_agent_id` (persisted).
- `WorkflowTaskSpawnMetadata.resume_from_agent_id` stamps the receipt
  returned to workflow/tool callers.

Schema change:
- New `resume_from` property added to the `agent` tool JSON schema.

Tests (16 new, all green):
- parse accepts resume_from / resumeFrom camelCase / absent / whitespace-only
- parse accepts resume_from + fork_context=false (conflict detected at spawn)
- manager rejects running source with actionable error message
- manager rejects missing source
- manager accepts completed / interrupted / failed / cancelled sources
- manager rejects cross-workspace source
- transcript artifact loaded when available
- checkpoint fallback when artifact is missing
- session name resolves to agent_id via resolve_agent_ref
- SubAgentSpawnOptions carries resume_from_agent_id
@Hmbown
Hmbown force-pushed the copilot/add-resume-from-continuation-chains branch from 69f4b8f to 49e17e0 Compare August 3, 2026 12:18
@Hmbown
Hmbown marked this pull request as ready for review August 3, 2026 12:44
Copilot AI review requested due to automatic review settings August 3, 2026 12:44
@Hmbown
Hmbown merged commit 01d8974 into agent/v094-release-train-20260802 Aug 3, 2026
4 checks passed
@Hmbown
Hmbown deleted the copilot/add-resume-from-continuation-chains branch August 3, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds “continuation chain” support to the agent/subagent spawn path by introducing a resume_from parameter that rehydrates a settled agent’s transcript and injects it into the child’s initial fork context, allowing role/profile transitions without losing transcript lineage.

Changes:

  • Added resume_from parsing + JSON schema support, plus validation (running/missing/cross-workspace, and fork_context=false conflict).
  • Threaded resume_from_agent_id through spawn metadata and persisted ChildLaunchManifest for receipt/lineage traceability.
  • Added extensive tests around parsing, validation, and transcript artifact loading/fallback.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/tui/src/tools/subagent/mod.rs Implements resume_from parsing, schema, validation, transcript loading, and threads provenance into spawn options/metadata/manifest.
crates/tui/src/worker_profile.rs Extends ChildLaunchManifest with resume_from_agent_id for durable lineage provenance.
crates/tui/src/fleet/worker_runtime.rs Updates Fleet worker launch manifest construction to include the new field.
crates/tui/src/tools/subagent/tests.rs Adds tests for resume_from parsing/validation and transcript artifact behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7720 to +7721
let messages = load_subagent_transcript_artifact(&source_workspace, &source_agent_id)
.unwrap_or(checkpoint_messages);
Comment on lines +7686 to +7692
return Err(ToolError::invalid_input(format!(
"resume_from: agent '{source_id}' (session '{}') is still running. \
Only settled agents (completed, interrupted, failed, cancelled) \
may be used as a resume source. Use action=wait to block until \
it settles, or action=interrupt to stop it.",
source.session_name
)));
Comment on lines +15576 to +15580
// The `resume_from_agent_id` on `SubAgentSpawnOptions` must be threaded
// into the persisted `ChildLaunchManifest` so receipts can trace lineage.
let options = SubAgentSpawnOptions {
resume_from_agent_id: Some("agent_source_abc".to_string()),
..SubAgentSpawnOptions::default()
Hmbown pushed a commit that referenced this pull request Aug 4, 2026
…5142)

* Initial plan

* feat(subagent): add resume_from continuation chains (#425)

Add `resume_from` parameter to the `agent` tool's `action=start` path,
implementing the continuation-chain contract from issue #425.

Semantics:
- `resume_from` accepts a settled child agent_id or session name.
- The source agent must not be running (completed, interrupted, failed,
  cancelled, or budget_exhausted are all accepted).
- The source must live in the same workspace as the spawning agent;
  cross-workspace sources are rejected with a clear error.
- The full transcript is loaded from the on-disk artifact. When the
  artifact is unavailable (legacy record, archived child, process-restart
  resume) the checkpoint messages are used as a fallback.
- The loaded transcript is injected into the child's `fork_context`,
  forcing `fork_context=true` so the new agent starts with the prior
  lineage and the provider can reuse prefix-cache entries.
- Explicitly setting `fork_context=false` together with `resume_from`
  is rejected at spawn time as contradictory.

Receipt traceability:
- `SubAgentSpawnOptions.resume_from_agent_id` carries the source id
  into `ChildLaunchManifest.resume_from_agent_id` (persisted).
- `WorkflowTaskSpawnMetadata.resume_from_agent_id` stamps the receipt
  returned to workflow/tool callers.

Schema change:
- New `resume_from` property added to the `agent` tool JSON schema.

Tests (16 new, all green):
- parse accepts resume_from / resumeFrom camelCase / absent / whitespace-only
- parse accepts resume_from + fork_context=false (conflict detected at spawn)
- manager rejects running source with actionable error message
- manager rejects missing source
- manager accepts completed / interrupted / failed / cancelled sources
- manager rejects cross-workspace source
- transcript artifact loaded when available
- checkpoint fallback when artifact is missing
- session name resolves to agent_id via resolve_agent_ref
- SubAgentSpawnOptions carries resume_from_agent_id

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Hmbown pushed a commit that referenced this pull request Aug 4, 2026
…5142)

* Initial plan

* feat(subagent): add resume_from continuation chains (#425)

Add `resume_from` parameter to the `agent` tool's `action=start` path,
implementing the continuation-chain contract from issue #425.

Semantics:
- `resume_from` accepts a settled child agent_id or session name.
- The source agent must not be running (completed, interrupted, failed,
  cancelled, or budget_exhausted are all accepted).
- The source must live in the same workspace as the spawning agent;
  cross-workspace sources are rejected with a clear error.
- The full transcript is loaded from the on-disk artifact. When the
  artifact is unavailable (legacy record, archived child, process-restart
  resume) the checkpoint messages are used as a fallback.
- The loaded transcript is injected into the child's `fork_context`,
  forcing `fork_context=true` so the new agent starts with the prior
  lineage and the provider can reuse prefix-cache entries.
- Explicitly setting `fork_context=false` together with `resume_from`
  is rejected at spawn time as contradictory.

Receipt traceability:
- `SubAgentSpawnOptions.resume_from_agent_id` carries the source id
  into `ChildLaunchManifest.resume_from_agent_id` (persisted).
- `WorkflowTaskSpawnMetadata.resume_from_agent_id` stamps the receipt
  returned to workflow/tool callers.

Schema change:
- New `resume_from` property added to the `agent` tool JSON schema.

Tests (16 new, all green):
- parse accepts resume_from / resumeFrom camelCase / absent / whitespace-only
- parse accepts resume_from + fork_context=false (conflict detected at spawn)
- manager rejects running source with actionable error message
- manager rejects missing source
- manager accepts completed / interrupted / failed / cancelled sources
- manager rejects cross-workspace source
- transcript artifact loaded when available
- checkpoint fallback when artifact is missing
- session name resolves to agent_id via resolve_agent_ref
- SubAgentSpawnOptions carries resume_from_agent_id

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

v0.9.3 Subagents: add resume_from continuation chains

3 participants