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
I'll start by exploring the repository structure and understanding the current implementation before making any changes.
Assistant
Let me look at the discovery.go file mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> find /agentsview -type f -name "discovery.go" </tool_call>
Assistant
The user wants me to find the discovery.go file. Let me search for it properly.
Assistant
Got it. Let me now look at the discovery.go file.
Assistant
Let me see the full file, particularly around line 359 where the subagent discovery logic is:
Assistant
The file is 2105 lines. Let me look at the
DiscoverClaudeSessionsfunction around line 359:Assistant
Let me look at the relevant sections in detail:
Assistant
Let me see what's around line 952:
Assistant
Let me see the full
DiscoverClaudeSessionsfunction:Assistant
Now I understand the issue. The
DiscoverClaudeProjectsfunction at lines 352-376 reads thesubagents/directory and skips any subdirectories (includingworkflows/), so files nested deeper likesubagents/workflows/<wf_id>/agent-<id>.jsonlare never discovered.Let me check for existing tests related to this:
Assistant
Let me look at the test files to understand how subagent discovery is tested.
Assistant
Let me check the discovery_test.go for existing subagent tests:
Assistant
Let me look at the existing test and the
FindClaudeSourceFilefunction:Assistant
Let me look at the
FindClaudeSourceFilefunction and theAgentTypedefinitions:Assistant
Let me check the AgentType definitions:
Assistant
Let me look at the taxonomy.go file to understand AgentType definitions.
Assistant
Now let me check the types.go file for AgentType definitions:
Assistant
Now I have a clear understanding. Let me look at the test helpers to understand how to create a proper test:
Assistant
Now I have a complete understanding of the issue. Let me:
- First create a reproduction script to confirm the bug
- Then apply the fix to make
DiscoverClaudeProjectswalksubagents/recursively - Also fix
FindClaudeSourceFileto find files in nested directories - Verify existing tests still pass
Let me first create a reproduction script:
Assistant
The user wants me to run the reproduction script to confirm the bug. Let me try to run it. I need to first check the go module name to understand the import path.
Assistant
The user wants me to run the reproduction script to confirm the bug exists. Let me move it to the correct location in the repository and run it.
Assistant
Let me just put it in the current directory structure and run it. Let me first check the cmd/testfixture structure.
Assistant
The user wants me to run the reproduction script. Let me put it in a valid location and run it.
Assistant
Now let me fix the import path to match the module:
Assistant
Now let me run the reproduction script to confirm the bug:
Assistant
Let me set the GOMODCACHE and GOPATH environment variables to run the Go module properly.
Assistant
Let me set the missing environment variables and run the reproduction script:
Assistant
The reproduction confirms that files aren't being discovered. But notice that even the top-level session file isn't found, which means the directory structure might not match what the function expects. Let me check what path
DiscoverClaudeProjectsexpects - it takes aprojectsDir, so it should be the parent of "my-project". Let me fix the test:Assistant
Interesting - not even the top-level session file is discovered. Let me debug by checking if the function is reading the directory correctly. Let me run the existing tests to make sure the basic function works:
Assistant
The existing tests pass. Let me debug why my test script finds nothing - I need to trace through the issue more carefully.
Assistant
I see the issue with my test - I'm passing the project directory directly, but
DiscoverClaudeProjectsexpects a directory containing project directories. Let me fix the test:Assistant
I've confirmed the bug - the 4 files nested under
subagents/workflows/are not discovered. Now I'll implement the fix.Let me first look at the full
DiscoverClaudeProjectsfunction andFindClaudeSourceFileto understand the exact changes needed:Assistant
Now let me look at the
FindClaudeSourceFilefunction completely to understand what needs to change there too:Assistant
Let me see the full FindClaudeSourceFile function:
Assistant
Now I understand both functions. Let me implement the fix. I'll create a helper function for recursively walking the subagents directory, and update both
DiscoverClaudeProjectsandFindClaudeSourceFile.Assistant
Let me look at the exact lines I need to modify in both functions:
Assistant
Now I have a complete understanding of the code. Let me implement the fix:
Plan:
- Create a helper function
walkSubagentFilesthat recursively walks thesubagents/directory and finds allagent-*.jsonlfiles - Update
DiscoverClaudeProjects(lines 347-378) to use this helper instead of just reading one level - Update
FindClaudeSourceFile(lines 460-490) to also search recursively insubagents/
Let me make the changes:
- Create a helper function
Assistant
I'll use the
editcommand to replace the subagent scanning logic inDiscoverClaudeProjects. Let me first open the file to see the exact lines:Assistant
The user wants me to replace the subagent scanning logic in
DiscoverClaudeProjectsandFindClaudeSourceFileto recursively walk thesubagents/directory. Let me use the edit command properly this time, being careful with the indentation and syntax.I'll:
- Add a helper function
walkSubagentFiles - Replace the flat loop in
DiscoverClaudeProjects(lines 347-377) to use the helper - Replace the flat loop in
FindClaudeSourceFile(lines 460-490) to also walk recursively
Let me first add the helper function, then replace the two locations.
- Add a helper function
Assistant
Let me first look at the exact lines I need to edit:
Assistant
Let me add the helper function first, inserting it right after
DiscoverClaudeProjectsends (after line 383):Assistant
Let me use the
editcommand properly. I need to:- Replace lines 347-377 (the flat subagent scan loop) with a call to a new helper function
- Insert the new helper function after DiscoverClaudeProjects
- Update FindClaudeSourceFile to also walk recursively
Let me be very careful with the indentation. The code uses tabs for indentation.
Assistant
Now let me use the
editcommand to replace lines 347-377 with a call to a new helper function:Assistant
Let me try a different approach using the
editcommand with a heredoc:Assistant
The user wants me to fix the subagent discovery issue. The previous attempts to use the
editcommand failed because the tool couldn't extract the command properly. Let me try a different approach - I'll usesedto make the changes to the file, or use theeditcommand with proper heredoc syntax.Let me first look at the exact content of the file around the lines I need to modify, and then use
sedor a different approach.Assistant
The user wants me to fix the nested subagent discovery issue. Let me try a different approach using
sedto modify the file directly.Assistant
Let me try a different approach - I'll write the new helper function and the replacement code to a temp file, then use
sedto make the changes:Assistant
Let me verify the changes were applied correctly:
Assistant
Let me verify the changes look correct:
Assistant
Let me verify the FindClaudeSourceFile changes:
Assistant
The changes look good. Now let me run the existing tests to make sure nothing is broken:
Assistant
Existing tests pass. Now let me run the reproduction script to confirm the fix resolves the issue:
Assistant
All 6 files are now discovered, including the nested subagent files. Let me run the full test suite for the parser package to make sure nothing else is broken:
Assistant
There's a test failure. Let me see which test failed:
Assistant
Let me check if this test failure is related to my changes or pre-existing:
Assistant
Let me check if this test failure is pre-existing by reverting my changes temporarily and running the test:
Assistant
The
TestParseCortexSession_SplitHistoryReadErrorfailure is pre-existing (happens even without my changes). Let me restore my changes and run the full parser test suite (excluding that pre-existing failure):Assistant
Good - the
TestParseCortexSession_SplitHistoryReadErrorfailure is pre-existing and unrelated to my changes. Let me now run all tests excluding that one to confirm my fix doesn't break anything:Assistant
All discovery-related tests pass. Let me also test some edge cases with my reproduction script - specifically testing that symlinks to directories work correctly and that the code handles edge cases:
Assistant
Let me fix the test script -
filepath.Containsdoesn't exist, I should usestrings.Contains:Assistant
All tests pass, including edge cases. Let me verify the final changes and clean up the temporary test script:
Assistant
The changes look correct. Let me run the existing tests one more time to confirm everything passes, then clean up:
Assistant
All tests pass. Let me clean up the temporary test script:
Assistant
Let me verify the final state of the changes before submitting:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.