Skip to content

Commit ddab695

Browse files
committed
fix(session): skip fresh-turn reset wholesale for parked queues, pin vote step
1 parent e84cda1 commit ddab695

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎packages/core/src/session/runner/llm.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,14 @@ const layer = Layer.effect(
147147
// keep the count of the turn that ran. Moves and compactions
148148
// carry the count across the handoff, and granted steers never
149149
// reach here (delivery "steer"). A queued prompt parked
150-
// behind a steer-only drain never promotes here either, so it
151-
// must not reset the count — otherwise every grant would see 0
152-
// and the per-turn cap would never apply.
150+
// behind a steer-only drain never promotes here either, so the
151+
// whole block is skipped: resetting would fake a new turn the
152+
// vote input cannot see (the parked vote must report the same
153+
// step and continuations as an idle vote after the same
154+
// history). The skipped entering/step resets are subsumed —
155+
// promotion re-sets step before any runStep, entering is
156+
// unobservable on this path, and captures are undefined
157+
// while !continuing.
153158
if (pending !== undefined) executedSteps = 0
154159
if (pending !== undefined && pending.type !== "move" && pending.type !== "compaction")
155160
stoppingContinuations = 0

‎packages/core/test/session-runner.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7082,11 +7082,13 @@ describe("SessionRunnerLLM", () => {
70827082

70837083
scenario("keeps the stopping cap when a queued prompt is parked behind a steer-only drain", function* (s) {
70847084
const seen: number[] = []
7085+
const steps: number[] = []
70857086
let grants = 0
70867087
const hooks = yield* PluginHooks.Service
70877088
yield* hooks.register("session", "experimental.stopping", (event) =>
70887089
Effect.sync(() => {
70897090
seen.push(event.continuations)
7091+
steps.push(event.step)
70907092
if (grants >= 3) return
70917093
grants++
70927094
event.decision = { shouldContinue: true, text: `Continue ${event.continuations}` }
@@ -7106,9 +7108,11 @@ describe("SessionRunnerLLM", () => {
71067108

71077109
// The parked queued prompt never promotes in a steer-only drain, so it
71087110
// must not reset the counter — otherwise every vote would see 0 and the
7109-
// cap of 2 would never apply.
7111+
// cap of 2 would never apply. The vote still reports the turn's actual
7112+
// model steps, exactly like an idle vote after the same history.
71107113
expect(result._tag).toBe("Complete")
71117114
expect(seen).toEqual([0, 1])
7115+
expect(steps).toEqual([1, 1])
71127116
expect(s.requests).toHaveLength(3)
71137117
})
71147118

0 commit comments

Comments
 (0)