Repository navigation
Description
Problem
Bob's subagents and subtasks do not show in the session that started them. Each child task gets a session row of its own. The messages view and the timeline of the parent session show nothing between the parent's spawn_subagent (or start_subtask) call and the result. The child's cost is not in the parent's cost.
Cause: Cortex uses X-Task-Id as Bob's session id (core/session/idheader.go). Each child task sends a new X-Task-Id. Subagent support reads only Claude Code's headers (core/pipeline/subagent.go), so the subagent field is empty on every Bob row.
What Bob sends
Source: the code of bob-shell 2.1.0 and Bob IDE 2.2.3, and two live runs through the laptop proxy on 2026-11-11.
- Every chat request sends
X-Task-Id: <task id>. - A child task also sends
X-Parent-Task-Id: <id>. Theweb_searchtool sends the same pair. - Bob has two kinds of child task:
| Kind | Started by | Where | Runs | Seen on the wire |
|---|---|---|---|---|
| Subagent | spawn_subagent |
bob-shell and Bob IDE | In parallel when there are several calls in one turn. It cannot start another child. | Yes, both clients |
| Subtask | start_subtask |
Bob IDE only (bob-shell 2.1.0 has no tool for it) | One at a time. The parent sends nothing until end_subtask. No nested subtasks. |
Yes, Bob IDE |
- Every child names the root task. In the Bob IDE run, subagents that the subtask started sent
X-Parent-Task-Id= the root, not the subtask. So the wire shows a tree with one level. - Bob treats both kinds as part of the parent. Its task list shows only root tasks (
parentId: null, taskType: "normal"). It merges a child's messages into the parent's tool message, and it adds the child's spend to the parent. Bob IDE shows a subtask in the parent's breadcrumbs. - A subtask and a subagent send the same headers. The tool list is the difference. A subtask is offered
end_subtask, and is not offeredstart_subtask. A subagent is offered neither. - Bob sends no subagent marker in the body.
agentRoleis empty.X-Parent-Task-Idis the only signal. - The
routerandsecuritycalls send no task id. Client affinity files them in the Bob session that Cortex saw last. In the live runs, oneroutercall of a parallel spawn went to a subagent's session.
Live evidence (laptop session API):
| Run | Root | Children (each one its own session today) |
|---|---|---|
| bob-shell 2.1.0 | 4430cc6e… |
4 subagents, 2 of them in parallel. All name the root. |
| Bob IDE 2.2.3 | f40f1df7… |
1 subtask, 2 parallel subagents started by the subtask, 1 subagent started by the root. All name the root. |
Rules
Apply these in this order. Each rule acts only on a header that Bob sent. No rule guesses.
- Session id. When the session id comes from
X-Task-Id, and the request also sends a validX-Parent-Task-Id, the session id is theX-Parent-Task-Idvalue. Check the parent id withvalidHeaderSessionID, as for every id header. An invalid parent id changes nothing: the request keeps its ownX-Task-Idsession, as today. - Subagent id. For such a request,
Context.Subagent()returns itsX-Task-Id.ParentSubagent()returns "". The parent is the session, as for a Claude Code subagent that the main conversation started. UsevalidSubagentIDon the value. - Kind. Record the child's kind on the event:
subtaskwhen the request's tool list hasend_subtask, otherwisesubagent. A field or value name is decided in the plan. - Header-less calls. No change. After rules 1–2, the Bob session that Cortex saw last is the root. Client affinity then files
routerandsecuritycalls in the root. They get no subagent id, because nothing on the wire names their child. - Messages view (agentop). A Bob subagent is a collapsible block, as for Claude Code (feature: ability to distinguish Claude Code subagent traffic within abctl #1047). A subtask is a labeled section of the main conversation, at its place in time, because the parent waits for it.
- Timeline. A Bob child is an agent row under its
subagentid, throughagentOf(core/session/timeline/agents.go). A subtask row is labeled as a subtask. - Cost. No new code. A child's rows are in the root session, so the root's cost includes them. This is what Bob does too.
Unchanged
- Claude Code attribution, and every other client.
- Bob root tasks: the session id stays
X-Task-Id. session.id_headers:X-Parent-Task-Idis not added to it. Rule 1 applies only whenX-Task-Idgave the id.- Trust:
X-Parent-Task-Idis client-asserted and unauthenticated, asX-Task-Idis. It is a grouping key, never a principal.
Not covered
- Children of a subtask are not shown inside the subtask's section. The wire names the root, not the subtask. A match by time would be a guess.
- A deeper tree. bob-shell's code sets a subagent's parent to the task that started it. That gives subtask → subagent only in bob-shell, and bob-shell cannot start a subtask. If a later Bob version names a subtask as a parent, rule 1 files that subagent in the subtask's id. Fix that when it is seen on the wire.
- Archived child sessions stay as separate sessions. The archive is not re-filed.
resume_id. A resumed subagent sends its old task id again and the same parent, so rules 1–2 file it in the same block. Not seen on the wire.
Files
core/session/idheader.go: rule 1. Probably aBobParentTaskHeaderconst besideBobSessionHeader.core/pipeline/subagent.go: rule 2.- Inference parse or event model: rule 3.
cmd/agentop: rule 5.core/session/timeline/agents.go: rule 6.- Docs:
docs/session-api.md(subagentfor Bob, the kind) anddocs/agents/bob.md(what Cortex shows for subagents and subtasks).
Required artifact: a doc for Bob
Update docs/agents/bob.md in the same PR. This issue does not close on code alone.
Tests
X-Task-Id+ validX-Parent-Task-Id→ parent's session,subagent= own task id.- Invalid
X-Parent-Task-Id→ own session, no subagent id. X-Parent-Task-IdwithoutX-Task-Id, and on a Claude Code request → no effect.- Tool list with
end_subtask→ kindsubtask. Without it →subagent. - A fixture from the Bob IDE run: root, a subtask, 2 parallel subagents and a header-less
routercall, interleaved. All rows land in the root. Two blocks and one subtask section render. - Live check: repeat both runs on the laptop proxy.
Size
One PR, about 400–600 lines with tests and docs.
Assisted-By: Claude (Anthropic AI) [email protected]
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: Add the plan for Bob subagents and subtasks (#1803)
docs: Make the #1803 plan steps exact and record the gate check
feat: Record a Bob child task's id and kind on its rows
feat: File a Bob child task in its root task's session
fix: Keep the Bob task headers in core/model