Repository navigation
fix(executor): honor stop-after over pending pauses and carry it on resume - #8745
sudoKrishna wants to merge 1 commit into
Conversation
…esume Three changes for issue simstudioai#8661: 1. The engine now lets stop-after win over a pause still pending on another branch. Reaching the stop target completes the run and drops the pause points instead of returning 'paused' and persisting a resume that can never finish. (executor/execution/engine.ts) 2. stopAfterBlockId is rejected upfront when it targets a block that pauses (human-in-the-loop or wait). Such a target cannot be honored: the run pauses there and the resume path prunes its outgoing edges, so the stop target would be lost. (executor/utils/stop-after.ts, execution-core.ts) 3. stopAfterBlockId is persisted in the pause snapshot and passed back into the resumed run, so a run that pauses on another branch still ends after its original stop target. (execution/types.ts, snapshot-serializer.ts, human-in-the-loop-manager.ts) Tests: an engine case for stop-after vs a pending pause, a serializer case for the carried stop target, and unit coverage for the pausing-target check.
|
@sudoKrishna is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
|
| stopAfterBlockId: string | ||
| ): boolean { | ||
| const blockType = blocks.find((block) => block.id === stopAfterBlockId)?.metadata?.id | ||
| return isHumanInTheLoopBlock(blockType) || blockType === BlockType.WAIT |
There was a problem hiding this comment.
isPausingStopTarget rejects every wait block, including the default mode where async is off. In that mode, WaitBlockHandler sleeps in-process and returns status: 'completed' without _pauseMetadata, so the engine can honor the stop target normally. This guard makes previously valid run-until requests fail before execution. Reject only waits that suspend the run, and cover the synchronous case in the tests.
Problem
Two pre-existing bugs in
stopAfterBlockId(the--stop-after/ "run untilblock" feature), from #8661:
branch is paused at a human-in-the-loop block, the run returns
paused.Nothing downstream runs, before or after resume.
block, resuming continues past it.
Fix
1. Stop-after wins over a pending pause. The engine records that the stop
target was reached; at the end of the run it clears any pending pause points and
returns a completed run, so no unusable resume is persisted. Downstream of the
stop target still does not run, as intended.
2. A pausing stop target is rejected upfront.
stopAfterBlockIdthat targetsa human-in-the-loop or wait block cannot be honored — the run pauses there and
the resume path prunes the paused block's outgoing edges, so the target would be
lost.
execution-corenow rejects it with a clear message instead of starting arun whose stop target resume cannot keep. New helper
isPausingStopTargetinexecutor/utils/stop-after.ts.3. The stop target is carried across pause/resume.
stopAfterBlockIdispersisted in the pause snapshot and passed back into the resumed run, so a run
that pauses on a different branch still ends after its original stop target.
Tests
executor/execution/engine.test.ts— stop-after completes instead of pausingwhen another branch pauses;
statusis notpausedand no pause pointssurvive.
executor/execution/snapshot-serializer.test.ts— the stop target is writteninto the pause snapshot.
executor/utils/stop-after.test.ts— human-in-the-loop v1/v2 and wait targetsare rejected; normal blocks and unknown ids are allowed.
Existing coverage: 336 tests in
executor/execution+ the HITL manager passunchanged.
Closes #8661