Skip to content

feat(runtime): open linked subagents while spawn is still running - #2408

Closed
Astro-Han wants to merge 12 commits into
mainfrom
feat/midflight-subagent-open
Closed

feat(runtime): open linked subagents while spawn is still running#2408
Astro-Han wants to merge 12 commits into
mainfrom
feat/midflight-subagent-open

Conversation

@Astro-Han

@Astro-HanAstro-Han commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

After a linked subagent or swarm batch is ready, the parent stream used to only show stdout progress until the durable tool result settled. Expand could show logs, but Open waited on that settle.

This PR adds live-only tool_result_preview SessionEvents so existing previews can show Open mid-flight:

  • Linked spawnkind: subagent preview when the child becomes ready (ToolRuntime wraps onReady).
  • Agent Swarmkind: agent_swarm snapshots from batch start (all items listed) through item start/ready/terminal, built by a single buildAgentSwarmContent path shared with durable settlement. Per-item Open appears as soon as childSessionId exists.
  • Terminal persisted result remains the later tool_result; previews never appendMessage.

Swarm-tagged spawns still do not emit kind: subagent previews (those would overwrite the batch snapshot). Open still navigates into the live child session chat (titlebar project › parent › child).

Out of scope: host-join dual authority, durable reconnect of previews, linked edit/revise, async Graph (#2384) status panel.

Refs the mid-flight gap after #2383.

Verification

  • npm run build --workspace @maka/core --workspace @maka/ui --workspace @maka/runtime
  • node --test --test-concurrency=1 packages/core/dist/__tests__/agent-swarm-result.test.js
  • node --test --test-concurrency=1 packages/runtime/dist/__tests__/tool-runtime-settlement.test.js
  • node --test --test-concurrency=1 packages/runtime/dist/__tests__/agent-swarm-tools.test.js
  • node --test --test-concurrency=1 packages/ui/dist/__tests__/live-turn-projection.test.js
  • node --test --test-concurrency=1 packages/ui/dist/__tests__/subagent-open-session.test.js

Review focus

  • tool_result_preview stays live-only (event stream, not appendMessage)
  • Swarm live/durable content share buildAgentSwarmContent (snapshot copy of items)
  • Swarm spawn wrapper must not publish kind: subagent previews
  • Item/batch queued/running are mid-flight; settle still terminal-only in practice

@Astro-Han
Astro-Hanforce-pushed the feat/midflight-subagent-open branch from 6e09e8f to a10d42fCompareAugust 7, 2026 07:42
Publish a live-only tool_result_preview when a linked child becomes ready so
SubagentPreview can show Open before the durable tool_result commits. Keep
preview projection in-flight, map the event as a partial tool heartbeat, and
leave swarm/batch paths untouched.
Rebase onto main for headless format drift. Assert linked-child ready
includes permissionMode and that ToolRuntime always wraps spawn with
onReady for live tool_result_preview.
#2406 deleted the contract tests that imported these helpers; knip on the
desktop workspace then failed the typecheck lane for every PR on main.
@Astro-Han
Astro-Hanforce-pushed the feat/midflight-subagent-open branch from 85d4d2a to bacacb4CompareAugust 7, 2026 07:45
Linked single-spawn Open is in scope; agent_swarm batch ready must not
publish a subagent preview that rewrites the parent swarm tool card.
Publish kind:agent_swarm tool_result_preview from batch start through
item ready so AgentSwarmPreview can show every row and Open as soon as
childSessionId exists. One buildAgentSwarmContent path owns live and
settled shapes; spawn still skips subagent previews for swarm tags.
Project live/settled agent_swarm results into a collapsed ChatToolCalls
group — one CallRow per item with status — instead of AgentSwarmPreview.
Activating a ready child row opens that child session.
Astryx multi-call groups show the latest child name when folded. Render
agent_swarm as a single outer CallRow named Agent Swarm, with per-item
rows nested in its expand detail instead.
Use a product header named Agent Swarm that expands into flat Astryx
CallRows per item. Drop the nested outer-CallRow-plus-inner-group that
forced two expand hops.
Drop the product header shell and CSS. Live/settled swarm items map to one
ChatToolCalls group; fold chrome stays Astryx's.
CallRow name is the tool kind; put agentName/profile in target so rows
read like agent_spawn ("Agent · Local Read") instead of a fake tool
named after the preset.
Mid-flight Open needs structured live facts (childSessionId / swarm items)
to reach Desktop. Wire tool_result_preview as a first-class continuity
transient with retained latest-per-toolUseId seed on rejoin, keep durable
agent_swarm decode terminal-only, project swarm through one Astryx multi-call
path, and stabilize ordinary ToolTrow keys so live membership growth does not
collapse expanded rows.
Live mid-flight Open only needs identity and status, not full ToolResultContent
bulk. Introduce ToolResultPreviewContent (subagent/agent_swarm open-facts),
publish it through buildAgentSwarmPreviewContent and a single preview event
shape, enforce durable terminal-only decode, fix protocol subpath import, and
materialize open-facts into activity rows with empty summary/artifacts.
@Astro-Han

Copy link
Copy Markdown
ContributorAuthor

Closing to rewrite on current main.

#2384 removed the sync agent_swarm multi-call path this branch was built on (live open-facts / flat CallRows). Post-#2384 main uses async graph swarm + agent_swarm_status; a mechanical rebase is not the right shape.

Will reopen from latest main with a design that matches the current spawn_subagent / ToolTrow + SubagentPreview presentation and the async swarm model.

Sign up for freeto 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.

1 participant

@Astro-Han