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 codebase
Assistant
Let me explore the internal directory and specifically the discovery.go file mentioned in the issue
Assistant
me look at the broader context and test file to understand the test patterns:
Assistant
Now let me look at the test for this function to understand the test patterns:
Assistant
Let me look at the function being called (
DiscoverClaudeProjects) and the DiscoveredFile type:Assistant
Now let me look at how filepath.WalkDir is used in the file:
Assistant
Let me check the structure of the discovery.go imports:
Assistant
Now let me first create a reproduction script to verify the bug:
Assistant
need to write the test within the project. Let me create a temporary test file inside the parser package:
Assistant
The file name starts with
_which Go ignores. Let me rename it:Assistant
I've successfully reproduced the bug. The deep workflow subagent file is missing from the discovery. Now let me fix the issue:
Assistant
Now I'll fix the code to walk recursively under
subagents/:Assistant
Let me use the proper format:
Assistant
Now let me add the helper function
walkClaudeSubagentDir:Assistant
Let me add the helper function
walkClaudeSubagentDirbeforeDiscoverClaudeProjects:Assistant
Now let me verify the changes look correct:
Assistant
Let me run the repro test to confirm it works:
Assistant
The fix works. Now let me run the existing tests to make sure I didn't break anything:
Assistant
All existing tests pass. Let me also run the wider discovery test suite:
Assistant
All discovery tests pass. Let me also run the broader claude-related tests:
Assistant
All Claude tests pass. Now let me think about edge cases and add a proper test for the workflow case:
Assistant
me think about edge cases:
agent-<id>.meta.jsonfiles (mentioned in the issue) - these are.jsonnot.jsonl, so my filterstrings.HasSuffix(name, ".jsonl")will correctly exclude them.- Files directly in
subagents/- still works because the walk covers depth 0 too. - Files in
subagents/workflows/<wf-id>/- the new fix handles this. - Files in deeper nesting, e.g.
subagents/workflows/<wf-id>/sub/<agent-id>.jsonl- also covered. - Missing subagents directory - the early
os.Statcheck returns gracefully.
Let me also verify that the
agent-<id>.meta.jsonfiles would not be matched, and look for any subagent-related patterns I should consider:Assistant
All edge cases handled correctly. Let me run the entire parser test suite to ensure nothing else is broken:
Assistant
There's a test failure but it's unrelated to my change (it's in cortex_test.go). Let me verify this is pre-existing:
Assistant
Confirmed - this failure is pre-existing and unrelated to my fix. Let me restore my changes:
Assistant
The test failure is pre-existing and unrelated to my change. Let me verify with git status and clean up my temporary test files:
Assistant
Now let me also check that I haven't missed any other discovery paths. Let me look for any other similar patterns I should update:
Assistant
me look at the engine.go to understand how the discovery result is used:
Assistant
This is a different code path used by the watcher. Let me look at the broader context:
Assistant
I see - the file watcher also has the same bug for deep-research paths. Let me also fix this:
Assistant
Let me fix the file watcher classification too:
Assistant
Now let me build and run tests to verify:
Assistant
Build succeeds. Now let me run sync tests:
Assistant
Now let me look at the test for
TestEngine_ClassifyOnePathClaudeStatPermissionErrorStillClassifiesto understand the test pattern and add a similar test for workflow:Assistant
me write a test that exercises the full workflow, including the engine's
classifyOnePath:Assistant
The classification also works correctly. Let me now also test the
DiscoverClaudeProjectsfunction with a larger scenario mimicking the real issue:Assistant
Excellent! 313 files discovered (1 parent + 312 workflow subagents), exactly as expected. Let me now also look for any watcher code that needs updating:
Assistant
me also check the workbuddy discovery for similar patterns:
Assistant
WorkBuddy is a different agent, so it's not affected by this issue. Let me clean up the temporary test files and run all the relevant tests one final time:
Assistant
Now let me run the full discovery and sync test suites (minus the unrelated cortex test failure):
Assistant
Only the pre-existing unrelated test fails. Let me also run sync tests:
Assistant
All sync tests pass. Let me also run the broader test suite to make sure nothing else is broken:
Assistant
the pre-existing unrelated
TestParseCortexSession_SplitHistoryReadErrortest fails. Let me verify by looking at the final state of my changes:Assistant
Both fixes look clean. Let me do one final verification:
Assistant
All tests pass. Let me also do a final check that my changes don't introduce any obvious issues with the symlink check. Let me also re-verify the build:
Assistant
No vet errors. Let me also do a final summary of my changes:
Assistant
Now let me run a final check and verify everything is good:
Assistant
All edge cases are correctly handled. Let me clean up my temporary test file:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.