fix(decision): account for responses received after cancellation

Merged
RU
9d ago
+38-1
  • A response completed in the cancellation race counted as a call but lost its returned tokens and actual model id while the step was still open.
  • Capture response accounting before refusing its cancelled value; cancellation still propagates untouched. This change does not retain provider responses received after the owning step has closed.

Verified

Ran it locally: yes.

Used the real budget recorder with a native AbortController, cancelled during the call, and verified that it rejects the late answer while retaining the returned tokens and served model. Existing text and executor tests pass without live model calls.

mainthis branch
Regression failsRegression and adjacent tests pass
RUN  v5.0.1 packages/decision


 Test Files  3 passed (3)
      Tests  90 passed (90)
   Start at  09:49:43
   Duration  512ms (transform 46%, import 37%, tests 15%, worker 1%)

The full repository pnpm check, changed package build, typecheck, and changed TypeScript lint pass. The full repository pnpm check passes on the pinned unchanged base with the complete frozen-lockfile install. Browser and mobile benchmark suites were not run; no live model calls were made.

Independent review follow-up: Accounting is retained for responses received while the owning step is open. Responses after step closure remain outside this change, preserving step ownership.