The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(app): keep detached async sub-agents running past their parent turn
M3gA-Mind0f2f8292b006
diff --git a/app/src/store/__tests__/chatRuntimeSlice.test.ts b/app/src/store/__tests__/chatRuntimeSlice.test.tsindex 313b385169..bfa8d3e064 100644--- a/app/src/store/__tests__/chatRuntimeSlice.test.ts+++ b/app/src/store/__tests__/chatRuntimeSlice.test.ts@@ -219,6 +219,87 @@ describe('chatRuntimeSlice', () => {expect(next.toolTimelineByThread['thread-i']).toEqual([]);});+ /**+ * A detached `spawn_async_subagent` child outlives the turn that spawned it.+ * Settling it on the parent's `completed` snapshot made the Background tasks+ * panel report "none running" — and the row read "Cancelled" — while the+ * sub-agent was still making tool calls. Its own `subagent_completed` event+ * is what settles it.+ */+ it('keeps a detached async subagent running when its parent turn completes', () => {+ const asyncRow = {+ id: 'subagent:sub-async',+ name: 'subagent:researcher',+ round: 1,+ status: 'running' as const,+ subagent: {+ taskId: 'sub-async',+ agentId: 'researcher',+ status: 'running' as const,+ mode: 'async',+ toolCalls: [],+ },+ };+ const snapshot: PersistedTurnState = {+ threadId: 'thread-async',+ requestId: 'req-async',+ lifecycle: 'completed',+ iteration: 1,+ maxIterations: 25,+ streamingText: '',+ thinking: '',+ toolTimeline: [asyncRow],+ startedAt: '2026-09-22T00:00:00Z',+ updatedAt: '2026-09-22T00:00:09Z',+ };++ const next = reducer(undefined, hydrateRuntimeFromSnapshot({ snapshot }));+ const row = next.toolTimelineByThread['thread-async'][0];++ expect(row.status).toBe('running');+ expect(row.subagent?.status).toBe('running');+ });++ /**+ * The counterpart: an `interrupted` snapshot means the core process driving+ * the child is gone, so even a detached child has no driver left and must+ * settle rather than pulse forever.+ */+ it('settles a detached async subagent when the turn was interrupted', () => {+ const snapshot: PersistedTurnState = {+ threadId: 'thread-async-int',+ requestId: 'req-async-int',+ lifecycle: 'interrupted',+ iteration: 1,+ maxIterations: 25,+ streamingText: '',+ thinking: '',+ toolTimeline: [+ {+ id: 'subagent:sub-async-int',+ name: 'subagent:researcher',+ round: 1,+ status: 'running' as const,+ subagent: {+ taskId: 'sub-async-int',+ agentId: 'researcher',+ status: 'running' as const,+ mode: 'async',+ toolCalls: [],+ },+ },+ ],+ startedAt: '2026-09-22T00:00:00Z',+ updatedAt: '2026-09-22T00:00:09Z',+ };++ const next = reducer(undefined, hydrateRuntimeFromSnapshot({ snapshot }));+ const row = next.toolTimelineByThread['thread-async-int'][0];++ expect(row.status).toBe('cancelled');+ expect(row.subagent?.status).toBe('cancelled');+ });+it('rehydrates historical subagent rows without live streamed prose', () => {const snapshot: PersistedTurnState = {threadId: 'thread-subagent',diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.tsindex a5c1c27068..70a95575d9 100644--- a/app/src/store/chatRuntimeSlice.ts+++ b/app/src/store/chatRuntimeSlice.ts@@ -1031,9 +1031,23 @@ function toolTimelineFromPersisted(* still `running`; leaving `awaiting_user` (and any other non-running child)* intact preserves the truthful "was waiting for the user" history — and the* pulse is already stopped by the row-level `cancelled` above.+ *+ * `turnStillOwnsDetachedChildren` is the one case where a `running` row is not+ * orphaned: a detached sub-agent (`spawn_async_subagent`, `mode === 'async'`)+ * is a fire-and-forget task that deliberately outlives the turn that spawned+ * it, and the core is still driving it. Settling those on the parent's+ * `completed` snapshot is what made the Background tasks panel report+ * "none running" — and the row read "Cancelled" — while the sub-agent was+ * visibly still making tool calls. Its `subagent_completed` event settles it+ * for real. An `interrupted` snapshot passes `false`: there the core process+ * itself is gone, so even a detached child has no driver left.*/-function settleOrphanedTimelineEntry(entry: ToolTimelineEntry): ToolTimelineEntry {+function settleOrphanedTimelineEntry(+ entry: ToolTimelineEntry,+ turnStillOwnsDetachedChildren = false+): ToolTimelineEntry {if (entry.status !== 'running') return entry;+ if (turnStillOwnsDetachedChildren && entry.subagent?.mode === 'async') return entry;return {...entry,status: 'cancelled',@@ -2258,7 +2272,7 @@ const chatRuntimeSlice = createSlice({state.toolTimelineByThread[threadId],snapshot.toolTimeline.map((e, seq) => toolTimelineFromPersisted(e, seq))- .map(settleOrphanedTimelineEntry)+ .map(e => settleOrphanedTimelineEntry(e, snapshot.lifecycle === 'completed')));// Persisted order is issue order — seed the live counter with the// row count so events arriving after this hydration keep counting