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 and understanding the codebase, then reproduce the issue, fix it, and verify the fix.
- Assistant
Let me look at the discovery.go file mentioned in the issue.
- Assistant
Let me open the discovery.go file.
- Assistant
Let me navigate to around line 359 to see the relevant code.
- Assistant
Let me scroll up to see the full function.
- Assistant
Let me look at the function more closely. I need to see the complete
DiscoverClaudeProjectsfunction. - Assistant
Let me view the function using sed to see lines 308-383.
- Assistant
Now I understand the issue. Let me check if there are existing tests for discovery.
- Assistant
Let me examine the existing discovery tests to understand the test patterns.
- Assistant
Let me look at the test file to understand the patterns used.
- Assistant
Let me see more of the test file to understand the pattern.
- Assistant
Let me first check the existing tests to see if there are already tests for this case, and then write a reproduce script.
- Assistant
Let me check the go environment setup.
- Assistant
Let me set up the go environment properly.
- Assistant
Let me try to set the environment properly.
- Assistant
Hmm, the output is empty. Let me try to see if there's a GOMODCACHE set somewhere.
- Assistant
Let me check if we need to set GOPATH.
- Assistant
The environment seems to be configured strangely. Let me try with explicit GOPATH.
- Assistant
Let me try a different approach - set the environment variable first.
- Assistant
Let me set HOME too.
- Assistant
Good, the existing tests pass. Now let me write a test to reproduce the issue first, then fix the code. Let me first create a test that sets up the workflow subagents directory structure to confirm the bug.
- Assistant
Let me rename the file to not have _test.go suffix.
- Assistant
Good, I can see the directory structure. Now let me write a quick reproduce test using the actual parser code to confirm the bug.
- Assistant
Let me look at the existing test structure more carefully and create a test case directly in the discovery_test.go to reproduce the bug.
- Assistant
Now let me implement the fix. The issue is in the subagent discovery loop that only reads the top level of
subagents/and skips subdirectories. I need to make it walk recursively. - Assistant
Now let me implement the fix. I'll replace the subagent discovery loop to walk recursively into subdirectories.
- Assistant
Good, the fix looks clean. Now let me run the existing tests to make sure I didn't break anything.
- Assistant
All existing tests pass. Now let me add a test case for the workflow subagents to verify the fix.
- Assistant
Now let me add a test case for the "WorkflowSubagents" scenario. I'll add it right after the "Subagents" test case in the tests slice.
- Assistant
The edit looks wrong. Let me check the current state of the file around the Subagents test case.
- Assistant
I see the issue. The closing
},for the "Subagents" test case is missing. Let me fix it. - Assistant
Now I see there's a duplicate
{on line 95. Let me fix that. - Assistant
Now I see there's a duplicate
name: "WorkflowSubagents",on line 96. Let me fix that. - Assistant
Good, the file looks correct now. Let me run the tests to make sure everything compiles and works.
- Assistant
All tests pass. Now let me run the full test suite to make sure I didn't break anything else.
- Assistant
There's a FAIL. Let me see what test failed.
- Assistant
Let me find the actual failure.
- Assistant
The failure is in
TestParseCortexSession_SplitHistoryReadError, which is unrelated to my change. Let me verify this was already failing before my change. - Assistant
Good - the test was already failing before my change. This is a pre-existing issue, not caused by my changes. Let me restore my changes.
- Assistant
Good. Now let me run just the discovery tests to make sure all my changes pass.
- Assistant
All discovery tests pass. Let me also verify that the build compiles correctly and run a broader test suite.
- Assistant
Good, the build compiles correctly. Let me review the final changes I made.
- Assistant
The diff looks clean and correct. Let me verify that the existing tests pass and that the new test case passes.
- Assistant
All tests pass. Let me also run the broader test suite to make sure nothing else is broken.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.