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.meta.json(agentType: workflow-subagent) is available alongside each transcript if the workflow grouping is worth surfacing in the UI.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /agentsview, current file: none) bash-$
Assistant
Let me analyze the issue. The problem is that
DiscoverClaudeSessionsininternal/parser/discovery.goonly looks one level deep in thesubagents/directory, but deep-research and workflow runs place subagent transcripts deeper atsubagents/workflows/<wf_id>/agent-<id>.jsonl. The fix is to walk thesubagents/directory recursively instead of just reading its top level.Let me start by exploring the repository structure and understanding the codebase.
Assistant
Let me look at the specific area around line 359 where the issue is reported.
Assistant
Now I can see the problem clearly. The code at lines 359-375 only reads the top level of the
subagents/directory and skips any subdirectories. Let me look at more context to understand the function better.Assistant
Now I understand the full context. The function
DiscoverClaudeProjectsscans session directories and theirsubagents/subdirectories. The issue is at lines 359-375 where it readssubagents/but only processes files at the top level, skipping directories (likeworkflows/).Let me also check the test file to understand the expected behavior and test data structure.
Assistant
Now let me look at the test cases for subagent discovery more closely.
Assistant
Now I understand the issue. Let me also check if there's a
filepath.WalkDiror similar recursive walk utility available in Go that I can use. The fix needs to walk thesubagents/directory recursively to findagent-*.jsonlfiles at any depth.Let me create the fix. I need to replace the loop that reads
subagents/at the top level with a recursive walk.Assistant
Now I need to replace the flat directory reading with a recursive
filepath.WalkDir. Let me create the fix:Assistant
Good,
path/filepathis already imported, which includesfilepath.WalkDir. Now let me apply the fix. I'll replace lines 355-375 to usefilepath.WalkDirfor recursive traversal of thesubagents/directory:Assistant
Let me verify the change looks correct:
Assistant
The indentation is wrong. The sed command didn't preserve the proper Go indentation. Let me fix this properly by rewriting the section with correct indentation:
Assistant
Let me use the edit command with proper indentation:
Assistant
Now I'll use the edit command to replace lines 355-375 with the recursive walk version. I need to be very careful with the indentation - the code is inside a
for _, entry := range entriesloop (2 tabs), thenfor _, sf := range sessionFiles(3 tabs), and the inner body needs 4 tabs:Assistant
The assistant needs to verify the changes made to the discovery.go file. Let me check the file to see if the replacement was successful.
Assistant
The replacement looks correct. Now let me verify the code compiles and run the existing tests.
Assistant
The Go module cache isn't set. Let me check the Go environment and set up the necessary environment variables.
Assistant
The code compiles successfully. Now let me run the existing tests to verify the fix doesn't break anything.
Assistant
Existing tests pass. Now let me create a test script to verify the fix handles the new nested
subagents/workflows/<wf_id>/path structure correctly.Assistant
Right, internal packages can't be imported from outside the module. Let me create a test file inside the parser package instead.
Assistant
Let me run the new tests to verify the fix works correctly.
Assistant
Now let me run all the discovery-related tests to make sure nothing is broken.
Assistant
All tests are passing. Let me run the complete test to see the full output and make sure everything passes.
Assistant
All discovery tests pass. Now let me remove the test file I created (since I shouldn't add new tests to the repository) and also run the broader test suite for the parser package to make sure nothing else is broken.
Assistant
Let me run the full parser test suite to make sure everything passes.
Assistant
The test failure
TestParseCortexSession_SplitHistoryReadErroris incortex_test.go— completely unrelated to my changes indiscovery.go. Let me verify this is a pre-existing failure by checking if it fails on the original code too.Assistant
The test failure is pre-existing and unrelated to my changes. Let me restore my changes and run the discovery-specific tests to confirm my fix is solid.
Assistant
Good. My changes are back. Let me verify all the discovery tests pass, and also run the Claude-related tests that might exercise subagent discovery.
Assistant
All tests pass. Let me also verify the change with a quick diff review and confirm the edge cases are handled.
Assistant
The diff looks clean and correct. Let me now think through the edge cases and verify my fix handles them:
-
Top-level subagent files still found: ✅
filepath.WalkDirvisits all files in the directory tree, including those at the root ofsubagents/. -
Nested workflow subagent files found: ✅
filepath.WalkDirrecursively descends into subdirectories likeworkflows/<wf_id>/. -
Non-existent subagents directory: ✅ If
subagentsDirdoesn't exist,filepath.WalkDirreturns an error, which the walk function handles by returningnil(continuing gracefully). Previously,os.ReadDirwould return an error andcontinuewould skip to the next session — nowfilepath.WalkDirreturns the error but we ignore it (_ =), and the walk callback handles errors by returningnil. This is equivalent behavior. -
Non-agent files ignored: ✅ The same prefix/suffix checks apply.
-
Files with wrong extension ignored: ✅ The
.jsonlsuffix check still applies. -
Project name preserved: ✅
entry.Name()is still used as the project name. -
Sorting preserved: ✅ The sort after the loop still applies to all discovered files.
Let me also verify that the error handling for a missing subagents directory still works correctly:
-
Assistant
The first test failed because I forgot to create the
projectdirectory. But the important testTestDiscoverClaudeProjects_MixedTopLevelAndNestedpassed, confirming both top-level and nested subagents are discovered. Let me clean up my test file and verify the existing tests still pass.Assistant
Now let me run the full discovery test suite one more time to confirm everything is working.
Assistant
All 36 discovery tests pass. Let me also verify the code compiles and check the final diff one more time:
Assistant
The build is successful. Let me check the final state of my change:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →