ISSUE DESCRIPTION Deep-research / workflow subagent transcripts aren't discovered…
- User
ISSUE DESCRIPTION
Deep-research / workflow subagent transcripts aren't discovered (nested under subagents/workflows/)
What I was doing
Running Claude Code's
/deep-researcha few times, then looking for those sessions in agentsview. Each run fans out into ~100 subagents and leaves a large pile of per-agent transcripts on disk — exactly the kind of session history I'd want to browse and analyze in agentsview after the fact.What happened
None of the deep-research subagent transcripts show up in agentsview. The parent session imports fine; the ~100 subagents per run are invisible.
The cause is a path-depth assumption in discovery.
DiscoverClaudeSessionslooks for subagent transcripts exactly one level down:<project>/<session>/subagents/agent-<id>.jsonland in that loop it skips any directory entry:
// internal/parser/discovery.go ~L359 for _, sub := range subFiles { if sub.IsDir() { continue // ← never descends } name := sub.Name() if !strings.HasPrefix(name, "agent-") || !strings.HasSuffix(name, ".jsonl") { continue } ... }But deep-research (and Workflow-tool runs generally) write their subagent transcripts one level deeper, grouped by workflow id:
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonlsubagents/here contains only theworkflows/directory, which the loop skips — so the entire tree underneath is never discovered. Each transcript carriesisSidechain: trueand an accompanyingagent-<id>.meta.jsonwhoseagentTypeisworkflow-subagent.Concretely, in one session three
/deep-researchruns produced 312agent-*.jsonlfiles undersubagents/workflows/, and zero directly undersubagents/. All 312 are currently dropped.Why it matters
Deep research is one of the highest-value things to capture: a single invocation can spawn a hundred subagents and burn a lot of tokens, and right now that whole tree is invisible in agentsview — no transcripts, no token/usage attribution, no way to review what the subagents actually did. As more people lean on workflow-style fan-out, this is a growing blind spot.
The fix looks small: walk
subagents/recursively (or specifically also descend intosubagents/workflows/<wf_id>/) instead of only reading its top level, and treatagent-*.jsonlfound anywhere beneath it the same way. The () is available alongside each transcript if the workflow grouping is worth surfacing in the UI. Assistant
Let me understand the issue:
DiscoverClaudeSessionslooks for subagent transcripts one level deep:<project>/<session>/subagents/agent-<id>.jsonl- But deep-research and workflow subagents write transcripts one level deeper:
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl - The fix: walk
subagents/recursively instead of only reading its top level
Let me start by exploring the repository structure and understanding the codebase.
Assistant
Let me look at the discovery.go file mentioned in the issue.
Assistant
Let me find the discovery.go file.
Assistant
Let me look at the discovery.go file around line 359.
Assistant
Let me try opening the file and then navigating.
Assistant
Let me find the relevant section. Let me search for the specific code mentioned in the issue.
Assistant
Now let me look at lines 325-390 which contain the relevant code.
Assistant
Now I can see the issue. Let me also check the sidechain discovery code mentioned at line 461.
Assistant
Let me also check for tests and understand the discovery test patterns
Assistant
Let me check if there are any tests for Claude subagent discovery that I should be aware of.
Assistant
Let me look at the existing test case for subagents to understand the test structure.
Assistant
Let me also check the FindClaudeSourceFile test for subagents.
Assistant
Now let me get the full picture by looking at the function signatures and how they're tested.
Assistant
Let me also check the helper function for setting up the file system in tests.
Assistant
Let me look at the setupFileSystem function.
Assistant
Now I have a clear understanding of the issue. Let me plan the fix:
-
DiscoverClaudeProjects(~line 348-369): Replace the flat single-levelos.ReadDironsubagents/with a recursivefilepath.WalkDirto findagent-*.jsonlat any depth. -
FindClaudeSourceFile(~line 460-487): Similarly, search recursively undersubagents/for the target file.
Let me first check the Go version to ensure
filepath.WalkDiris available.-
Assistant
Good, Go 1.26.3 has
filepath.WalkDir. Let me first run the existing tests to establish a baseline.Assistant
Let me check the Go environment.
Assistant
Let me set up Go environment properly.
Assistant
Need GOCACHE too.
Assistant
Good, the existing tests pass. Let me also run FindClaudeSourceFile tests.
Assistant
Now let me create a reproduce script to confirm the issue, then fix it.
Assistant
The filename ends with _test.go so Go won't run it directly. Let me rename it.
Assistant
Can't use internal package from outside. Let me write a test within the package instead.
Assistant
Let me fix the import.
Assistant
Bug confirmed. Now let me implement the fix. First, let me look at the exact code sections I need to
Assistant
Now let me implement the fix. First, edit
DiscoverClaudeProjectsto walksubagents/recursively:Assistant
Let me use the heredoc syntax for multi-line editing
Assistant
Let me try using the heredoc syntax with the
editcommand:Assistant
I see there are leftover lines (375-378) from the old code. Let me check the full picture and clean up.
Assistant
I need to remove the leftover lines 375-378. Let me do that.
Assistant
Let me use sed to remove the leftover lines.
Assistant
Let me use sed to remove the leftover lines (375-378
Assistant
Let me verify the surrounding code now looks correct.
Assistant
The first fix looks good. Now let me fix
FindClaudeSourceFile. Let me look at the current code after the line number shift.Assistant
Let me look at the full
FindClaudeSourceFilefunction.Assistant
Now let me fix the
FindClaudeSourceFilefunction to recursively search undersubagents/.Assistant
Again, leftover lines. Let me remove them.
Assistant
I need to remove lines 499-501.
Assistant
Let me verify the full function now looks correct.
Assistant
The code looks correct. Let me now run the existing tests.
Assistant
All existing tests pass. Let me now run the full test suite for the parser package to make sure nothing else broke.
Assistant
The only failure is
TestParseCortexSession_SplitHistoryReadErrorwhich is a pre-existing failure in cortex tests (unrelated to our discovery changes). All discovery-related tests pass.Let me verify my changes are clean with a diff.
Assistant
The diff looks clean. Let me verify the code compiles correctly:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.