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 recursive walk of subagents directory using filepath.WalkDir instead of os.ReadDir to allow nested workflows dirs.
Assistant
Now let's replace this block with a recursive walk using filepath.WalkDir.
Assistant
Now let's check that this file also handles subagent metadata elsewhere - maybe the parser that reads these files depends on path depth (e.g., session ID extraction from path). Let's check how subagent files are parsed later to see if nested paths break anything.
Assistant
Let's look at each occurrence in context to understand what they represent (Claude vs workbuddy vs something else).
Assistant
Now let's check other spots referencing "subagents" path depth of 4, particularly in discovery.go around line 470-490 (for something else, maybe reverse lookup).
Assistant
Now let's build the project.
Assistant
Build succeeds. Now let's run relevant tests.
Assistant
Confirmed this failure is pre-existing (running as root breaks permission-based test), unrelated to our change. Now let's run discovery-specific tests and sync engine tests.
Assistant
All relevant tests pass. Now let's write a quick reproduction script to confirm the fix works end-to-end for the exact scenario described in the issue.
Assistant
I'll put the repro script inside the repo temporarily (in the internal/parser dir but named non-test so go run works... actually go run still needs it under module). Let's place it as a small subdir under the repo root but not internal.
Assistant
All 5 files discovered correctly including the nested workflow subagents. Let's clean up the temp repro directory and files.
Assistant
Now let's run the full test suite for the sync package too, to make sure engine.go changes don't break anything.
Assistant
All sync tests pass. Let's also run the full test suite to be thorough.
Assistant
These failures are pre-existing environment issues (missing $HOME, running as root). Let's confirm by setting HOME and re-running.
Assistant
Confirmed — with
$HOMEset, config tests pass. The remaining failure (TestParseCortexSession_SplitHistoryReadError) is due to running as root (permission checks bypassed), also pre-existing and unrelated to our change.Assistant
All other tests pass; only the pre-existing root-permission test issue remains. Now let's view the final diff.
Assistant
The diff looks clean and comprehensive. Let's also check if there's a file watcher setup (fsnotify) that watches directories recursively — since new nested directories (workflows/<wf_id>/) need to be watched too, not just files matched by path.
Assistant
Good, existing test "Subagents" checks "not-agent.jsonl" is properly ignored — this still works since the filter checks name prefix agent- regardless of depth. Let's confirm this test passes.
Assistant
Now let's also check
TestFindClaudeSourceFilepasses and add a nested scenario is not required since I shouldn't add new tests, but let's verify existing tests still pass.Assistant
All good. Let's also check
internal/sync/engine_test.gofor any classifyOnePath tests related to subagents.Assistant
This all passed already. Let's do a final review of the diff and run gofmt.
Assistant
No formatting issues. Let's do one more full check to be safe: run parser and sync test suites once more with HOME set.
Assistant
This remaining failure is unrelated (permission test failing under root), confirmed earlier as pre-existing. Let's do final
git diffreview and submit.Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.