fix: capture subagent parent edges end-to-end#242
Merged
Conversation
Claude Code names subagent JSONLs `agent-<17 hex>.jsonl` and nests Workflow-tool spawns under `subagents/workflows/wf_<id>/`; every record inside carries the parent's sessionId. The walker only accepted `agent-<uuid>.jsonl` directly under `subagents/`, so no real subagent file was ever imported — and adopting the embedded sessionId would have clobbered the parent row on upsert. Identity now comes from the filename stem and the parent edge from the directory above the innermost `subagents` component. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sessionToProto never set parent_session_id, so every edge the importers captured (codex thread spawns, hermes parents, claude-code subagents) was dropped at push time and the server stored NULL for every session — leaving the panel's subagent grouping and the Subagents insight empty. Bump ProjectionVersion to 11 so sync_reconcile re-pushes existing rows and the server learns the edges. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ojections Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t import Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The panel never grouped subagent sessions under their parents, and Insights → Subagents was always empty. The production Postgres had 0 parent edges across 3,570 sessions, while local stores were capturing them fine (226 on one device alone). Two independent bugs broke the pipeline:
sessionToProtonever mappedSession.ParentSessionIDonto the wire, so every edge the importers captured (codex thread spawns, hermes parents) died at sync time. This is what made already-linked codex children — e.g. fact-check fan-outs — show up flat in the panel.agent-<uuid>.jsonl, but real CLIs writeagent-<17 hex>.jsonl, and Workflow-tool spawns nest deeper atsubagents/workflows/wf_<id>/. Worse: every record in a subagent transcript carries the parent'ssessionId, so adopting it (as the parser did) would clobber the parent row on upsert.Fix
sessionToProtomapsParentSessionID→parent_session_id(the proto field and the server upsert already existed).agent-<id>), never the embeddedsessionId; the parent UUID is the directory above the innermostsubagentscomponent.ProjectionVersion10→11 sosync_reconcilere-pushes existing rows and the server learns the edges retroactively.Validation
just test-race), golangci-lint, gen-check, tidy-check, lint-md all green.~/.claude/projectsdata: claude-code went from 0 to 251/315 sessions linked as children (including a 145-child workflow fan-out), codex 196, hermes 31, zero orphan edges, parents intact.After release: run
prosa syncon each device — reconcile re-pushes and the panel grouping + Subagents insight light up for historical data too.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.