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
I’ll inspect the repository structure and the discovery implementation/tests, then reproduce the depth-related omission with the project’s existing test conventions before making a focused recursive-discovery change.
- Assistant
The implementation confirms the exact one-level assumption: it reads
subagents/and discards directories. I’ll now read repository guidance and the existing discovery test setup to understand symlink/error-handling conventions and identify whether recursive walking should follow symlinked directories or remain confined to the physical subtree. - Assistant
Repository guidance requests unit tests, but the environment explicitly prohibits modifying or adding tests, so I will use a temporary external repro program instead and remove it afterward. The likely production fix is
filepath.WalkDirrooted at each session’ssubagentsdirectory: it naturally descends arbitrary workflow nesting, does not follow directory symlinks (avoiding escape/cycles), can skip unreadable subtrees, and preserves existing filename filtering and final sorting. I’ll inspect the focused tests/imports and all call sites before editing. - Assistant
Discovery is the affected sync entry point. I also noticed
FindClaudeSourceFilehas a subagent case; I’ll inspect it because recursive transcripts should remain locatable by session ID after import (for resume/source operations), and a matching depth assumption there could leave the feature only partially functional. - Assistant
FindClaudeSourceFilerepeats the same direct-child assumption, so I’ll update both paths to keep discovery and subsequent source lookup consistent. Before editing, I’ll reproduce the reported behavior with a temporary in-repository executable that creates one direct subagent and two workflow-nested subagents; the expected pre-fix result is that only the direct file is discovered and nested lookup fails. The temporary file will be deleted and never submitted. - Assistant
The repro did not compile because I used the wrong module path; this is only a harness issue, not the reported behavior. I’ll correct the import to the module declared in
go.modand rerun it. - Assistant
The environment has neither
GOMODCACHEnorGOPATHconfigured. I’ll supply a temporary conventionalGOPATHfor Go commands; dependencies may already be cached elsewhere, but Go can fetch them into/tmp/goif needed. - Assistant
Go also requires a build cache because this stripped environment has no
HOME; I’ll explicitly setHOME,GOPATH, andGOCACHEfor all validation commands. - Assistant
The repro now exactly matches the report: only 1 of 3 transcripts is discovered, and nested source lookup returns empty. I’ll add one internal walker that recursively visits valid
agent-*.jsonlfiles beneathsubagents/, ignores inaccessible/missing branches as the old code did, does not follow directory symlinks, and supports early termination for source lookup. Both discovery and lookup will use it. - Assistant
The scripted edit aborted safely before writing because the exact source-lookup comment differs from my marker. I’ll inspect that small boundary and then rerun the transformation with the correct marker.
- Assistant
I found the only mismatch (“by searching” rather than “across”). I’ll apply the same focused transformation with that corrected marker and format the Go file.
- Assistant
The change is in place and preserves the direct-file behavior while allowing arbitrary nesting. I’ll rerun the exact repro first; it should now discover all three files and return the nested transcript path. Then I’ll remove the temporary harness.
- Assistant
The repro is resolved: all three transcripts are discovered and nested lookup succeeds. The harness is removed, leaving only the production change. I’ll now run the focused parser test suite, including the existing Claude direct-subagent discovery/lookup tests, to verify backward compatibility.
- Assistant
The parser package compiles and runs, but its full suite has one unrelated environment-sensitive failure:
TestParseCortexSession_SplitHistoryReadErrorexpects a chmod-based read failure, while tests run as root here and can still read the file. I’ll run the focused Claude discovery and source-lookup tests explicitly to verify the changed behavior without that unrelated root-permission test. - Assistant
Focused tests pass. Per repository validation guidance, I’ll run
go fmt ./...andgo vet ./...with the required FTS5/CGO settings, then inspect status to ensure formatting did not touch unrelated files. - Assistant
go fmt ./...unexpectedly reformatted an existing integration test (the formatter printed its path), which is unrelated and tests must not be modified. The initial status was clean, so this is definitively generated by my command; I’ll inspect that diff and restore only that test file, preserving the intended production change. Vet completed successfully. - Assistant
Only
discovery.goremains modified andgit diff --checkis clean. Because recursive discovery feeds the sync engine, I’ll run the relevant Claude subagent integration tests (identified from their names) in addition to parser tests, ensuring direct subagent import and filtering remain intact. - Assistant
All relevant sync integration tests pass. I’ll perform a final review of the complete diff and repository status, checking for accidental files, malformed whitespace, and confirming the implementation only changes recursive Claude subagent handling.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.