Skip to content

fix(native-chat): a subagent's words are presented as that subagent's, never the parent's - #23605

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/sta-8138-subagent-speech
Sep 28, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/sta-8138-subagent-speech

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​393 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​391
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​306 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​256

ELI5

When an agent in the chat hands work to a helper agent (a subagent), the helper's words show up in the same chat. Today they look exactly like the main agent talking, so you can read a helper's "The PR is CLEAN" as if the agent you asked had concluded it. This PR keeps every helper line where it happened but labels it as that helper's, and never lets a helper's words stand in as the main agent's reply.

What Changed

Before (mechanism). Every journal row already records which agent wrote it: #22299 added producer linkage (agentId, parentAgentId, producerKind, …) and scoped the sidebar and status readers by it. But the chat transcript's projection copied only the row's id, time and position onto each chat message, so the linkage stopped there. Everything downstream of the projection could no longer tell the agent from its helpers:

  • a helper's prose rendered as an ordinary assistant bubble, i.e. as the agent you are talking to;
  • the tool-call fold merged a helper's tool calls into the parent's tool run (and the parent's into a helper's prose), because it folds into "the preceding assistant message" regardless of who wrote it;
  • a settled turn folds down to its "answer", defined as the turn's last prose row — so when a helper kept narrating after the parent's last word, the collapsed turn showed the helper's words as the parent's only visible reply;
  • orca orchestration worker-read and terminal read on a structured worker printed a helper's lines as [assistant] …, the worker's own.

