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
Let me look at the discovery file mentioned in the issue
Assistant
Let me see the specific section mentioned in the issue
Assistant
Now let me look at the test files for discovery to understand testing patterns
Assistant
Now let me look at the full DiscoverClaudeProjects function
Assistant
Let me check how workbuddy handles similar logic and look at related parser tests
Assistant
Let me look at the related claude subagent test for context
Assistant
Let me look at the rest of the discovery_test.go for context. Let me also see what's around line 1107 (cursor) and 1210 to understand the structure for similar
Assistant
me look at how claude parses subagent files to understand the pattern
Assistant
Now let me create a script to reproduce the issue first
Assistant
Let me look at similar directory walks in the codebase
Assistant
Now I have a clear understanding. Let me implement the fix:
Assistant
Now let me write the fix. I'll add a helper that walks the
subagents/tree recursively and use it both for discovery and for lookup:Assistant
me try a different approach with the edit tool
Assistant
Now let me add the
errorsimport to the file:Assistant
I need to add
errorsto the imports. Let me check the current state of the file and add theerrorsimport.Assistant
Now let me verify the file compiles and run the reproduction test:
Assistant
The fix is working. Now let me also verify the fix to
FindClaudeSourceFileworks correctly. Let me write a more comprehensive test:Assistant
All cases pass. Now let me clean up the test file and run the existing tests to make sure I didn't break anything:
Assistant
Existing tests pass. Now let me run the full parser tests to make sure nothing else broke:
Assistant
Let me check if this failure exists on the original code (pre-my-change):
Assistant
is pre-existing (not related to my changes). Let me run the full test suite to confirm:
Assistant
me look at the symlink test to make sure my change preserves symlink behavior:
Assistant
me verify the current state of the modified code:
Assistant
I notice there's an extra blank line. Let me clean that up:
Assistant
Now let me also build and run the wider tests:
Assistant
me look for any other places that might also be affected:
Assistant
Let me check the workbuddy subagent discovery more carefully:
Assistant
me check the watch code to ensure subagent file events are handled properly:
Assistant
This is important — let me check the file event handler:
Assistant
Yes, there's a path classification in
engine.gothat doesn't handle the nested workflow case. For deep-research subagents, the path would be:<claudeDir>/<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl- After
isUnder:<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl - Split:
["<project>", "<session>", "subagents", "workflows", "<wf_id>", "agent-<id>.jsonl"]— 6 parts!
So
len(parts) == 4doesn't match. We need to also handlelen(parts) == 6 && parts[2] == "subagents" && parts[3] == "workflows".Let me check the other place too at line 559
Assistant
Let me look at the broader function context:
Assistant
Let me look at the function that does path classification:
Assistant
Now I see the path classification. Let me look at where
classifyOnePathis called and see if I need to update it.Assistant
need to update the
classifyOnePathfunction to handle the nested workflow case:Assistant
Now let me build and test:
Assistant
All sync tests pass. Now let me look at the project derivation logic more carefully to make sure my changes don't break anything:
Assistant
me check how
processFilederives the project:Assistant
Let me look at the
processFilefunction for Claude to see how project is used in re-sync context:Assistant
Let me also improve the project derivation for subagent paths in
SyncSingleSessionContext. This ensures manual re-sync works correctly for subagent files too:Assistant
Now let me add the
claudeProjectFromPathhelper:Assistant
Let me add the
claudeProjectFromPathhelper right afterfindContainingDir. I need to be careful — the helper needs access toe.agentDirs[parser.AgentClaude], but the existing pattern inSyncSingleSessionContextfor WorkBuddy iterates overe.agentDirs. Let me make this a method on EngineAssistant
called it as a function but defined it as a method on Engine. Let me fix the call site:
Assistant
me check the existing tests in sync:
Assistant
Now let me look at the existing engine tests for subagent files to confirm there are tests for the shallow case at least:
Assistant
Let me re-create the reproduction test and run it through the sync engine as well:
Assistant
All checks pass. Let me also run the sync end-to-end test to confirm the full pipeline works:
Assistant
me also test the sync engine integration end-to-end. Let me look at the setup:
Assistant
Let me also add an end-to-end test using the existing test infrastructure:
Assistant
Let me create a comprehensive end-to-end test in the sync package:
Assistant
Let me clean up my reproduction test in the parser package:
Assistant
Now let me also look at the
assertSessionStateandrunSyncAndAssertpatterns used in the existing tests to make sure my fix works in the integration test flow:Assistant
Let me write a quick standalone Go program to verify the engine path:
Assistant
I need to put this test inside the repo since
internal/packages can only be used by the same module. Let me write it as a temporary file:Assistant
For Claude, IDPrefix is empty. Let me fix the test:
Assistant
Excellent! Everything works end-to-end. Let me also test the
SyncPathspath (file watcher simulation):Assistant
The SyncPaths path also works correctly. Let me also test SyncSingleSession:
Assistant
Let me also test the project derivation fallback in SyncSingleSession:
Assistant
The test result
real_project_nameshows my fallback correctly identifies the project asreal-project-name(which is then normalized byGetProjectName). Without my fix, this would have yieldedwf-1(the workflow group). Let me verify by looking at GetProjectName:Assistant
so
GetProjectNamenormalizes "real-project-name" to "real_project_name" viaNormalizeName. The fallback is correctly identifying the project. Let me clean up the temp test file:Assistant
Now let me also run the full test suite to confirm nothing's broken:
Assistant
the pre-existing TestParseCortexSession_SplitHistoryReadError failure remains (verified earlier as not caused by my changes). Let me also do a final check on the diff and formatting:
Assistant
Only the pre-existing cortex failure remains. Let me check the diff of my changes one more time:
Assistant
The diff looks clean. Let me also verify one more edge case with a comprehensive test:
Assistant
All edge cases pass. Let me also run the discovery tests once more to ensure stability:
Assistant
Only the pre-existing failure. Let me look at the diff one more time and verify the changes are minimal and correct:
Assistant
The fix is complete and working. Let me do a final summary of the changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.