Skip to content

mcp: verify_scene runs in steps, so a host can pause inside a long check - #1272

Merged
wass08 merged 1 commit into
mainfrom
mcp/stepped-verify
Nov 11, 2026
Merged

wass08 merged 1 commit into
mainfrom
mcp/stepped-verify

Conversation

@wass08

@wass08 wass08 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

verify_scene runs every check in one synchronous stretch. On a large building with the usage checks on that stretch is long: 16 to 18 seconds on an Apple-silicon Mac for a six-storey building of about 1,300 nodes, several times that on a small server. Nothing else on the server runs meanwhile, so a host's timers and I/O wait for it. author_scene ends with the same checks, so every conversion of such a building ends with that stretch, and a host that has to do something on a schedule while a call runs (renew a lock, answer a heartbeat) cannot.

#1271 let a host pause between the calls of a run_batch. This PR makes the checks themselves stop, so the pause reaches inside one long call:

  • verify_scene is written in steps (verifySceneSteps): it stops after each registered check, and the circulation measurement, which is most of the time, stops after each floor (measureUsageSteps, usageIssueSteps). verifyScene runs the same steps through in one go, so its answer is unchanged.
  • A batch stops inside a verify_scene call too, as well as after each call.
  • author_scene's closing checks pause on a host that gives the hook.
  • A registered check can answer in steps by returning a generator (SceneCheck.run); one that returns its findings works as before.

Measured through a host that pauses, on that building: the longest uninterrupted stretch of an author_scene call goes from 18.5 s to 2.8 s. The call takes the same time in total (22 s).

Renamed, since the hook is no longer about batches only: betweenBatchCalls is now betweenSteps (createPascalMcpServer, registerTools). RUN_BATCH_STEPS is now AGENT_OPERATION_STEPS.run_batch, beside AGENT_OPERATION_STEPS.verify_scene, and createBatchOperation is gone (AGENT_OPERATIONS.run_batch runs the steps through). The hook was added in #1271; a host that passes the old name has to rename it.

Is it safe? The same contract as #1271. Without the hook nothing changes: every call is uninterrupted. With it, other work of the host runs between the steps, so only a host whose scene no other call can reach meanwhile (a bridge of its own for each request) should give it. verify_scene reads the scene it was handed at its start. In author_scene the design is already written when the checks run, so on a host that serves concurrent calls on one bridge another call could change the scene before the report is made; that host leaves the hook out, as before.

How to test

  1. bun test in packages/core (7,186 pass) and in packages/mcp (1,531 pass).
  2. packages/core/src/agent-operations/verify-scene-typed.test.ts: taken a step at a time, verify_scene stops more than five times on a two-room scene and answers the report it answers in one go.
  3. packages/mcp/src/tools/paused-steps.test.ts (was run-batch-pause.test.ts): on a host with the hook, verify_scene pauses between its checks, a batch pauses inside a verify_scene call as well as after each call, and both answer what they answer without the hook.
  4. packages/mcp/src/tools/author-scene.test.ts: on a host with the hook, author_scene pauses during its closing checks and reports the same gate.

Ran locally: both suites above, biome check on both packages, check-types for the eleven affected packages. apps/editor's check-types did not run clean in my checkout for unrelated missing modules (react-scan, geist), so CI is the check for it.

Screenshots / screen recording

N/A — non-visual change

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

🤖 Generated with Claude Code


Note

Medium Risk
Renames a public host hook (betweenBatchCalls → betweenSteps) and changes how long checks are scheduled on the event loop; outcomes are intended to match inOneGo when the hook is omitted.

Overview
Long agent operations (verify_scene, run_batch, usage circulation checks, and author_scene's closing verify) are now expressed as resumable generators (Steps, AgentOperationSteps) with synchronous behavior unchanged via inOneGo.

Core: verifySceneSteps yields after each registered scene check (and nested generators, e.g. usage checks per measurement and per floor in measureUsageSteps). run_batch uses createBatchSteps with a stepped map so a batch can yield* inside calls like verify_scene. createBatchOperation and RUN_BATCH_STEPS are replaced by AGENT_OPERATION_STEPS (run_batch + verify_scene). SceneCheck.run may return either issues or a generator.

MCP: Host callback betweenBatchCalls → betweenSteps; shared tools route any stepped operation through pausedBetweenSteps (not batches only). author_scene awaits pauses during closing verifySceneSteps.

Hosts without the hook see no behavioral change; hosts with per-request scene isolation can let timers/I/O run between steps while preserving the same final results.

Reviewed by Cursor Bugbot for commit 2c3bb1f. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@wass08
wass08 merged commit 51bf407 into main Nov 11, 2026
9 checks passed
@wass08
wass08 deleted the mcp/stepped-verify branch November 11, 2026 20:28
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