After (mechanism). The projection now carries the row's linkage onto the chat message through the same single spread (agentJournalLinkageFields) every other linkage carrier uses. Nothing new is stored: the chat message is rebuilt from the journal on every read. With the linkage present, each reader applies one rule, all through the existing single interpretation point for "was this the session's own agent":

  • the tool-call fold never folds one agent's calls into another agent's run, so interleaved agents stay in the order they happened, each call under the agent that made it;
  • each agent has its own "live" run, so a parent still inside its spawn call reads as running while its helper works below it (previously only the transcript's last row could read as live);
  • a turn's answer is the last prose the session's own agent wrote;
  • a helper's row stays where it happened, set off like an aside and captioned with the helper's name from its spawn roster (or "Subagent" if no loaded roster names it), on desktop and mobile; a row whose only content is hidden behind its settled turn is not captioned;
  • worker transcripts tag a helper's lines [assistant, subagent <name>]; the worker-read payload serves only the helper's id, bounded exactly like the roster entry that names it, and not the provenance fields.

User-visible after. The chat still shows everything every agent did. A helper's lines read as the helper's. A collapsed turn shows the agent's own answer, with the helpers' narration behind "Worked for N" like the rest of the turn's work.

Why

The failure class. Attribution existed in the durable record and was thrown away at one hop, so every reader downstream had to present rows without knowing whose they were. Patching individual readers would leave the next one wrong; carrying the fact across the hop fixes the class, and each reader keeps only presentation policy.

How often, on real data. On this machine's journals from the last six days, 572 of 2,309 settled turns (about 25%) folded down to a helper's words as the turn's answer. In one real session the "parent's" transcript held 3,584 tool calls and 299 prose lines that were actually its helpers', against 3,353 and 461 of its own.

Why attribute in place, rather than the alternatives.

  • Drop helper rows from the parent's timeline and summarize them only in the roster row. Rejected: the turn's "N changed files" rollup keys each file to the message that edited it so a click can reveal the diff, and helpers' edits are real changes to your workspace; hiding their rows breaks those reveals or silently undercounts the rollup. It also reverses a deliberate earlier decision that the transcript shows every agent's output.
  • Move each helper's rows under its entry in the subagent roster. Rejected: the roster row is deliberately a flat summary ("children are summarized here, never nested into the transcript"), it would need the same reveal plumbing, and mobile does not render the roster block at all.
  • Anchor helper rows to the tool call that spawned them. Rejected: that call's id is re-minted every time a helper resumes, and the linkage's own contract says it is provenance, never a join key. The stable key is the helper's canonical id, which is also the roster entry's id, so the caption's name comes from the same fact.

What stays one rule. Absence of linkage means "the session's own agent", read in one place (isRootAgentJournalItem and its new sibling agentJournalItemSubagentId). Transcripts with no linkage at all — terminal-backed chats and journals written before #22299 — fold and render exactly as before; there is a test for that.

Deviation from common practice, stated plainly. The common approach keeps a helper's own rows out of the parent's timeline: either dropping them, or attaching them beneath the call that spawned the helper. This PR does neither; it attributes them in place. That is a deliberate deviation for the reasons above, not an alignment. Its cost is that a helper-heavy session stays busy to read, and every new reader of chat messages has to consult the producer rather than being safe by construction. The linkage-on-the-message and producer-aware fold introduced here are the foundation a later "attach helper rows beneath their helper" design would build on, so this is not a dead end.

Known weaknesses.

  • A helper whose roster row is outside the loaded page is captioned "Subagent" rather than by name until the older page loads. It is still never presented as the parent.
  • Rows a provider emits before it has announced the helper can arrive with no linkage and read as the parent's. That is the producer's existing, documented behaviour from fix(native-chat): journal rows name the agent that produced them #22299, not something this PR changes.
  • Very long helper-heavy sessions remain dense. Nesting a helper's rows beneath it is the natural follow-up, deliberately not in scope here.
  • Not caused by this PR, and not changed by it: a pending approval or question card raised by a helper does not name the helper; a helper's plan (todo list) could replace the parent's in the composer, though no journal on the test machine contains one; the conversation outline is not producer-scoped, which only matters if a provider ever journals a helper's own user-role row (none does today).

Wire and persistence. No schema bump, no migration, no new persisted fact. The chat message gains optional linkage fields that are copies of what the journal already stores; they reach the worker-read result and the released-worker archive as new optional fields (Rule 1 in docs/reference/remote-wire-compatibility.md). An older client ignores them and prints as today; a newer client reading an older host sees no linkage and prints as today. Archives written before this change carry no linkage and read exactly as before.

Linked Issue

Linear: STA-8138 — relands the user-visible fix reverted in #22058 on the identity model #22299 introduced, rather than on the reverted boolean.

Scope note: #22299 already relanded the sidebar and status half of #21398. The ticket's acceptance ("a subagent's output is not presented as the parent agent's speech") also covers the chat transcript, which #21398 had deliberately left alone; this PR is that half.

Visual Proof

To be attached by the Electron QA pass.

Testing

  • Automated tests added/updated
  • I manually tested these changes locally (Electron QA runs on the remote QA machine; results attached above)

New tests, each proven red against the pre-change code and green after (break the fix, watch the named tests fail, restore):

  • projection: a helper's transcript message names its producer; the agent's own does not;
  • fold: a helper's calls never join the parent's run; interleaved agents keep their order, each call in its own agent's run; a turn boundary still ends the run; a transcript with no linkage folds exactly as before;
  • turn answer: the agent's own last prose is the answer; a helper's later prose folds behind a settled turn; a turn only helpers spoke in has no answer;
  • desktop slots and row: the settled turn draws the parent's answer and folds the helper's words; the parent's run stays live while its helper works below it, and settles once the parent answers; the helper row is captioned from the roster, and only helper rows are; windowing reserves the caption's height;
  • mobile row: the helper is named; an unnamed helper still reads as a subagent; the parent's own row gets no caption; a settled row with nothing visible names no one;
  • worker-read payload: only the helper's id is served, bounded to the same key as its roster entry; a helper's pending question keeps its producer;
  • worker transcript text: helper lines are tagged with the helper's name, or as an unnamed subagent.

Gates: root typecheck (node, CLI, web) and the mobile typecheck (which root typecheck does not cover, and which caught a real bug in the first draft), oxlint with root and mobile configs (with a positive control proving it fails on a real violation), the changed-code quality gate, React Doctor, and all five localization verifiers.

Broad regression over src/shared, the native-chat and sidebar components, the orchestration CLI and src/main/runtime: 23,868 passed, 8 failed, and every failure was checked against main's code. Three pass in isolation (load-sensitive), three fail identically with this change reverted (orchestration-task-list-brief ×2, orchestration-all-start-versions-migration), one fails 1 run in 3 on both main's code and this branch (repo-ref-maintenance). None is caused by this PR.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform: no platform-specific code. SSH/remote: the change is in shared projection and presentation; remote hosts' journals carry the same linkage, and the wire change is optional-field only. Mobile: same fold and caption as desktop. Performance: one linear pass per message list to collect roster names, memoized on the list; row props stay primitive so memoized rows do not re-render.

Two pre-existing localization issues noticed and deliberately not fixed here: the Spanish catalog has no subagents section at all, and the existing Japanese, Korean and Chinese "Kicked off N subagents" strings are mistranslated as "fired", "expelled" and "kicked out".

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…, never the parent's

The journal already names the agent that produced every row, but the transcript
projection dropped it, so a subagent's prose rendered as the parent's reply, its
tool calls folded into the parent's runs, and a settled turn could fold down to
a subagent's words as its only visible answer.

The transcript message now keeps the row's producer. The fold keeps each agent's
calls in that agent's own run, a turn's answer is the session's own agent's last
prose, and a subagent's row names the subagent on desktop, mobile and a worker's
transcript text.
…wn run live

Review follow-ups:
- the fold is main's adjacency fold plus one condition: a row never folds into
  another agent's run, so an agent's later call stays below its subagent's work
  instead of jumping back into its earlier row
- each agent has its own live frontier, so a parent still inside its spawn call
  reads as running while its subagent works below it
- mobile names no one on a row whose only content is hidden behind its settled turn
- a pending question from a subagent keeps its producer
- worker reads serve only the producing agent's id, bounded like the roster key
  that names it, and drop the provenance fields
- the single-message worker formatter is private, so no caller can drop names
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a9084b15-96bc-4b4a-8db4-d18b147a0a26

📥 Commits

Reviewing files that changed from the base of the PR and between c2af6af and 85c49e1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/zh.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change preserves subagent identity in projected and served transcript messages. Native chat uses that identity to separate agent-specific runs and show subagent labels, captions, and row styling. Worker transcript formatting adds subagent speaker prefixes and uses batch formatting in CLI output and terminal previews. Tests cover attribution, folding, projection, and row layout.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 85c49

Interleaved tool results can disappear, and some subagent messages can appear without attribution. Fix both before merging.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 85c49

Helper-agent attribution is improved across the chat experience, but an interleaved tool result may disappear from the visible transcript. No new cross-user access or privilege escalation is evidenced.

Retained concerns

  • Medium · reliability · inferred: If a result-only or harness-sidecar message arrives after another agent becomes the current assistant, the new producer match prevents it from folding into the wrong agent, but does not recover its original target. The unpaired tool result can then be removed from the displayed transcript, reducing visibility of the tool outcome. Production reachability for this ordering is unverified.
Security review details

Security Blast Radius

  • inferred — The evidenced exposure is attribution and outcome visibility within transcripts consumed by chat and worker readers. The inspected changes do not establish a new tenant boundary, credential authority, or privileged action.

Security Findings and Attack Paths

  • inferred — Helper-linked status content could bypass the ordinary desktop attribution caption through the notice or provider-frame branches. Those branches predate this change; the evidence does not establish a newly reachable production path or increased exposure, so this is not treated as an introduced security finding.

Trust Boundaries and Controls

  • observed — Attribution uses producer linkage rather than the prose or a display label as its identity check. The inspected ordinary-row path retains its existing link callbacks and assistant-control condition; the new caption does not itself grant an action.

Resilience and Maintainability Implications

  • inferred — Rejecting a cross-agent fold protects speaker integrity, but dropping an unmatched result can remove evidence of a tool outcome from the displayed history. The structured producer’s combined call/result rows limit this scenario; other provider ordering remains unverified.

Hardening Proposals

  • proposed — Exercise a delayed result or sidecar across interleaved producers and preserve its outcome without attaching it to the wrong speaker. Confirm whether production emits helper-linked notices or provider frames before extending attribution to those branches.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.31% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 31 files. (7 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: subagent output is attributed to the subagent instead of the parent agent.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, linked issue, testing, compatibility, and performance. The required visual proof is still pending, and several checkl…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 42.31% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 31 files. (7 skipped: 7 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — two non-blocking notes inline (one design question, one wire-contract observation).

Reviewed changes

Carries the journal's producer lineage onto the chat transcript so a subagent's words are never presented as the parent agent's.

  • Projection — NativeChatMessage now intersects AgentJournalProducerLinkage; structured-agent-session-projection.ts and structured-agent-question-projection.ts spread the row's linkage. Absence of agentId remains the claim that the session's own agent wrote the row.
  • Fold — foldToolMessages only absorbs a tool-only message into a preceding assistant written by the same producer, so interleaved agents keep their order and each call lands under the agent that made it.
  • Turn answer — nativeChatTurnAnswerRows now requires isRootAgentJournalItem, so a subagent narrating after the parent's last word is no longer the turn's answer.
  • Slots — per-agent frontier (trailingRunIndexes), roster-label lookup, and caption height (attributed).
  • Presentation — desktop MessageRow and mobile MobileNativeChatMessage caption a subagent row from the roster label, falling back to Subagent; native-chat-subagent-attribution.ts is the shared label source.
  • Worker text — formatWorkerTranscriptMessages tags subagent lines [assistant, subagent <name>]; worker-transcript-payload.ts serves only the bounded agentId.
  • i18n — subagents.unnamed / writtenBy added to en, fr, ja, ko, zh, es.

I verified the key equality the feature rests on (roster entry id === journal agentId === canonical task/thread id, for both Claude and Codex) and that mobile's structured messages do carry both the roster block and the child agentId, so labels resolve end to end. Changed tests run green here except the mobile suite (expo deps unavailable in this environment).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

(row, index) =>
// Each agent has its own frontier: a subagent working below its parent's run
// has not moved the parent past it.
const trailingRunIndexes = new Set<number>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The per-agent frontier never consults the roster's completion state. A subagent that has finished stops emitting rows, so its last qualifying row stays trailingRun: true for the rest of the parent's working turn — and NativeChatToolRun forces live whenever activeTurnIsWorking === true && trailing !== false, so a completed subagent's tool run keeps pulsing until the whole turn settles. The old single findLastIndex frontier let the parent's later row settle it. Is that intended?

Technical details
# A completed subagent's run stays live for the remainder of the turn

## Affected sites
- `native-chat-transcript-slots.ts:121-136` — `trailingRunIndexes` marks one frontier per `agentId` and never reads `agents[].state`; a child agent's frontier can only be superseded by that same agent's later rows, which a completed child never writes.
- `NativeChatTranscriptRow.tsx:59` → `NativeChatMessageRow.tsx:260` → `NativeChatToolRun.tsx:132-136` — `trailing !== false` on a working turn forces `live`, regardless of the call's terminal state.
- `NativeChatMessageList.tsx:161-169` — `turnKeys` are assigned on `user` boundaries only, so a child's rows share the parent turn's key and get `activeTurnIsWorking: true` while the parent works.

## Example interleaving
```
user ask → root prose "delegating" → root spawn call →
child tool run (completed; roster already reads `completed`) →
root prose "continuing" → root tool run
```
trailing = {child row, root row}: the child's run renders `data-native-chat-tool-run-state="live"` while the roster row above reports it `completed`.

## Required outcome
- Either a completed subagent's own run settles once it is done, or the behavior is documented as intended (per-agent liveness overrides roster completion for the duration of the turn).

## Suggested approach (optional)
- When marking a non-root frontier, skip (or do not mark trailing) an agent whose roster entry state is terminal. The roster is on the same message list, so the state is already reachable from `messages`.

## Open questions for the human
- Is a finished subagent's run meant to keep its live mark until the turn ends?

Comment on lines +117 to +121
agentId: _agentId,
parentAgentId: _parentAgentId,
providerParentRef: _providerParentRef,
producerKind: _producerKind,
attempt: _attempt,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This destructure removes parentAgentId, providerParentRef, producerKind and attempt from the served payload — fields the old code spread through — not just adds agentId. Per docs/reference/remote-wire-compatibility.md Rule 3, a host that stops populating a field is a wire change even with no codec change. No renderer or mobile consumer reads these today (checked), so it is benign, but the PR description's "new optional fields (Rule 1)" framing doesn't cover the removal.

Technical details
# Worker-read transcript narrows previously-published provenance fields

## Affected sites
- `worker-transcript-payload.ts:115-122` — destructures away `parentAgentId`, `providerParentRef`, `producerKind`, `attempt` (previously served via `...served`).
- `worker-transcript-payload.ts:130` — re-adds only the bounded `agentId`.

## Required outcome
- Confirm no released client reads the removed fields from `orchestration.workerRead` / the released-worker archive, or note the narrowing in the wire section of the PR so a future reader does not treat the payload as purely additive.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c26cdffc-9cd1-4b62-b5f2-512f4c529e55

📥 Commits

Reviewing files that changed from the base of the PR and between 0830051 and c2af6af.

📒 Files selected for processing (38)
  • mobile/src/session/MobileNativeChatMessage.test.ts
  • mobile/src/session/MobileNativeChatMessage.tsx
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/mobile-native-chat-message-styles.ts
  • src/cli/handlers/orchestration/worker-output.ts
  • src/main/runtime/orchestration/worker-transcript-payload.test.ts
  • src/main/runtime/orchestration/worker-transcript-payload.ts
  • src/main/runtime/structured-worker-terminal-read.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx
  • src/renderer/src/components/native-chat/native-chat-row-height-estimate.ts
  • src/renderer/src/components/native-chat/native-chat-tool-fold.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-slots.ts
  • src/renderer/src/components/native-chat/structured-agent-question-projection.test.ts
  • src/renderer/src/components/native-chat/structured-agent-question-projection.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.options.test.tsx
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-journal-producer.ts
  • src/shared/native-chat-subagent-attribution.ts
  • src/shared/native-chat-tool-fold.ts
  • src/shared/native-chat-turn-fold.test.ts
  • src/shared/native-chat-turn-fold.ts
  • src/shared/native-chat-types.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
  • src/shared/worker-transcript-background-task-text.test.ts
  • src/shared/worker-transcript-subagent-attribution.test.ts
  • src/shared/worker-transcript-text-scaling.test.ts
  • src/shared/worker-transcript-text.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +190 to +193
// A subagent's row sits where it happened but speaks as that subagent, never as
// the agent the reader is talking to.
const subagentName =
agentJournalItemSubagentId(message) === null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Show attribution on notice and provider-frame rows.

If a subagent row contains a notice or provider frame, MessageRow returns at Line 111 or Line 123 before it reaches this caption. The displayed content has no subagent attribution, even though the message retains agentId. Render the caption in those branches as well, or move attribution into a wrapper shared by all non-user row types.

Comment on lines +91 to +96
const foldTarget =
mutableAssistantIndex >= 0 &&
agentJournalItemSubagentId(output[mutableAssistantIndex]) ===
agentJournalItemSubagentId(message)
? mutableAssistantIndex
: -1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve tool results when another agent interleaves.

If a child emits a tool call, the parent emits an assistant row, and the child then emits a tool result, foldTarget is -1. The result stays in its own row. dropUnattributableToolResults then removes it because that row has no call. The transcript loses the result and any reported failure. Keep the result in its attributed position, or match it to the child's call without moving it ahead of the parent's row.

Comment on lines +37 to +38
const label = nativeChatSubagentLabel(subagentLabels, message)
return label === undefined ? `${message.role}, subagent` : `${message.role}, subagent ${label}`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,100p' src/shared/worker-transcript-text.ts
sed -n '1,100p' src/shared/native-chat-subagent-attribution.ts
rg -n 'agentPath|agent\.label|subagent.*label' src/main src/shared | head -100

Repository: stablyai/orca

Length of output: 19695


🏁 Script executed:

#!/bin/bash
sed -n '1,130p' src/main/codex/codex-subagent-activity.ts
sed -n '1,130p' src/main/codex/codex-subagent-roster.ts
sed -n '1,100p' src/main/codex/codex-subagent-group-body.ts
sed -n '1,100p' src/main/runtime/orchestration/worker-transcript-activity-block-bounds.ts
rg -n -A12 -B8 'boundInlineText\(agent\.label|label:.*agent\.label|replace\(/\\s|trim\(\)' src/main/claude src/main/codex src/main/native-chat src/main/runtime

Repository: stablyai/orca

Length of output: 45715


Injection

Reachability: External
Exploitability: Moderate
CWE: CWE-93

Reachability path
● Entry
  src/shared/worker-transcript-background-task-text.test.ts:5
  formatWorkerTranscriptMessage
│
▼
● Sink
  src/shared/worker-transcript-text.ts

Escape line breaks from Codex roster labels before building speaker prefixes. Codex labels retain embedded line breaks after trimming and length bounding. workerTranscriptSpeaker inserts the label directly, so a label containing \n[assistant] ... can create a forged speaker line in CLI transcript and terminal-read output.

Escape line breaks in the shared formatter
   const label = nativeChatSubagentLabel(subagentLabels, message)
-  return label === undefined ? `${message.role}, subagent` : `${message.role}, subagent ${label}`
+  const safeLabel = label?.replace(/\r/g, '\\r').replace(/\n/g, '\\n')
+  return safeLabel === undefined
+    ? `${message.role}, subagent`
+    : `${message.role}, subagent ${safeLabel}`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const label = nativeChatSubagentLabel(subagentLabels, message)
return label === undefined ? `${message.role}, subagent` : `${message.role}, subagent ${label}`
const label = nativeChatSubagentLabel(subagentLabels, message)
const safeLabel = label?.replace(/\r/g, '\\r').replace(/\n/g, '\\n')
return safeLabel === undefined
? `${message.role}, subagent`
: `${message.role}, subagent ${safeLabel}`

View in Security blast radius

…-subagent-speech

# Conflicts:
#	src/renderer/src/components/native-chat/NativeChatMessageRow.test.tsx
#	src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Fixes subagent message attribution in chat display.

The PR should not merge until the lockfile agrees with the dependency manifest and patch configuration.

Findings

  1. P1 Inconsistent dependency lockfile ▶

Summary

The PR carries journal producer linkage into chat messages, keeps interleaved agents’ tool runs separate, and attributes subagent rows in desktop, mobile, and worker transcript output.

  • The lockfile’s unrelated i18next-cli change is inconsistent with the dependency manifest and patch configuration.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  J[Session journal rows] --> P[Chat projection with producer linkage]
  P --> F[Producer-aware tool and turn folds]
  F --> D[Desktop and mobile attributed rows]
  P --> W[Bounded worker transcript]
  W --> T[Attributed CLI and terminal text]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment thread pnpm-lock.yaml
Comment on lines 396 to +399
specifier: ^9.1.7
version: 9.1.7
i18next-cli:
specifier: 1.74.1
version: 1.74.1(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])
specifier: 1.74.2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Inconsistent dependency lockfile The lockfile now resolves [email protected] and records a patch hash for it, but package.json still pins 1.74.1 and pnpm-workspace.yaml declares no patch for 1.74.2. A frozen install cannot use this configuration as committed, blocking clean installs and CI. Please update the manifest and patch declaration together, or restore the lockfile entry.

@brennanb2025
brennanb2025 merged commit e8e144b into main Sep 28, 2026
50 checks passed
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…3614) into #23059

Conflicts, resolved to keep main's mechanism and #23059's turn facts:
- Codex turn boundaries and translator: main's #23682 wins; the error-driven
  `fail` end and the oversized-notification settler are gone, and only
  `turn/completed` ends a turn, a command's turn included.
- Codex adapter: the compaction tracker stays deleted; #23618's settlement of
  sends in an ended turn is kept, and `codexDispatchRejection` is imported from
  its new home.
- Journal reducer: main's per-item creating fence (#23456) moves into the item
  and submission folds this branch split out of the reducer.
- Stale-turn verdict: main's proof-of-death revision; every turn revision states
  the thread scope.
- Failure words: main's retry-control rules (#23608) with this branch's any-command
  retry step; `commandRefused` drops its retry step beside a Retry, as hostFault does.
- Delivery: both the commit wake and main's death-evidence resettle and dispose.
- Fold row and transcript slots: both the turn-outcome flag and main's `agentId`.
- pr.yml and pnpm-lock.yaml taken from main.

Beyond the conflicts, the merged files needed:
- use-structured-agent-session: both sides added the same `submissions` key; one kept.
- structured-agent-session-projection: the root-item import main still used is unused here.
- The desktop message list and the mobile chat view each grew past the line limit
  from both sides' additions: the turn-membership memo moves into its own hook, and
  the mobile list footer (live status, then waiting rows) into its own helper.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up: #23752 restructures this PR's transcript half so a subagent's rows live in that subagent's own section, never in the parent's conversation. Review status is in that PR.

@brennanb2025
brennanb2025 deleted the brennanb2025/sta-8138-subagent-speech branch September 30, 2026 06:55
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