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 this issue. The problem is that
DiscoverClaudeSessionsininternal/parser/discovery.goonly looks for subagent transcripts one level deep undersubagents/, but deep-research and workflow runs put them deeper atsubagents/workflows/<wf_id>/agent-<id>.jsonl. The fix is to walksubagents/recursively instead of just reading its top level.Let me start by exploring the repository structure and finding the relevant code.
Assistant
Good, this is a Go project. Let me find the discovery.go file mentioned in the issue.
Assistant
The user is trying to open a file. Let me check the correct syntax for the open command. Looking at the function definition, it seems like the arguments should be positional. Let me try a different approach - just use the file path.
Assistant
I need to use the
openfunction properly. Let me check how it works.Assistant
Let me look at the specific area around line 359 mentioned in the issue.
Assistant
Now I can see the problem clearly. Around line 359-365, the code reads
subagents/directory and skips any entry that is a directory (if sub.IsDir() { continue }). This means it never descends intosubagents/workflows/<wf_id>/where deep-research puts its subagent transcripts.Let me look at more context to understand the full function and see if there are any helper functions for walking directories.
Assistant
Now I understand the problem. The code at line 362 skips directories inside
subagents/, so it never finds files undersubagents/workflows/<wf_id>/. I need to walk thesubagents/directory recursively instead.Let me check if there are any existing helper functions or tests for this:
Assistant
Now I understand the test structure. Let me also check the
FindClaudeSourceFilefunction to see if it also has the same issue with nested subagent paths:Assistant
I see that
FindClaudeSourceFilealso has a similar issue — it only looks at the top level ofsubagents/. Let me now write a test to reproduce the issue, then fix it.Let me first run the existing tests to make sure they pass:
Assistant
Good, the existing tests pass. Now let me create a temporary test script to reproduce the issue — showing that nested subagent files under
subagents/workflows/<wf_id>/are NOT discovered:Assistant
This confirms the issue. Now let me fix the code. The fix needs to:
- In
DiscoverClaudeProjects: Instead of just reading the top level ofsubagents/, walk it recursively to findagent-*.jsonlfiles at any depth. - In
FindClaudeSourceFile: Also search recursively undersubagents/when looking for subagent files.
Let me look at the exact code I need to modify:
- In
Assistant
Now I'll replace the non-recursive
subFilesloop with a recursive walk. I need to usefilepath.Walkorfilepath.WalkDirto descend into subdirectories:Assistant
Now I'll make the replacement. I'll replace the non-recursive loop with a
filepath.WalkDircall that recursively walks thesubagents/directory:Assistant
Now I need to replace lines 347-376 with a recursive version. Let me do it:
Assistant
I need to replace the non-recursive loop with a recursive walk. Let me use the edit command to replace lines 347-376 in the discovery.go file.
Assistant
I need to edit the file. Let me use the edit command properly with the file path and line range.
Assistant
Let me verify the change was applied correctly:
Assistant
Good, the change looks correct. Now I need to also fix the
FindClaudeSourceFilefunction which has the same issue — it only looks at the top level ofsubagents/when searching for subagent files. Let me check the current state of that function:Assistant
I see the issue. In
FindClaudeSourceFile, the subagent search (lines 459-483) only checks the exact path<project>/<session>/subagents/agent-<id>.jsonlwithout recursing. I need to make it search recursively undersubagents/as well.Let me also check the line numbers more carefully:
Assistant
Now I need to replace lines 458-485 to walk recursively under
subagents/:Assistant
Wait, I used a closure with a
resultvariable that I didn't declare. Let me check what the code looks like now:Assistant
I need to declare the
resultvariable. Let me fix this by adding a proper variable declaration. I'll rewrite the code section to use a simpler approach - just return from within the walk callback:Assistant
Now let me verify the code compiles and the existing tests still pass:
Assistant
Good, it compiles. Now let me run the existing tests:
Assistant
All existing tests pass. Now let me write a temporary test script that validates the new nested subagent discovery works correctly:
Assistant
The logic works correctly. Now let me run the full test suite for the parser package to make sure nothing is broken:
Assistant
All the tests related to my changes pass. The only failing test is
TestParseCortexSession_SplitHistoryReadErrorwhich is a pre-existing failure unrelated to my changes. Let me verify this by checking if it was failing before my changes:Assistant
Yes, the
TestParseCortexSession_SplitHistoryReadErrorfailure was pre-existing and unrelated to my changes. Let me restore my changes:Assistant
Now let me verify the diff of my changes to make sure everything looks correct:
Assistant
Now let me verify the changes are clean and submit:
Assistant
Let me now go over the checklist from the issue:
Checklist Review:
-
If an error was reported in the issue description, I have successfully reproduced it.
- Yes. I created a test script (
/tmp/test_nested_discovery.go) that demonstrated the old behavior only finds direct subagent files (1 file) while the recursive approach finds all nested files (11 files: 1 direct + 10 nested underworkflows/directories).
- Yes. I created a test script (
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.