From f15542d2ea1df24e4ee0e067b21cf4e1f576b5ae Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 15 Oct 2026 10:42:05 +0800 Subject: [PATCH] sessions: OpenCode 2 subagents show their type, and a Kimi Code subagent opens on its task, not a context chip (#2290, infinitr0us) OpenCode 2.0.29 keeps a child session's agent in session_v2.agent and titles it with the task alone, so ocSubagentTitle found no kind and every OpenCode subagent row showed only its title and time. The kind now comes from session_v2.agent when set (ocV2DB.agent, kept once found; a missing column or NULL reads as none and isn't kept), and the "(@agent subagent)" title split stays the fallback for older versions. A Kimi Code subagent's own wire.jsonl starts with the task its parent gave it, a turn.prompt whose origin is {kind: system_trigger, name: subagent}; the transcript folded every system_trigger as context. In a subagent's own wire (not agents/main) that prompt now opens as its first user message (kimiTask). Other system triggers, and a "subagent" one in the session's main wire, stay folded. Fixtures follow the reporter's described shapes: ocMakeV2's real session_v2 schema with agent 'explore' and a task-only title beside a child with no agent and an older suffixed title; a 1.5-shaped subagent wire (agentId, promptId, turnId) with the subagent trigger, a reply and a background_task trigger, plus a subagent trigger appended to main. No real OpenCode child sessions or Kimi Code subagents on this machine. No GUI change: the Sessions client already draws a subagent's kind. Run: TestOpenCodeV2SubagentKind and TestKimiSubagentTask fail on the old subagents.go/transcript_kimi.go (no kind; user/context first), and TestKimiSubagentTask fails with the agents/main scope check dropped. go test -p 1 -tags nogui ./internal/sessions/ ok at the rebased head; gofmt -l clean; go vet -tags nogui ./internal/sessions/ for darwin, GOOS=linux and GOOS=windows. Full suite: SUITE_LINE --- docs/subsystems/gateway-sessions.md | 13 +++-- internal/sessions/subagents.go | 24 +++++++++ internal/sessions/subagents_test.go | 80 ++++++++++++++++++++++++++++ internal/sessions/transcript_kimi.go | 17 +++++- 4 files changed, 130 insertions(+), 4 deletions(-) diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.md index 749488d4e..a973c5bfd 100644 --- a/docs/subsystems/gateway-sessions.md +++ b/docs/subsystems/gateway-sessions.md @@ -425,19 +425,26 @@ for the session) and `start`/`last`; its file is never sent. `ocRoots` records its parent. Its title splits 1.x's ` (@ subagent)`; 2.x titles it the description alone (task tool, opencode 2.0.25), and a default `Child session -