Skip to content

fix: capture subagent parent edges end-to-end#242

Merged
upsetbit merged 4 commits into
masterfrom
fix/subagent-edges
Jun 12, 2026
Merged

fix: capture subagent parent edges end-to-end#242
upsetbit merged 4 commits into
masterfrom
fix/subagent-edges

Conversation

@upsetbit

@upsetbit upsetbit commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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:

  1. Push dropped the edge. sessionToProto never mapped Session.ParentSessionID onto 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.
  2. Claude Code subagents were never imported. The walker expected agent-<uuid>.jsonl, but real CLIs write agent-<17 hex>.jsonl, and Workflow-tool spawns nest deeper at subagents/workflows/wf_<id>/. Worse: every record in a subagent transcript carries the parent's sessionId, so adopting it (as the parser did) would clobber the parent row on upsert.

Fix

  • sessionToProto maps ParentSessionIDparent_session_id (the proto field and the server upsert already existed).
  • The walker accepts both subagent namings and the workflow nesting; the child's identity is the filename stem (agent-<id>), never the embedded sessionId; the parent UUID is the directory above the innermost subagents component.
  • ProjectionVersion 10→11 so sync_reconcile re-pushes existing rows and the server learns the edges retroactively.
  • Docs updated to describe the real layouts and the v10/v11 projection rows.

Validation

  • Full suite (just test-race), golangci-lint, gen-check, tidy-check, lint-md all green.
  • New table-driven tests pin identity + edge recovery for every observed layout (Agent tool, Workflow tool, old UUID naming, degraded non-UUID parents).
  • Sandboxed sync over real ~/.claude/projects data: 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 sync on each device — reconcile re-pushes and the panel grouping + Subagents insight light up for historical data too.

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

upsetbit and others added 4 commits June 12, 2026 01:01
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>
@upsetbit upsetbit merged commit 44480c1 into master Jun 12, 2026
5 checks passed
@upsetbit upsetbit deleted the fix/subagent-edges branch June 12, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant