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 in
internal/parser/discovery.gowhereDiscoverClaudeSessionsonly looks for subagent transcripts one level deep undersubagents/ - Deep-research subagents are nested deeper:
subagents/workflows/<wf_id>/agent-<id>.jsonl - The current code skips directories, so it never descends into
workflows/ - The fix needs to walk recursively or specifically handle the nested structure
Let me start by exploring the repository structure and understanding the code.
- The problem is in
Assistant
Let me look at the discovery.go file mentioned in the issue.
Assistant
Let me read the discovery.go file to understand the current implementation.
Assistant
Let me look at the specific function
DiscoverClaudeSessionswhich is the one mentioned in the issue:Assistant
Let me see the
DiscoverClaudeSessionsfunction in more detail around lines 330-400:Assistant
Now I can see the issue clearly. Let me look at the full
DiscoverClaudeProjectsfunction and also check for any existing recursive walk utilities:Assistant
I can see the issue now. Let me look at the existing tests and also check if there's a recursive walk function already in use elsewhere:
Assistant
Let me also check for any discovery-related tests and understand the test patterns:
Assistant
Let me read the discovery test file to understand the testing patterns.
Assistant
Now I understand the issue and the codebase. Let me look at the
FindClaudeSourceFilefunction more carefully to see how it handles subagents:<tool_call> <function=bash_terminal> <parameter=command> sed -n '440,550p' /agentsview/internal/parser/discovery.go </tool_call>
Assistant
Let me look at the FindClaudeSourceFile function to understand how it searches for Claude session files.
Assistant
Now I understand the issue completely. Let me create a test script to reproduce the issue, then fix the code.
Assistant
Let me write a proper test to reproduce the issue directly:
Assistant
Let me write a proper Go test to reproduce the issue and run it:
Assistant
The issue is that the filename contains "_test" which Go treats as a test file. Let me rename it.
Assistant
The issue is that $HOME is not set. Let me set it or use a different approach.
Assistant
The bug is confirmed. The current code only discovers 1 subagent file (top-level), but the fixed version discovers all 6 including the 5 nested workflow subagent files.
Now let me implement the fix. I need to modify two places:
DiscoverClaudeProjects- the discovery loop that skips directoriesFindClaudeSourceFile- the lookup function that also doesn't handle nested subagents
Assistant
Now I can see the exact code. Let me modify the
DiscoverClaudeProjectsfunction to usefilepath.WalkDirinstead of the single-levelos.ReadDirthat skips directories:Assistant
The edit didn't work because of the quoting issue. Let me try a different approach using the heredoc syntax.
Assistant
Let me try using a bash command to make the edit instead:
Assistant
Let me use sed to make the replacement:
Assistant
Let me create the new section and then concatenate the files.
Assistant
Let me continue building the replacement file by adding the rest of the original file after line 382.
Assistant
Let me verify the new file looks correct:
Assistant
Let me review the output more carefully. The file looks correct - the old subagent scanning loop has been replaced with the new
filepath.WalkDirbased approach. Let me verify the complete file compiles correctly and then also fix theFindClaudeSourceFilefunction to handle nested subagent paths.Actually, let me first check if the closing brace is correct. Looking at the output, I see:
code} } // DiscoverCodexSessionsThe extra
}at line 382 corresponds to the closing brace of thefor _, sf := range sessionFilesloop. Let me verify the line count matches.Original lines 347-382 had:
- Line 347:
// Scan session directories for subagent files - Lines 348-381: the loop body
- Line 382:
}closing the for loop - Line 383:
}closing the outer for loop - Line 384: blank
- Line 385:
sort.Slice(...)
Wait, I need to check if I have the right line numbers. Let me check what line 382 and 383 contain in the original file.
- Line 347:
Assistant
Let me verify the line count and structure is correct:
Assistant
The line counts match. Let me verify the structure around the change is correct:
Assistant
The file structure looks correct. Now let me copy it over and also check the
FindClaudeSourceFilefunction which needs the same fix:Assistant
Let me check the
FindClaudeSourceFilefunction which also handles subagent file discovery:Assistant
I need to also fix the
FindClaudeSourceFilefunction, which has the same limitation - it only searches one level deep undersubagents/. Let me update that too:Assistant
The subagent lookup in FindClaudeSourceFile (around line 460-485) also only goes one level deep. I need to replace it with a WalkDir version to find nested workflow subagent files too.
Assistant
Let me fix the
FindClaudeSourceFilefunction with a better approach that actually captures the full path:Assistant
Let me fix the
FindClaudeSourceFilefunction with a proper approach. I need to be more careful about the file construction.Assistant
Let me continue building the fix for
FindClaudeSourceFile. I need to add the rest of the original file (the closing braces and the rest of the function) and then append the remaining code.Assistant
Let me verify the fix for
FindClaudeSourceFilelooks correct and check the whole file compiles:Assistant
The user wants me to continue fixing the
FindClaudeSourceFilefunction. Let me verify the new file is correct and then check if it compiles properly.Assistant
Let me trace through the issue more carefully. I need to look at the line numbers around line 486 in the original file to understand what I'm replacing.
Looking at my previous output:
- Line 455-458: The first loop (top-level project search)
- Lines 460-485: The subagent lookup (the part I need to fix)
- Line 486: The closing
return ""and}ofFindClaudeSourceFile
The issue is that I need to:
- Keep lines 1-458 (up to the end of the first for loop)
- Replace the subagent lookup section (lines 460-485)
- Keep lines 486+ (the
return ""and closing braces)
Let me check what's at line 485 and 486 in the original:
Assistant
Let me check the current state of the file and understand what happened:
Assistant
I need to fix the FindClaudeSourceFile function to also walk subagents/ recursively. Let me first check the current state of the file, then make a precise fix.
Assistant
I need to fix the
FindClaudeSourceFilefunction. Let me create the replacement carefully.Assistant
Let me check the current state of the file and make a proper fix for the
FindClaudeSourceFilefunction.Assistant
Let me check the current state of the discovery.go file and understand what line numbers I need to modify for the
FindClaudeSourceFilefunction.Assistant
Let me look at the current state of the file to understand what needs to be changed in
FindClaudeSourceFile. The subagent lookup in this function (lines 460-488) still uses the old one-level deep approach withos.Stat. I need to replace it with a recursive walk.Let me check the exact line range to replace:
Assistant
The file is currently at 2105 lines. I need to fix the
FindClaudeSourceFilefunction (lines 460-488) to also walk subagents/ recursively. Let me build the replacement properly.Assistant
Let me verify the replacement looks correct:
Assistant
The replacement looks correct. Let me now verify the file compiles properly and then copy it over. First, let me check if there are any variable name conflicts:
Assistant
The file looks correct. Now let me copy it over and verify it compiles:
Assistant
Let me investigate the syntax error:
Assistant
There's a syntax error - let me check the structure around line 385:
Assistant
Assistant
I see the issue. Let me examine the current file to understand the structure:
Assistant
I see the issue - there's a duplicate closing brace because my replacement text included the outer loop's
}and then I appended from line 383 which also had the outer loop's}. Let me reset and fix this properly.Assistant
Let me reset and fix this more carefully. I'll use the
editcommand with proper handling of the indentation.Assistant
Now let me carefully rebuild the fix. The issue is that the subagent scanning loop starts at line 347 (the comment) and ends at line 379 (the closing
}of the inner for loop). Line 380 is the closing}of the outer for loop.Assistant
The user is showing me a syntax error in the code. Let me analyze what's wrong. The error is:
codeinternal/parser/discovery.go:387:6: syntax error: non-declaration statement outside function bodyThis happens at the line
return files[i].Path < files[j].Path. Let me look at the file structure to understand why this is happening.The problem is likely that I have an extra closing brace that's closing the function too early, causing the
returnstatement to be outside of the function body.Let me check what's around line 387 in the current file.
Assistant
Let me examine the problematic area in detail:
Assistant
Let me reset the file and do this more carefully by examining the exact structure of the original file.
Assistant
Let me start fresh and be more careful. Let me first understand the exact structure of the original file:
Assistant
Now I can see the exact structure. Let me fix this carefully:
- Lines 347-376: The subagent scanning loop (to be replaced)
- Line 377:
}closes thefor _, entry := range entriesouter loop - Lines 379-383:
sort.Slice,return files, function close
I need to replace only lines 347-376, keeping line 377 onwards intact.
Assistant
The file structure looks correct now. Let me copy it over and verify it compiles:
Assistant
The
DiscoverClaudeProjectsfix compiled. Now I need to also fixFindClaudeSourceFilewhich has the same issue. Let me check the current state of that function:Assistant
I need to fix the
FindClaudeSourceFilefunction to also walk the subagents directory recursively. Let me replace lines 466-493 with a recursive walk version.Assistant
The structure looks correct. Let me copy the file over and verify it compiles:
Assistant
The code compiles successfully. Now let me verify the fix works by running my test script and the existing tests.
Assistant
My simulation confirms the fix works. Now let me run the existing tests to make sure I haven't broken anything:
Assistant
All the relevant tests pass. Let me now run all the parser tests to make sure nothing else is broken:
Assistant
There's a test failure. Let me check what failed:
Assistant
The test failure is
TestParseCortexSession_SplitHistoryReadErrorwhich is unrelated to my changes - it's a test in the cortex_test.go file about reading errors. Let me check if this test was already failing before my changes.Assistant
The test failure is pre-existing and unrelated to my changes. Let me restore my changes:
Assistant
The test failure is pre-existing (it was failing before my changes). All the discovery tests related to my fix pass. Let me verify the fix more thoroughly by checking the git diff and creating a comprehensive test:
Assistant
The diff looks correct. Let me run the full test suite for the parser package to make sure nothing is broken:
Assistant
The only failure is
TestParseCortexSession_SplitHistoryReadError, which is a pre-existing issue unrelated to my changes. Let me also run the tests in other packages to make sure my changes don't break anything else:Assistant
All tests pass except for the pre-existing
TestParseCortexSession_SplitHistoryReadErrorfailure which is unrelated to my changes (it's incortex_test.go, not in any discovery-related test).Let me verify my fix handles edge cases properly by reviewing the code one more time:
Assistant
Let me review my changes and verify everything is in order before submitting.
Assistant
The user wants me to submit my changes. I've successfully fixed the issue by:
-
Modifying
DiscoverClaudeProjectsto usefilepath.WalkDirinstead ofos.ReadDirfor subagent discovery, which allows it to find nestedagent-*.jsonlfiles insubagents/workflows/<wf_id>/paths. -
Modifying
FindClaudeSourceFileto usefilepath.WalkDirfor finding nested subagent files.
All existing tests pass (except for a pre-existing unrelated failure in
TestParseCortexSession_SplitHistoryReadError). The fix correctly handles the deep-research workflow subagent discovery issue.Let me 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.