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
Let me explore the repository structure and find the relevant code.
Assistant
Let me look at the specific section about subagent discovery and understand it better.
Assistant
Let me see the full function around
FindClaudeSourceFileand understand it:Assistant
Let me look at the discovery loop section more carefully:
Assistant
Now let me check the existing tests for these functions:
Assistant
Now I understand the structure. Let me modify the discovery code to walk
subagents/recursively. First, let me updateDiscoverClaudeProjects:Assistant
Let me open the file at the relevant section and make the edit:
Assistant
Now I'll replace the inner subagent loop (lines 347-376) with a recursive walk using
filepath.WalkDir. Let me write a helper functiondiscoverClaudeSubagentFilesthat walks recursively.Let me make the edit.
Assistant
Now let me update
FindClaudeSourceFileto also look in nested workflow directories:Assistant
I'll update
FindClaudeSourceFileto walk thesubagents/directory recursively:Assistant
Let me improve the
FindClaudeSourceFilewalk to fully short-circuit using a sentinel error, which is cleaner than relying onSkipDir:Assistant
Now I need to define
errStopWalk. Let me add it near the top of the file:Assistant
Now let me build to check for compile errors:
Assistant
Build succeeds. Now let me run the existing tests for discovery:
Assistant
Existing tests pass. Now let me write a temporary test to reproduce the issue scenario and verify the fix:
Assistant
Now let me create a temporary reproduction test script:
Assistant
Both tests pass. Let me confirm the tests would have failed against the original code (reproducing the bug), by temporarily stashing my changes:
Assistant
The bug is confirmed reproduced in the original code and fixed by my changes. Now let me remove the temporary test file and run the broader parser test suite:
Assistant
Let me check whether
TestParseCortexSession_SplitHistoryReadErrorwas already failing before my change:Assistant
The cortex test failure is pre-existing and unrelated to my change. Let me run the discovery-related tests once more to confirm everything passes:
Assistant
Let me check if there are other places in the codebase that make similar path-depth assumptions about subagent transcripts (e.g., watch roots or path reconstruction):
Assistant
There's important path-classification logic in
internal/sync/engine.go. Let me examine it:Assistant
Let me look at the function signature and the area around line 5590:
Assistant
Let me look at where the Claude project derivation happens in the sync engine (around the switch statement):
Assistant
Let me find callers of
classifyOnePathand understand the live-sync flow:Assistant
Let me look at where
classifyPathsis called — likely from the watcher event handler.Assistant
Let me find the function containing the Claude project derivation switch and understand its purpose:
Assistant
So
SyncSingleSessionContextis the function around line 5438-5600. It re-syncs a single session by ID by finding its source file. Let me look at how it gets the path.Assistant
Let me look at the WorkBuddy section of
classifyOnePathand the broader engine logic:Assistant
Now let me update the Claude branch of
classifyOnePathto handle the nested workflow path:Assistant
Now let me update the Claude subagent branch in
classifyOnePathto handle the nested workflow path:Assistant
I introduced an extra closing brace. Let me view and fix:
Assistant
There's an extra
}at line 507. Let me remove it:Assistant
Now let me build and run the tests:
Assistant
Now let me verify the engine's
FindSourceFiledispatches toparser.FindClaudeSourceFilefor subagent IDs:Assistant
The
FindSourceFileflow already benefits from myFindClaudeSourceFilefix. Now let me run the sync engine tests:Assistant
Let me check existing sync tests related to Claude subagent classification to ensure consistency:
Assistant
Let me write a temporary test to verify
classifyOnePathhandles the nested workflow path, then remove it:Assistant
The classify test passes. Let me remove the temporary test:
Assistant
Now let me run the full parser and sync test suites once more (excluding the pre-existing cortex failure):
Assistant
Let me run the entire test suite to make sure nothing else broke:
Assistant
Let me check the sessionwatch module to ensure the watcher handles recursive dirs for Claude (so new
workflows/<wf_id>/dirs are caught):Assistant
Let me check how the fsnotify file watcher resolves Claude watch roots:
Assistant
Let me check the default exclude patterns to make sure
subagents/workflows/isn't excluded:Assistant
Let me check what exclude patterns are passed to the watcher for Claude:
Assistant
The default excludes don't affect
workflows/orsubagents/, so live sync will pick up nested workflow subagents. Let me review the final diff:Assistant
Let me verify formatting with gofmt:
Assistant
Let me run
go veton the changed packages and run the relevant tests once more:Assistant
Let me run a broader set of sync engine Claude tests to confirm nothing broke:
Assistant
Let me look at
TestSyncPathsClaudeRejectsNestedto make sure my generalization doesn't conflict with its intent:Assistant
Let me check for any tests referencing
workflowssubagent paths that might assert old behavior:Assistant
No tests reference
workflows. My changes are complete. Let me do a final review of the complete diff and confirm the build is clean:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.