fix(coding-agent): settle late compaction slices and forward daemon subagent lineage - #2021
Merged
sethkarten merged 1 commit intoSep 3, 2026
Merged
Conversation
…ubagent lineage resolveRuntimeSessionOptions now whitelists semanticParentSessionId and semanticSpawnedByRequestId, so sessions created through the production runtime factory (daemon workers, runtime hosts) register spawn lineage; the factory is extracted as createDefaultRuntimeFactory so the pin exercises the real path instead of a forward-everything test factory. A split-turn summary slice resolving after a sibling already failed the compaction now settles as request_failed instead of pushing into the drained slice list and staying in-flight forever.
sethkarten
self-requested a review
September 3, 2026 21:17
sethkarten
approved these changes
Sep 3, 2026
sethkarten
deleted the
fix/semantic-edges-settle-race-and-daemon-lineage
branch
September 3, 2026 21:18
This was referenced Sep 3, 2026
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.
What provenance consumers lose today
Two defects in the
ai.prime.acp/semantic-edges-v1producer (#1885), both found during review of #1984:semanticParentSessionId/semanticSpawnedByRequestIdcorrectly, but the production runtime factory rebuilds session options through theresolveRuntimeSessionOptions()whitelist — which did not include the two fields. Every session created through that factory (all daemon workers and runtime-hosted subagents) registered with no parent session and no spawning request, so nosubagent_calledge could ever be derived for them. Only the inline host, which bypasses the factory, produced complete lineage.Promise.all. When one slice rejects, the compaction settles as failed and drains the uncommitted-slice list; a sibling slice that resolves after that pushed its request ID into the already-drained list, leaving arequest_startedwith no terminal event. The fold treats such a request like a crash window (zero edges — no wrong edges are derived), but provenance under-claims a wire call that actually completed.The two mechanisms
resolveRuntimeSessionOptions()forwardssemanticParentSessionIdandsemanticSpawnedByRequestId(2 lines). The factory closure is extracted ascreateDefaultRuntimeFactory()—main()remains its consumer — so the new end-to-end pin exercises the real factory. The prior coverage asserted the fields on the options handed to mocked factories, upstream of the drop; that mock blindness is exactly how this shipped broken._compact()keeps acompactionSettledflag, set where the slice list drains (commit and catch). A summary slice whose wire call resolves after the compaction settled now settles its own request asrequest_failedinstead of pushing into the drained list. No restructuring of thePromise.allflow.Deliberate behavior notes
createDefaultRuntimeFactoryextraction is mechanical; behavior of the factory is unchanged except the whitelist addition.Validation
main-interactive-routing— whitelist forwards the two fields;suite/agent-session-runtime— a subagent created through the production factory registersparent_session_id/spawned_by_request_idand derives asubagent_calledge;agent-session-semantic-edges— a slice resolving after a sibling's failure settles asrequest_failed, never left in-flight (the whitelist pins were failed with only the 2 whitelist lines reverted, isolating them from the extraction)semantic-edges(52),agent-session-semantic-edges(23),suite/agent-session-compaction,suite/agent-session-compaction-continuation,daemon-mode(184),main-interactive-routing(53),suite/agent-session-runtime(26) — 387 tests, 0 failuresnpm run check(biome, tsgo, installer render, browser smoke) passes via the pre-commit hookLOC
Net src: agent-session.ts +9, main.ts +10/−0 effective (58+/48− is the factory extraction moving the closure body; the semantic delta is the 2 whitelist lines + the export wrapper). Tests +145, changelog +1. Classification: mechanism-preserving fixes — no new mechanism beyond the settled flag; the factory extraction is a move, not an addition.
Linear: RES-1261 https://linear.app/primeintellect/issue/RES-1261
Note
Medium Risk
Touches session compaction ledger semantics and subagent session creation on the daemon/runtime factory path; incorrect behavior under-claims provenance or leaves in-flight requests, but changes are narrow guardrails rather than new compaction or spawn flows.
Overview
Restores semantic spawn lineage for daemon- and runtime-hosted subagents by whitelisting
semanticParentSessionIdandsemanticSpawnedByRequestIdinresolveRuntimeSessionOptions(), so the production path can again register parent session / spawning request and derivesubagent_calledges. The daemon runtime factory closure is extracted as exportedcreateDefaultRuntimeFactory()(behavior unchanged aside from the whitelist);main()now calls that helper.Fixes a split-turn compaction race where a summary slice that finished after a sibling failure already drained
uncommittedSlicescould leave arequest_startedwith no terminal event._compact()trackscompactionSettledand marks such late slices as failed instead of enqueueing them after drain.Tests pin whitelist forwarding, end-to-end lineage through the real factory, and late slice settlement on the semantic-edges ledger.
Reviewed by Cursor Bugbot for commit d4ea4a0. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix late compaction slice settlement and forward subagent lineage in
AgentSessionAgentSession.compactso summary slices resolving after a sibling failure or after settlement are explicitly failed instead of left in-flight.semanticParentSessionIdandsemanticSpawnedByRequestIdfrom runtime session options into resolved options inresolveRuntimeSessionOptions, preserving spawn lineage for child sessions.mainintocreateDefaultRuntimeFactoryand replaces the inline closure with a call to it.createDefaultRuntimeFactoryis newly exported from main.ts; callers relying on the previous inline closure behavior should use the exported function.Macroscope summarized d4ea4a0.