Skip to content

Strip the sub-agent report envelope from expanded task details - #376

Merged
TheGreatAxios merged 1 commit into
cl-4869-stale-back-to-parent-session-link-persists-in-the-mainfrom
cl-4866-clean-up-transcript-rendering-of-tasksub-agent-activity
Aug 7, 2026
Merged

Strip the sub-agent report envelope from expanded task details#376
TheGreatAxios merged 1 commit into
cl-4869-stale-back-to-parent-session-link-persists-in-the-mainfrom
cl-4866-clean-up-transcript-rendering-of-tasksub-agent-activity

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #372 (CL-4869) — both tickets concern how sub-agent
activity renders in the parent transcript.

Auditing the live TUI's task/tool-row rendering against CL-4866's
outcomes:

  • Curated task rows, not raw field dumps: already correct.
    describeToolCall's "task" case (src/tui/tool-formatter.ts)
    reduces a spawn's prompt/intent/tier/maxTurns/criteria brief
    to just its description, and toolCallRow uses it. Confirmed with
    a rendered frame below.
  • Long shell commands hang-indented, not wrapped mid-token: already
    correct and tested (command-display.test.ts, stream.ts
    truncateLine/indentBody).
  • Repeated calls collapse onto one row: already correct and tested
    (tool-rows.ts canCoalesceCall/coalesceCallRows, "a run of
    identical calls / is one row").
  • Sub-agent report markdown rendered or stripped: not correct.
    summarizeTaskResultPreview — which strips the Sub-agent "desc" reported: / ## Summary envelope — existed in
    src/tui/tool-formatter.ts with zero callers anywhere in the
    codebase. The one-line collapsed preview happened to go through it
    indirectly via summarizeToolResult, but the expanded detail behind
    the arrow fell through to bodyLines(content) on the raw text, so
    expanding a task result showed the literal Sub-agent "..." reported:
    prefix and ## heading markers.

This PR fixes the one real gap: resultSummary in mcp-view.ts now
gives "task" results the same always-curated treatment tool_search
catalogues already get, and strips the envelope/heading markers from
the text that becomes the expanded detail.

Investigation note (CL-4869 connection)

Digging into why these fixes seemed to exist already (PR #298/#300,
superseded by merged #312) turned up something more important: #312
touched only src/tui/app.tsx and its Ink component tree, which has
zero importers anywhere in the repo — package.json carries no
ink/react dependency, and the live entrypoint renders through
src/tui-opentui/shell.ts instead. Those merged fixes never reached
the shipping TUI. That's documented in #372's description. This PR's
stripTaskReportEnvelope addition is new, not a port of dead-tree
code — the dead tree's equivalent (mergedToolCollapsedPreview) was
unused there too.

Verification

  • bun run typecheck
  • bun run test (full suite, 4040 pass / 0 fail)
  • bun test ./src ./tests ./evals --randomize --seed 42 (4040 pass / 0 fail; one earlier run on this seed showed an unrelated one-off flake in an unrelated file that did not reproduce on rerun)
  • Rendered a real frame of an expanded task result row through the
    OpenTUI test harness:
  ✓ Task explore callers 8 lines ▾
      Summary
      Found 3 call sites in src/tui-opentui.

      Findings
      - shell.ts line 40
      - diff.ts line 12

No raw prompt/intent/tier dump on the collapsed line, no
Sub-agent "..." reported: prefix, no literal ## in the expanded
body.

Closes CL-4866

A task tool result wraps a sub-agent's reply as `Sub-agent "desc"
reported:` followed by raw `## Summary` / `## Findings` markdown
headings. The collapsed one-line preview already stripped this
envelope, but the expanded detail behind the arrow rendered the
result text as plain lines, so the raw prefix and literal `##`
markers leaked straight into the transcript.

Give "task" results the same always-curated treatment tool_search
catalogues already get in resultSummary, and strip the envelope and
heading markers from the text that becomes the expanded body.
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

CL-4866

@TheGreatAxios
TheGreatAxios merged commit 6a79984 into cl-4869-stale-back-to-parent-session-link-persists-in-the-main Aug 7, 2026
3 checks passed
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.

1 participant