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:code<project>/<session>/subagents/agent-<id>.jsonland in that loop it skips any directory entry:
go// 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:
code<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.
Assistant
Let me analyze the issue. The problem is that
DiscoverClaudeSessionsininternal/parser/discovery.goonly looks for subagent transcripts one level down (<project>/<session>/subagents/agent-<id>.jsonl), but deep-research and workflow runs write them one level deeper (<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl). The current code skips directories, so it never descends into theworkflows/directory.Let me start by exploring the repository structure and finding the relevant code.
Assistant
Now I can see the problematic code at lines 359-375. It only reads the top level of the
subagents/directory and skips directories withcontinue. I need to walk it recursively. Let me also check the test file to understand the expected behavior.Assistant
Now let me look at the specific section I need to modify and understand the full context:
Assistant
Now I understand the problem. Let me create a test script to reproduce the issue first, then fix it.
Assistant
Good, existing tests pass. Now let me write a quick reproduction script that creates the nested
subagents/workflows/<wf_id>/agent-<id>.jsonlstructure and verify the current code doesn't find them.Assistant
Right, Go internal packages can't be imported from outside. Let me put the test in the right place.
Assistant
I've confirmed the bug: the test shows only 2 files are found (the parent and the top-level subagent), but the 3 nested workflow subagents are missing. Now let me fix the code by replacing the simple directory loop with a recursive walk.
The fix needs to walk
subagents/recursively to find allagent-*.jsonlfiles at any depth. I'll create a helper function or modify the loop to usefilepath.WalkDir.Assistant
I need to add
"io/fs"to the imports forfilepath.WalkDir(actually,filepath.WalkDiris inio/fsin newer Go but it's available directly frompath/filepath— let me check).Assistant
Good,
filepath.WalkDiris available directly. Now let me implement the fix. I'll replace the simple loop (lines 359-375) with a recursive walk usingfilepath.WalkDir.Assistant
Continued from where we left off. I need to fix the discovery.go file to recursively walk the subagents directory. Let me use the edit command to replace the non-recursive loop with a filepath.WalkDir call.
Assistant
Let me use sed to do the replacement, since the edit tool seems to need the file open first.
Assistant
Let me verify the changes look correct:
Assistant
The code looks correct. Now let me run the tests to verify both the new nested workflow test and the existing tests pass:
Assistant
All tests pass, including:
- The existing
TestDiscoverClaudeProjects/Basic,/Subagents,/Empty, and/Nonexistenttests - The new
TestDiscoverClaudeProjects_NestedWorkflowstest
Now let me run the broader test suite to make sure I haven't broken anything else:
- The existing
Assistant
All discovery tests pass. Let me also run the full test suite for the parser package to make sure nothing is broken:
Assistant
The one failing test (
TestParseCortexSession_SplitHistoryReadError) is incortex_test.go— unrelated to my changes. Let me verify it was already failing before my changes:Assistant
The test was already failing before my changes. Let me restore my changes:
Assistant
Good. The failing test is pre-existing and unrelated to my changes. Now let me clean up the test file I created (since I was told not to modify tests, and this is a new test file):
Assistant
Now let me verify the fix one more time by running the existing discovery tests:
Assistant
All existing tests still pass. Let me also verify the final state of my changes:
Assistant
The diff looks correct. Let me verify the code compiles and all relevant tests pass one final time:
Assistant
Everything looks good. Let me now submit the changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.