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 start by exploring the repository structure and understanding the codebase, then locate the relevant code mentioned in the issue.
- Assistant
Let me find the discovery.go file mentioned in the issue.
- Assistant
Let me open and examine this file:
- Assistant
Let me scroll down to find the relevant section:
- Assistant
Let me search for "subagents" in the file.
- Assistant
Let me look at the code around line 352:
- Assistant
Let me open the file at the relevant line:
- Assistant
Let me check if there are any tests for this discovery function:
- Assistant
Let me look at the test files to understand the test structure.
- Assistant
Let me look at the discovery test file.
- Assistant
Let me scroll down to see more of the test file:
- Assistant
Now let me look at the actual discovery code more carefully to understand how to fix it.
- Assistant
Let me look for the main discovery function name.
- Assistant
Let me look at the full function definition and the surrounding code.
- Assistant
Now I understand the issue clearly. The function
DiscoverClaudeProjectsscans for subagent files in thesubagents/directory, but it only looks one level deep. When it encounters a directory (likeworkflows/), it skips it withcontinueon line 360-361, so it never descends into subdirectories likesubagents/workflows/<wf_id>/.Let me check if there are any other similar patterns in the codebase:
- Assistant
Let me check the code around line 461 to see if there's another reference to subagents.
- Assistant
I can see there's another function
FindClaudeSourceFilethat also has the same issue - it only looks one level deep in thesubagents/directory (line 480). This function also needs to be fixed to recursively search for subagent files.Let me create a test to reproduce the issue first:
- Assistant
Let me create the file properly with bash.
- Assistant
Let me set up the Go environment properly.
- Assistant
Let me check the Go environment setup.
- Assistant
I need to set up the Go environment properly. Let me set HOME and GOPATH.
- Assistant
Good, now let me write a test that demonstrates the issue with nested workflow subagents. Let me add a test case to the existing test file:
- Assistant
I can see the existing test structure. Now let me add a test case for the nested workflow subagents. I'll add a new test case after the existing "Subagents" test case:
- Assistant
It seems the edit created a duplicate of the "Subagents" test case. Let me fix this.
- Assistant
I see there are still some issues with the edit. Let me look at the full context around lines 80-130 to understand the issue better.
- Assistant
I see the issue - there are syntax errors and duplicates. Let me fix this properly by replacing the whole block from line 80 to 134:
- Assistant
I see the issue - I'm missing the closing
}for the struct slice. Let me fix this: - Assistant
Good, now the test file looks correct. Let me verify it compiles and run the new test to confirm it fails (since the code doesn't handle nested subagents yet):
- Assistant
The test confirms the bug - it only finds 2 files (parent-session.jsonl and agent-top.jsonl) instead of the expected 5. Now I need to fix the code in
DiscoverClaudeProjectsto recursively walk through the subagents directory.Let me fix the discovery code:
- Assistant
Good! Now let me run the test again to see if the fix works:
- Assistant
Excellent! The test passes now. Let me run all the tests for the discovery function to make sure I didn't break anything:
- Assistant
All tests pass. Now let me also fix the
FindClaudeSourceFilefunction which has the same issue - it only looks one level deep in the subagents directory: - Assistant
I need to fix the
FindClaudeSourceFilefunction to recursively search through the subagents directory. The current code only looks for files at<project>/<session>/subagents/agent-<id>.jsonl, but we need to also search for files at<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl.Let me fix this by using
filepath.WalkDiror a helper function to search recursively. - Assistant
Good! Now I need to check if
filepath.SkipAllis available in the Go version used by this project. Let me check the Go version and if there's an alternative. - Assistant
Go 1.26.4 -
filepath.SkipAllwas added in Go 1.20, so it should be available. Let me check if the project has a go.mod that specifies a different version. - Assistant
Good, Go 1.26.3, so
filepath.SkipAllshould be available. Let me check if it compiles: - Assistant
Good! It compiles. Now let me run the tests for the
FindClaudeSourceFilefunction to make sure I didn't break anything. - Assistant
Let me run the tests for
FindClaudeSourceFile: - Assistant
Good! All tests pass. Now let me also add a test for the
FindClaudeSourceFilefunction to make sure it can find workflow subagents nested undersubagents/workflows/<wf_id>/. - Assistant
Let me find the TestFindClaudeSourceFile function to see what it already tests and then add a test for the nested workflow subagent case.
- Assistant
Let me look at the TestFindClaudeSourceFile function to understand its structure.
- Assistant
Good! I can see there's already a test for "Subagent" in the
TestFindClaudeSourceFilefunction. Let me add a test for "WorkflowSubagent" that tests finding a nested workflow subagent. - Assistant
I see the issue - the edit didn't close the previous test case properly. Let me fix this by replacing from line 255 to 278.
- Assistant
Good! Now let me run the test for
FindClaudeSourceFileto see if the new test passes: - Assistant
Excellent! All tests pass. Now let me run all the tests in the parser package to make sure I didn't break anything:
- Assistant
It says FAIL, let me check what tests failed.
- Assistant
There's a failing test
TestParseCortexSession_SplitHistoryReadErrorwhich is unrelated to my changes. Let me check if this test was failing before my changes by reverting them and running the test again. - Assistant
This is a pre-existing test failure unrelated to my changes. Let me verify by checking if it's already in the main branch:
- Assistant
The
TestParseCortexSession_SplitHistoryReadErrorfailure is pre-existing and not related to my changes. Let me run just the discovery-related tests to make sure everything I changed passes: - Assistant
All the discovery-related tests pass. Let me also check if there are any other tests in the repository that might be affected by my changes, particularly any tests that use the discovery functions.
- Assistant
Good, no other test files reference these functions. Let me now review the changes I've made:
- Assistant
The diff looks good. Let me now run a comprehensive test to make sure everything works correctly. Let me also check if there are any other discovery functions that might need similar updates.
- Assistant
Let me check if there are any other similar patterns in other discovery functions that might need fixing.
- Assistant
Good, I've updated both occurrences of the subagents discovery. Let me now run a broader set of tests to make sure nothing else is broken.
- Assistant
All discovery and find tests pass. Let me also run the full test suite for the parser package to make sure I haven't broken anything, excluding the pre-existing failing test.
- Assistant
Let me use single quotes for the regex.
- Assistant
Only the pre-existing failure shows up - all my changes are good. Let me also check if there are other tests that might indirectly use these discovery functions:
- Assistant
Good - just used for wiring. Let me verify the test file looks clean:
- Assistant
Good,
go vetpasses. Let me also check that the broader codebase tests pass (not just the parser package). Let me check if there are integration tests or other packages that use the discovery functions: - Assistant
Let me also quickly check if there's anything related in the sync package:
- Assistant
Let me check the sync engine for subagent path matching that might also need updating:
- Assistant
Let me search for where the sync engine processes Claude subagent paths, particularly looking for path splitting logic:
- Assistant
Let me check these occurrences to understand what they do:
- Assistant
I see! The sync engine also has the same issue at line 488 - it only handles paths with exactly 4 parts (project/session/subagents/agent-.jsonl), not 5 or more parts (project/session/subagents/workflows/wf_id/agent-.jsonl).
Let me check the other occurrences too:
- Assistant
I need to fix the sync engine code as well. Let me check the third occurrence at line 5590 and also understand the overall pattern.
- Assistant
I see - there are three places in the sync engine that need fixing:
- Line 488:
if len(parts) == 4 && parts[2] == "subagents"- for Claude subagent path matching - Line 726:
if len(parts) == 4 && parts[2] == "subagents"- for WorkBuddy subagent path matching - Line 5590:
if len(parts) == 2 || len(parts) == 4 && parts[2] == "subagents"- for WorkBuddy project extraction
These all need to handle nested workflow subagent paths like
project/session/subagents/workflows/wf_id/agent-*.jsonl.Let me fix these one by one.
- Line 488:
- Assistant
Good. Now let me fix the WorkBuddy subagent path matching at line 726:
- Assistant
Let me fix the WorkBuddy subagent path matching at line 727 to handle nested paths:
- Assistant
I see the issue - the edit removed the closing
}for theif len(parts) == 2 {block. Let me fix this by looking at the code more carefully. - Assistant
I see the issue - the closing
}forif len(parts) == 2 {is missing. Let me fix this properly: - Assistant
I see the issue - I'm still missing the closing
}for theif rel, ok := isUnder(workBuddyDir, path); ok {block. Let me fix this properly: - Assistant
I need to add a closing
}for theforloop. Let me look at the structure more carefully: - Assistant
I see the problem - the closing
}for theforloop is missing between lines 736 and 738. Let me fix this: - Assistant
Let me add a missing empty line before the Amp comment and fix the third occurrence at line 5590:
- Assistant
Good. Now let me fix the third occurrence - the project extraction for WorkBuddy:
- Assistant
Let me look at the context around line 5593 to fix it:
- Assistant
I need to update line 5593 to handle the nested workflow subagent case:
- Assistant
Good! Now let me verify the sync engine compiles:
- Assistant
Good! It compiles. Let me also run the sync tests to make sure nothing is broken:
- Assistant
All sync tests pass. Let me also run the full parser tests again to confirm everything is still good:
- Assistant
All tests pass. Let me now do a final review of all changes I've made:
- Assistant
Let me do a final comprehensive diff to review all changes:
- Assistant
The diff looks clean and correct. Let me do a final comprehensive test run to make sure everything passes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.