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
Now let's replace the subagent discovery loop with a recursive walk using filepath.WalkDir.
Assistant
Now let's check that
agent-filename parsing (used to derive agent ID / session grouping elsewhere) still works fine for nested paths - i.e., how these files get associated back to their parent session. Let's search for how subagent files are parsed/linked to sessions (e.g., by path pattern matching "subagents").Assistant
Let's inspect each occurrence to understand context (line 726 is workbuddy, 5590 is something else).
Assistant
Good, the watcher recursively watches all directories including new ones created (auto-watch on Create events), so nested subagents/workflows/<wf_id>/ directories will be watched automatically. That's fine, our fix to classifyPathFile in engine.go handles arbitrary depth already.
Now let's check the
discovery.gofile at line ~461 mentioned in issue for sessionID prefix logic, and other spots.Assistant
Go 1.26 is fine,
filepath.SkipAllis available. Now build.Assistant
Build succeeded. Now let's check now for other places related to workflow-subagent meta or session grouping - e.g. where subagent path pattern is used to derive parent session ID.
Assistant
Good — sessionID uses
filepath.Base(path), independent of depth. Now let's check the sync engine'sclassifyOpenCodePath, project derivation for Claude subagent files works fine since it just uses parts[0] (project name), unaffected by depth. Let's also check tests related to discovery to run them.Assistant
Now let's write a quick temp test/script that mimics the deep-research nested layout to verify the fix works end-to-end.
Assistant
Need to place it inside the module. Let's create a temp cmd dir within repo (will remove after).
Assistant
The nested discovery works. Let's clean up the temp cmd dir and run full test suite.
Assistant
Confirmed pre-existing failure unrelated to our change (root permission issue). Now let's run full parser tests excluding that one, plus sync engine tests.
Assistant
All discovery-related tests pass. Now run the sync package tests too.
Assistant
All sync tests pass. Let's run the full test suite to be safe.
Assistant
Only the pre-existing unrelated failure (root permission env issue) remains. Everything else passes. Let's review the full diff.
Assistant
The diff looks clean and correct. Let's also check
internal/sync/engine.goaround line 5590 area (project derivation for WorkBuddy) — not related to Claude, skip. Let's double check no other place references DiscoveredFile or subagents 4-part assumption for Claude specifically, e.g. in server or importer code.Assistant
These remaining ones (workbuddy.go, engine.go 730/5594) are for WorkBuddy, unrelated to the Claude issue. No other Claude-specific spots need change.
Assistant
No formatting issues. Let's go over the checklist:
Assistant
Confirmed: before the fix only 1 file was found (missing the nested subagent), after the fix 2 files are found (both parent and nested subagent). This confirms the bug reproduction and the fix.
Assistant
Everything looks good. Let's finalize with a checklist summary and submit.
Checklist review:
- ✅ Reproduced the error: confirmed with a temp script that nested
subagents/workflows/<wf_id>/agent-*.jsonlfiles were not discovered byDiscoverClaudeProjectsbefore the fix (only 1 of 2 files found). - ✅ Confirmed the fix resolves it: after the fix, both the parent session and nested subagent file are discovered (2 of 2 files found), and
FindClaudeSourceFilealso now locates the nested subagent by ID. - ✅ Edge cases considered: arbitrary nesting depth (not just one extra level for
workflows/<wf_id>/), missingsubagentsdirectory (skipped viaos.Statcheck), non-agent-*.jsonlfiles ignored,WalkDirerrors tolerated, and the live fsnotify-based watcher's path classifier (internal/sync/engine.go) updated similarly so newly created nested subagent files during a live sync are also classified correctly (the recursiveWatcher.WatchRecursive/auto-watch-on-create logic already handles watching new directories).
- ✅ Reproduced the error: confirmed with a temp script that nested
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.