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
I'll start by exploring the repository structure to understand the codebase and locate the relevant file mentioned in the issue (internal/parser/discovery.go around line 359). Let me first check what's in the current directory.
- Assistant
Let me look at the specific file mentioned in the issue: internal/parser/discovery.go.
- Assistant
Good, the file exists. Let me open it and look at the relevant section around line 359.
- Assistant
Let me scroll down to around line 359 to see the relevant code.
- Assistant
Now I can see the issue. The code at line 359-376 is scanning for subagent files but it's only looking at the direct children of the
subagentsdirectory. When it encounters a directory (likeworkflows/), it skips it instead of descending into it.Let me look at the broader context to understand the structure better and then fix the issue.
- Assistant
Now I understand the issue. Let me first create a test script to reproduce the problem and verify the fix.
- Assistant
Let me set up the Go environment properly.
- Assistant
Let me look at existing tests for the discovery functionality:
- Assistant
Let me read the discovery test file to understand the test patterns.
- Assistant
Now let me look at the full
DiscoverClaudeProjectsfunction to understand the complete structure: - Assistant
Let me look at the full function to understand the flow:
- Assistant
Now let me run the existing tests to make sure they pass before I make changes:
- Assistant
Now I understand the issue. The code at lines 359-375 iterates over files in the
subagents/directory and skips any directories (line 360-362). This means whensubagents/contains only aworkflows/directory (and no directagent-*.jsonlfiles), nothing gets discovered.The fix is to use
filepath.WalkDirto recursively search through thesubagents/directory foragent-*.jsonlfiles. Let me make the change: - Assistant
Now I need to replace the block from line 347 to line 376 with a version that recursively walks the
subagentsdirectory. Let me make the change: - Assistant
Good! Now let me run the existing tests to make sure they still pass:
- Assistant
Let me also write a quick test to verify the fix works for the workflow subagent case:
- Assistant
Can't use internal packages from outside. Let me add a proper test case to the test file to verify the fix:
- Assistant
Now I need to add a test case for the workflow subagent scenario. Let me add it right after the existing "Subagents" test case:
- Assistant
It looks like the test case insertion broke the structure. Let me check the file around that area:
- Assistant
I see the problem - the "Subagents" test case is missing its closing brace. Let me fix this:
- Assistant
I see the indentation is still wrong. Let me fix the closing of the wantFiles slice:
- Assistant
I need to fix lines 88-93 to properly close the "Subagents" test case:
- Assistant
Good! Now let me verify the test file compiles by running the tests:
- Assistant
All tests pass including the new "WorkflowSubagents" test. Now let me run the full test suite to make sure I haven't broken anything else:
- Assistant
There's a FAIL. Let me see what tests failed:
- Assistant
Let me search for specific FAIL output.
- Assistant
The failure is in
TestParseCortexSession_SplitHistoryReadError— let me check if this is a pre-existing failure unrelated to my changes: - Assistant
This test failure is in
cortex_test.goand is completely unrelated to my changes. Let me verify by checking git status: - Assistant
Let me confirm the cortex test was already failing before my changes:
- Assistant
The
TestParseCortexSession_SplitHistoryReadErrortest was already failing before my changes — it's a pre-existing issue unrelated to my fix. Let me now run all the discovery-related tests to verify they all pass: - Assistant
All discovery tests pass, including the new "WorkflowSubagents" test case. Let me also run the broader test suite to make sure nothing else is broken:
- Assistant
The only failure is the pre-existing
TestParseCortexSession_SplitHistoryReadErrortest which was already failing before my changes. All other tests pass. Let me now review my changes one more time to make sure they're correct:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.