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 analyze the issue. The problem is that
DiscoverClaudeSessionsininternal/parser/discovery.goonly looks one level deep in thesubagents/directory, but deep-research and workflow tools write subagent transcripts one level deeper atsubagents/workflows/<wf_id>/agent-<id>.jsonl. The fix is to walk thesubagents/directory recursively instead of only reading its top level.Let me start by exploring the repository structure and finding the relevant code.
Assistant
Good, I can see the Go files. Let me look at the discovery.go file that was mentioned in the issue.
Assistant
Let me look at the specific area around line 359 where the subagent discovery happens:
Assistant
Now I can see the issue clearly. The code at lines 359-363 skips directories, so it never descends into
subagents/workflows/<wf_id>/. I need to make it walk recursively. Let me see more context to understand the full function:Assistant
Now I understand the structure. The fix needs to change the subagent file scanning from a single-level
ReadDirto a recursive walk. Let me check if there's a helper function already for walking directories, or look at how other parts of the codebase handle recursive walking:Assistant
No existing Walk pattern. Let me also check if there are any tests for the discovery functions:
Assistant
Let me look at the existing tests to understand the test structure:
Assistant
Now I understand the test structure. I can see the "Subagents" test only tests the single-level case. Let me now implement the fix. I need to create a helper function to recursively walk the subagents directory and find all
agent-*.jsonlfiles.Let me first create a test script to reproduce the issue:
Assistant
Good, this confirms the issue. Now let me implement the fix. I need to modify the subagent scanning code in
DiscoverClaudeProjectsto recursively walk the subagents directory instead of just reading its top level.Let me look at the exact code block I need to modify:
Assistant
Now I need to replace the single-level
ReadDirloop with a recursive walk. I'll usefilepath.WalkDirto recursively find allagent-*.jsonlfiles under the subagents directory. Let me create the fix:Assistant
I need to use the correct syntax for the edit command. Let me try with the proper format.
Assistant
Good, the patch was applied. Let me verify the change looks correct:
Assistant
The change looks correct. Now let me run the existing tests to make sure I didn't break anything:
Assistant
All existing tests pass. Now let me run the full test suite for the parser package to make sure nothing else is broken:
Assistant
My apologies - I had an issue with my previous response. Let me continue checking the test results.
Assistant
The test failure
TestParseCortexSession_SplitHistoryReadErroris pre-existing and unrelated to my change (it's incortex_test.go, notdiscovery_test.go). Let me verify this by checking if this test was already failing before my change:Assistant
Confirmed - the test was already failing before my change. Let me restore my changes and run the discovery-specific tests:
Assistant
All discovery tests pass. Now let me create a temporary test script to verify my fix actually works for the nested workflow subagent scenario:
Assistant
The fix works correctly. Now let me verify the actual code change by looking at the diff:
Assistant
Let me also think about edge cases and check if there are any other similar patterns in the codebase that might need fixing:
Assistant
There's another occurrence at line 954. Let me check what that's about:
Assistant
This is in the Cursor session discovery code, which has a different, known directory structure (
agent-transcripts/<uuid>/<uuid>.{txt,jsonl}). This is a fixed one-level nesting, not like thesubagents/workflows/<wf_id>/which can have arbitrary depth. So this one doesn't need to be changed - it's intentionally single-level.Let me also run the broader test suite to make sure nothing is affected:
Assistant
The only failure is the pre-existing
TestParseCortexSession_SplitHistoryReadErrortest, which was already failing before my change (as I confirmed earlier). All other tests pass.Let me also verify that my code compiles correctly with no issues:
Assistant
The code compiles successfully. Let me clean up the temporary test files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.