Repository navigation
fix(verify): coupled child state in predicates; child usage to the root - #225
Conversation
🦋 Changeset detectedLatest commit: 4a0763c The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
| if (stepping) { | ||
| const resolved = resolveStep(prev, id, output); | ||
| charges.set(resolved, usage); | ||
| return { step: resolved, completed: true }; |
There was a problem hiding this comment.
🔴 Cancelled child requests appear completed
When root usage cancels a child, settleStep has already resolved its request and advanced the child's state. canReach can report a child completion that the live run cancels before delivery.
Learn more
A text request reports usage to the root before its invocation completes in a live run. In coupled exploration, settleStep resolves the child's invoke first, and the move builder records that completion before forwarding usage. If the root leaves the invoking state on usage, the later child completion cannot occur in the live run, but the search has already recorded it and stepped the child. The root can also send the child an event on usage while the search sees it already finished.
Example: A worker's summarize request has an onDone transition to finished. The root's @agent.usage transition leaves the state invoking that worker on a high token count. A live run cancels the worker before summarize completes; coupled exploration records xstate.done.actor(s) and a finished worker before handling that token count.
Recommended fix: Stage each child text completion until its usage event has been delivered at the root. Recheck that the same child and request sessions remain active, then resolve the request and record its completion; discard the staged completion if usage cancels or restarts either actor.
Was this helpful? React with 👍 or 👎 to provide feedback.
Closes two proof gaps from round-10 greenfield trials (project-copilot, fanout-budget).
Coupled child state in predicates
children: "coupled", acanReachpredicate anddedupeBynow get a snapshot whosechildren[id].getSnapshot()returns the child's explored state (grandchildren likewise), not its initial snapshot.sent === child.nholds on every explored state.Child usage to the root
recordUsage→ root), so coupled exploration does the same.usageentry forks once per value. The usage event goes to the root before the child's completion reaches its parent. The root takes or drops it (active, declares@agent.usage,can), asdeliverUsageEventdoes. It shows on the path as the root receives it.vacuousfor a child request with no entry (the child can't see whether the root takes usage)."outputs"/"explore"children still deliver none.Tests
src/verify-coupled.test.ts: predicate sees spawned/invoked child moves, send+receipt atomic,dedupeByview, child-fed token budget provable, root without usage transition drops it, event shape matches a liverunAgent.pnpm -s check,pnpm -s docs:check,npx vitest run src(1318 passed).