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 to understand the
Assistant
Now I understand the issue. Let me look more closely at the discovery.go code around the
subagentsdirectory and find how to handle nested subagents. Let me also check the test file to understand the patterns being usedAssistant
Now let me look at the entire structure around lines 350-380 to better understand what needs to be modified:
Assistant
Now I understand the issue clearly. The
subFilesloop currently skips directories, but the issue is that deep-research/Workflow-tool sessions nest their subagent transcripts undersubagents/workflows/<wf_id>/agent-<id>.jsonl.Let me look at the structure of the issue better. Let me find any other relevant patterns:
Assistant
Let me check the test for the test case to understand how the test works
Assistant
Now I understand the issue clearly. Let me check the FindClaudeSourceFile function as well, since it might have a similar issue:
Assistant
Now let me check how
DiscoverClaudeProjectsis used elsewhere to understand the implications:Assistant
Now let me check the agentType field handling for subagents to see how it's used:
Assistant
Now let me check the AgentClaude handling in the parser to see if it auto-detects sidechain status:
Assistant
Good. The parser handles
isSidechaincorrectly. Now let me check if there's a project handling test for the new structure I need to understand. Let me first reproduce the issue with a small script:Assistant
Let me create a temporary module to test instead:
Assistant
write a test within the parser package itself:
Assistant
I've reproduced the issue. Now let me implement the fix. Let me look at the actual code one more time:
Assistant
Now I have a clear understanding. Let me implement the fix. I'll modify
DiscoverClaudeProjectsto walk recursively insidesubagents/, and also fixFindClaudeSourceFile:Assistant
Let me try with a different edit format:
Assistant
Let me try the replace method instead:
Assistant
Let me check the actual file content to see exactly what's there:
Assistant
The file uses tabs. Let me use sed to perform the replacement:
Assistant
Now I need to add the
walkClaudeSubagentFileshelper function. Let me add it before theDiscoverClaudeProjectsfunction:Assistant
I need to add
errorsto the imports:Assistant
Now let me update
FindClaudeSourceFilesimilarly to find nested subagent transcripts:Assistant
Now I need to add the
findClaudeSubagentFilehelper function. Let me place it next towalkClaudeSubagentFiles:Assistant
Now let me check that the file compiles correctly:
Assistant
The build succeeds. Now let me run the repro test to verify the fix:
Assistant
The fix works. Now let me clean up the temporary test and run the existing tests:
Assistant
There's a test failure. Let me look for it:
Assistant
This looks like an unrelated test failure. Let me check whether this failure exists in the unmodified code:
Assistant
Good, this failure is unrelated to my fix - it exists in the original code. Let me restore my changes:
Assistant
Now let me run only the tests for the discovery code to make sure my fix is correct:
Assistant
All the discovery tests pass. Now let me also test that the tests don't have any regressions. Let me check the symlink test since that's related to my changes:
Assistant
All Claude-related tests pass. Now let me think about edge cases:
- Symlinks - The original code uses
os.ReadDir(notisDirOrSymlink), so symlinks pointing to directories would be skipped. Let me check the behavior ofWalkDirwith symlinks - by default it does NOT follow symlinks. This is fine because original behavior was to skip them.
Wait, let me re-check. The original code uses
os.ReadDirand checkssub.IsDir(). If a symlink points to a directory,sub.IsDir()would returnfalse(because symlinks themselves aren't directories). So symlinks-to-directories would be skipped. WithWalkDir, the behavior depends on whether it's following symlinks. Let me check...Actually, the original behavior of skipping symlinks-to-directories is preserved with my fix because
filepath.WalkDirdoes not follow symlinks by default. Good.- A subagents directory with no agent files - This should work correctly (returns empty list).
- Deeply nested directories - This should work because
filepath.WalkDirwalks all levels.
- Symlinks - The original code uses
Assistant
All edge cases are handled correctly:
- 100 nested subagents under
subagents/workflows/wf-001/ - 1 direct subagent under
subagents/ - Ignored non-agent files (notes.txt, agent-no-suffix)
- Ignored non-agent files in nested subdirs
FindClaudeSourceFileworks for both direct and nestedFindClaudeSourceFiledoesn't return false positives for non-existent IDs
Now let me clean up the test file:
- 100 nested subagents under
Assistant
Let me also verify the discovery_test.go file's Subagent test continues to pass with the recursive walking logic, since that's important for backward compatibility. Let me also run all tests in the parser package except the one that's known to be broken:
Assistant
Only the pre-existing unrelated failure remains. All my changes are working correctly. Let me also look at the changes I made:
Assistant
Let me fix a misleading comment -
filepath.WalkDirdoes NOT follow symlinks by default:Assistant
Now let me also re-examine the
findClaudeSubagentFileto see if I can simplify it. Since the originalFindClaudeSourceFilewas iterating sessions looking for the agent file, but now we need to walk all subagents trees, the approach is correct.Let me also verify that
walkClaudeSubagentFileshandles errors gracefully (e.g., permission errors during walk). Looking at my code:err := filepath.WalkDir(...) if err != nil { return files }This is good - it returns whatever was collected before the error.
Let me verify one more time by running the relevant tests:
Assistant
All tests pass. Let me also run a broader set of tests to ensure I haven't broken anything:
Assistant
Same pre-existing failure - unrelated to my changes. Let me also look at the larger codebase to see if there are any other places I should check:
Assistant
Let me check the engine.go file for any other paths:
Assistant
Let me check the context to see if this could affect sync functionality:
Assistant
Let me check the callers of
classifyOnePathto understand the full sync flow:Assistant
This
classifyOnePathis used to filter paths in the file watcher. When a file is modified, the file watcher triggers a sync. TheclassifyPathsfunction takes a list of paths and tries to figure out which parser should handle them.For nested subagents (6 parts), this function would skip them since they don't match the 4-part pattern. Let me see if this affects the sync functionality:
The sync engine relies on
DiscoverClaudeProjectsto find all files initially. Then it usesclassifyPathsto handle file change notifications (e.g., when a new file appears in the subagents folder).Let me check the tests in engine_test.go to understand the relationship better
Assistant
This is just a classification test for direct session paths. The classifyOnePath function is used by the file watcher to determine if a changed path is a session file. Looking at this more carefully, when a file in
subagents/workflows/wf-001/agent-X.jsonlis modified, the file watcher would trigger classifyOnePath and we'd need it to return the file for proper sync.Let me check this:
Assistant
This is important - when a file is modified in a nested subagent directory (e.g.,
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl), the file watcher will triggerSyncPathswith that file path, butclassifyOnePathwon't recognize it because the path has 6 parts instead of 4.Let me look at the relevant code more carefully:
Assistant
Let me fix this classifier to recognize the nested path structure too:
Assistant
Now let me also check the comment for
claudeDir:Assistant
Builds fine. Now let me run the sync tests to make sure my changes don't break anything:
Assistant
All sync tests pass. Let me also run the parser tests one more time:
Assistant
Only the pre-existing unrelated failure remains. Let me also verify the classifier test still passes by running a broader set of tests:
Assistant
Now let me write a more thorough test script to verify everything works as expected, but I'll use a temporary test file that I won't commit:
Assistant
All 102 files discovered correctly:
- 1 direct subagent
- 100 nested workflow subagents
- 1 deeply nested subagent
.meta.jsonfiles correctly excludednotes.txtand other non-agent files correctly excluded
Now let me also write a test for the sync engine's path classifier:
Assistant
The sync classifier also works correctly for nested workflow subagents. Let me clean up the temp tests and run a broader test pass:
Assistant
Now let me run the entire test suite to make sure everything still works:
Assistant
Only the pre-existing failure (
TestParseCortexSession_SplitHistoryReadError) remains, which is unrelated to my changes. Let me also run the cmd tests to be thorough:Assistant
All cmd tests pass too. Let me also verify my changes by reading the final diff:
Assistant
Let me also do a sanity check for any other places that might reference subagents path patterns:
Assistant
There's another classifier at line 735. Let me check it:
Assistant
This is for
WorkBuddy, notClaude. Let me check whether WorkBuddy has the same nested subagent issue:Assistant
WorkBuddy is a different agent, not Claude. Let me check WorkBuddy's discovery code:
Assistant
me check the test for subagents classification in the integration tests to understand context:
Assistant
me run this specific test to make sure my changes don't break it:
Assistant
Let me also check line 5599 where there's another check:
Assistant
Let me look at where line 5599 is:
Assistant
are all 4-part subagent path tests. Let me verify they still work correctly:
Assistant
Let me run all the tests in the project that aren't integration tests:
Assistant
Only the pre-existing unrelated failure. Let me also do a final check on my code to look for any issues:
Assistant
Let me check the engine change one more time to verify my logic:
Assistant
Wait, there's a potential edge case I missed. What if the path is
<project>/subagents/agent-X.jsonl(i.e., 3 parts, not 4)? Withlen(parts) >= 4, this wouldn't match. But this case is for the main session pattern, not for the subagent pattern. Looking at the original code:Original:
// Subagent: project/session/subagents/agent-*.jsonl if len(parts) == 4 && parts[2] == "subagents" {So the original was
== 4for subagents. My change is>= 4. This handles:project/session/subagents/agent-X.jsonl(4 parts) ✓project/session/subagents/workflows/wf-id/agent-X.jsonl(6 parts) ✓project/subagents/agent-X.jsonl(3 parts) - would NOT match in either case, so behavior is preserved.
Good. My change only expands the matched paths.
Wait, but what about edge cases like:
project/session/subagents/agent-X.jsonl.bak(4 parts, as leaf)?
Assistant
All subagent-related sync tests pass. Let me also run the full set of sync tests to be sure:
Assistant
Excellent! All sync tests pass. Let me check the final diff one more time:
Assistant
The diff looks clean and minimal. Let me also verify there are no temporary files left:
Assistant
Let me make sure my changes are well structured and the test for the existing test file
TestDiscoverClaudeProjectswith the "Subagents" subtest still passes (this is the existing test that confirms the basic subagent discovery):Assistant
All existing tests pass. Let me also check that I haven't accidentally broken the linting:
Assistant
go vetpasses too. Let me also examine the final implementation one more time to ensure it's correct:Assistant
Now let me think about the checklist:
Checklist
-
[x] If an error was reported in the issue description, I have successfully reproduced it.
- I created a reproduction test (
/agentsview/internal/parser/repro_test.go) showing that the original code only discovered 1 file (the direct subagent), missing all 100 nested workflow subagents. The test passed after my fix.
- I created a reproduction test (
-
[x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- After my fix, the same reproduction test discovered all 101 files (1 direct + 100 nested).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.