Skip to content

fix(subagent): return the chain's final result and mark unstarted steps - #227

Merged
Uking-xxx merged 1 commit into
mainfrom
fix/subagent-chain-result
Oct 9, 2026
Merged

Uking-xxx merged 1 commit into
mainfrom
fix/subagent-chain-result

Conversation

@Uking-xxx

Copy link
Copy Markdown
Collaborator

Fixes #220

Problem

A blocking subagent chain returned records[0] as the tool content (execute.ts), sharing the single-mode path. The parent model only sees content, never details, so:

  • a successful chain handed the parent the first step's output, not the final one;
  • a chain that failed or was aborted mid-way still read as the first step's success — the failure only lived in details.results;
  • steps that never started were seeded as running and stayed running after the chain stopped (in the TUI too: a ticking timer and (running...)).

Partial updates also flipped details.mode from chain to single mid-run.

Changes

  • Chain content: a per-step status line, plus
    • on success: the last step's output;
    • on failure/abort: Chain stopped at step N/M (...); the chain did not complete., the stopping step's error, and the last completed output (truncated at 50k).
      Earlier step bodies stay in details.results rather than piling into the parent's context.
  • New record statuses:
    • queued — not dispatched yet (later chain steps, parallel tasks behind maxConcurrency); no startedAt, so no clock. Flipped to running when the step is dispatched.
    • skipped — chain steps after a failed/aborted step.
  • Partial updates keep mode: "chain".
  • TUI: icons/labels for queued/skipped; widget and parallel headings count them separately (skipped no longer counted as failed); chain heading reads N/N steps completed / failed at step 2/3 instead of results[0].status.
  • Background lanes treat queued records as still running.

Single and parallel content are unchanged.

Testing

  • New test/subagent-chain-result.test.ts (8 cases, deterministic runner): success, mid-chain failure, abort, first-step failure, queued→running ordering for chain and parallel, plus single/parallel unchanged. 4 of them fail on main.
  • All subagent tests pass (52/52); pnpm run check passes.
  • Manual tmux run from source against step-5-preview: successful chain, unknown-agent failure at step 2, and Esc during step 2 — parent got the expected content in each case, and the widget showed 1/3 complete, 1 running, 1 queued while step 2 ran.

Note for consumers

StepSubagentResultRecord.status gains queued and skipped. Anything rendering details.results[].status directly (e.g. Desktop) should handle both.

A blocking chain returned records[0] as the tool content, so the parent
model only saw the first step's output, and a failed or aborted chain
still read as the first step's success. Unstarted steps were seeded as
"running" and stayed that way after the chain stopped.

- Chain content now carries a per-step status line plus the last step's
  output on success, or the stopping step's error and the last completed
  output on failure/abort.
- Add "queued" for steps not yet dispatched (later chain steps, parallel
  tasks behind maxConcurrency) and "skipped" for chain steps after a stop.
- Partial updates keep mode "chain" instead of flipping to "single".
- TUI headings and widget counts handle queued/skipped; the chain heading
  no longer reads results[0].
- Background lanes treat queued records as still running.

Fixes #220
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.

[bug] 子代理链式任务只返回第一步结果,未返回最终结果

1 participant