You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(runtime): migrate agent tools to child sessions - #1385
Preserve the existing foreground/synchronous parent tool boundary, cancellation propagation, bounded concurrency, input ordering, and swarm all-settled behavior.
Add a canonical SubagentExecutionRef and mixed agent_list / agent_output read model so child sessions are addressed by childSessionId, while legacy same-session child runs remain inspectable by runId.
Return both childSessionId and runId for newly spawned children, persist child-session task ownership plus swarm/item lineage, and wire the dedicated capability through Desktop, CLI/TUI, and headless hosts.
Continuation and compatibility
resume_run_ids now resolves a returned runId to either a legacy same-session child run or a linked child Session. A fresh swarm child is continued by creating a new session-inline AgentRun in that same child Session, with durable resumedFromRunId lineage.
Adaptive provider-rate-limit recovery is preserved for fresh child sessions. Each retry creates another AgentRun in the same child Session, records retriedFromRunId, reuses the durable child runtime snapshot, and keeps the resulting childSessionId + runId consumable by later resume_run_ids calls.
agent_list.runs remains the legacy projection; agent_list.executions is the canonical mixed child-session / legacy-run view and projects the latest child-session run as currentRunId.
Legacy tasks.json import and recovery now preserve TaskOwner.sessionId alongside the JSONL event-ledger copy.
New child creation keeps the current fresh context semantics. The proposed contextMode: "fork" is intentionally not exposed yet: it needs explicit model-input snapshot semantics, artifact/checkpoint handling, and distinct fork provenance rather than pretending that fresh child creation already provides those guarantees.
Follow-up review on a2eaa806. The overall migration direction looks good, and the current typecheck/test/e2e checks are green. I think there are two swarm behavior regressions that should block the fresh-swarm migration, plus one smaller persistence gap:
Fresh swarm results cannot be consumed by the advertised resume_run_ids path. Fresh items now run in linked child sessions and return childSessionId + runId, but every resume_run_ids entry still goes through prepareChildAgentResume(parentSessionId, runId). That lookup only accepts legacy child runs stored in the parent session and explicitly rejects session-inline runs. As a result, copying the runId returned by a new swarm item back into resume_run_ids fails with “resume source ... was not found”. Please either add a child-session execution-ref continuation path, or keep fresh agent_swarm items on the legacy path until that primitive exists. Merely documenting resume_run_ids as legacy-only would still be a regression in the public tool contract.
Adaptive rate-limit recovery is disabled for every fresh child-session item. The rate-limit branch now requires !effectiveResult.childSessionId, so a fresh item that receives a transient RateLimit is settled immediately as failed: it does not retry, does not trigger capacity shrink/backoff, and the swarm returns partial. The new test explicitly locks in this behavior. The durable model should create another AgentRun inside the same child session and update its current run; if that continuation/retry primitive is intentionally deferred, I would defer the fresh-swarm migration as well. The agent_spawn migration can still land independently.
The Task Ledger compatibility recovery path drops the new owner session reference.TaskOwner.sessionId is now written for durable child ownership, but normalizeOptionalOwner() in packages/storage/src/task-ledger-store.ts reconstructs only actor/agentId/runId/turnId. Normal event-ledger reads retain the field, but legacy import, tasks.json fallback, and untrusted-cache recovery lose it and can re-import the owner without its child-session identity. Please copy sessionId there and add a storage round-trip/fallback test.
The spawn identity wiring, cancellation composition, bounded concurrency, mixed list/output authorization, and backward-compatible result schemas otherwise look coherent.
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
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.
Summary
agent_spawncalls and newagent_swarmitems through the linked child-session primitive introduced in PR feat(runtime): add child-session runtime primitive #1376.SubagentExecutionRefand mixedagent_list/agent_outputread model so child sessions are addressed bychildSessionId, while legacy same-session child runs remain inspectable byrunId.childSessionIdandrunIdfor newly spawned children, persist child-session task ownership plus swarm/item lineage, and wire the dedicated capability through Desktop, CLI/TUI, and headless hosts.Continuation and compatibility
resume_run_idsnow resolves a returnedrunIdto either a legacy same-session child run or a linked child Session. A fresh swarm child is continued by creating a new session-inline AgentRun in that same child Session, with durableresumedFromRunIdlineage.retriedFromRunId, reuses the durable child runtime snapshot, and keeps the resultingchildSessionId + runIdconsumable by laterresume_run_idscalls.agent_list.runsremains the legacy projection;agent_list.executionsis the canonical mixed child-session / legacy-run view and projects the latest child-session run ascurrentRunId.tasks.jsonimport and recovery now preserveTaskOwner.sessionIdalongside the JSONL event-ledger copy.contextMode: "fork"is intentionally not exposed yet: it needs explicit model-input snapshot semantics, artifact/checkpoint handling, and distinct fork provenance rather than pretending that fresh child creation already provides those guarantees.Validation
npm run lintnpm run format:checknpm run buildnpm --workspace @maka/storage testRefs #1366
中文说明
概要
agent_spawn和agent_swarmfresh item 切换到 PR feat(runtime): add child-session runtime primitive #1376 引入的关联 child session runtime primitive。SubagentExecutionRef与混合agent_list/agent_output读模型:新的 child session 使用childSessionId定位,旧的同 session child run 继续使用runId查询。childSessionId + runId,持久化 task owner 的 child session 引用与 swarm/item lineage,并完成 Desktop、CLI/TUI、headless host 的能力接线。Continuation 与兼容性
resume_run_ids现在会把返回的runId解析为 legacy same-session child run 或 linked child Session。fresh swarm child 会在同一个 child Session 内创建新的 session-inline AgentRun,并持久化resumedFromRunIdlineage。retriedFromRunId,复用 durable child runtime snapshot,并让最终的childSessionId + runId仍可继续交给后续resume_run_ids。agent_list.runs保留为 legacy projection;agent_list.executions是 child session 与 legacy run 的规范混合视图,并把 child session 最新的 run 投影为currentRunId。tasks.json导入和恢复现在会保留TaskOwner.sessionId,与 JSONL event ledger 中的元数据副本一致。contextMode: "fork"暂不暴露,因为它需要明确的模型输入快照、artifact/checkpoint 处理和独立的 fork provenance。验证
npm run lintnpm run format:checknpm run build