Skip to content

app: refresh a room seat's stall window on streamed output - #4977

Merged
ashhart merged 2 commits into
ashhart:mainfrom
devopsfortunato:task/Tensorfold-Contribut+t-mwv9q621-xmspev
Nov 25, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
devopsfortunato:task/Tensorfold-Contribut+t-mwv9q621-xmspev

Conversation

@devopsfortunato

@devopsfortunato devopsfortunato commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

  • Before: a Room seat's turn ran under a fixed three-minute wall clock (DEFAULT_SEAT_TURN_TIMEOUT_MS = 180_000) armed once when the turn began. A seat that was streaming a healthy reply was aborted mid-stream at three minutes and skipped, and a cold built-in-engine prefill that took longer than three minutes was aborted before its first chunk, even though the engine request itself allows ten minutes for a first byte (ENGINE_FIRST_BYTE_MS, app/electron/agent/engine/provider.ts:13). On a slow local model this ends the room's work early, which is what the issue reports.

  • After: the window is an idle stall watchdog.

    • Every chunk a seat's stream delivers, and every onDelta or onActivity callback of a CLI-backed seat, re-arms it, so a productive turn runs as long as it keeps producing output.
    • The first chunk gets its own window from seatFirstOutputWindow(provider, idleMs, roomBudgetMs): the built-in engine gets max(idle window, min(ENGINE_FIRST_BYTE_MS, room budget)), where the room budget is quick 2 min, normal 5 min or deep 15 min. The room budget only caps the engine's ten-minute allowance and never shortens the idle window, so Quick keeps the three-minute idle floor (seatFirstOutputWindow(engine, 180_000, 120_000) is 180_000, asserted in room-seat-runtime.test.ts). Every other provider keeps the idle window, and a non-finite or <= 0 window still means no watchdog.
    • A CLI transport that resolves cleanly on abort (as all five real ones do) is reported as timed out instead of being committed as an empty or truncated healthy turn.
    • A room stop no longer surfaces as a seat timeout: the room signal clears the timer, an already-aborted signal is honoured before the turn starts, and a timer can no longer fire or be re-armed after the turn has settled.
    • runCliSeatTurn gains an optional onActivity callback so reasoning and tool-progress chunks count as progress without being forwarded as content deltas; DEFAULT_SEAT_TURN_TIMEOUT_MS (180 s) and the room's own 30-minute abort in room-run-runtime.ts are unchanged.
  • Issue: Refs App: Tensorfold Desktop - Room end's its work prematurely #3415 (the healthy-turn and cold-prefill cuts this removes; whether other stop paths remain is not established here)

  • Stacked on: main

  • atc overlap --json: no overlap for this branch's files. The command reported complete: false with otherPullRequestsLimit, pullFilesLimit and listed entries only for my earlier pull requests (4918, 4939); atc who app/electron/agent/room-seat-runtime.ts --json reports no pull requests and no agents.

Checks on this head

  • Head commit: 9788427, rebased on main 3795e60.
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: base 165 problems, head 165 problems, 0 new (8070 files).
  • Tests run, with the command and pass, fail and skip counts:
    • node node_modules/jiti/lib/jiti-cli.mjs electron/agent/room-seat-runtime.test.ts (new file, 12 tests): 12 passed, 0 failed, 0 skipped.
    • With app/electron/agent/room-seat-runtime.ts and app/electron/agent/room-cli-seat.ts stashed, the same command fails 7 of the 12: the long-streaming, CLI-streaming, clean-resolve-on-abort, engine-first-byte, already-aborted-signal, seatFirstOutputWindow and non-content-activity tests. So the change is what makes them pass.
    • Adjacent suites still pass: electron/agent/rooms-run.test.ts (9 ok), electron/agent/room-cli-seat.test.ts (5 ok, 2 skipped because macOS sandbox-exec is unavailable on Linux), electron/agent/room-reasoning-effort.test.ts.
    • npm test on this branch: 901/903 on the final tree (900/903 on an earlier head). The two failures are not room-related and are load/environment flakes on a 4-core box: electron/agent/sandbox.test.ts (prompt SIGKILL escalation on maxBuffer overflow, took 11120ms) fails identically on a clean worktree of upstream main 3795e60, and scripts/settings-main-transaction.test.mjs (30 s spawnSync timeout) passes alone. CI runs the full suite on Linux and macOS and is green.
    • npm run typecheck: exit 0.
    • npm run verify:mobile: exit 0.
    • git diff --check: clean.
  • CI: all checks green (15 success, 2 skipped scheduled nightly jobs), merge state CLEAN.
  • Not run locally, and why: no GPU is involved and the native engine is untouched, so the GPU and engine checks are covered by CI only.

Receipt

  • n/a: this is a desktop-app scheduling change and cannot reach inference.
Kernel contract n/a, no GPU kernel changes.

Checklist

  • The title and description match the head commit.
  • New tests fail before the change, pass after it.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@AIFlowML

Copy link
Copy Markdown
Contributor

I reran the Room checks on 978842714044d3113f58062d044fe7683432e009 on Apple silicon with Node 22.23.3. From app/:

for suite in room-seat-runtime rooms-run room-cli-seat room-reasoning-effort; do
  node node_modules/jiti/lib/jiti-cli.mjs "electron/agent/$suite.test.ts" || exit
done

The 12 watchdog tests, nine Room runner cases, six CLI-seat cases and reasoning-effort suite passed. A test merge into main ed70f71aa7e561974dc4ec005e17fe64cba3d98a was clean. These were host checks with test transports, so a live model was outside the run.

One detail to clarify before landing: the description says Quick mode caps a built-in seat's first-output wait at the two-minute room budget, but seatFirstOutputWindow takes Math.max(idleMs, cap). The existing test explicitly expects seatFirstOutputWindow(engineProvider, 180_000, 120_000) to return 180_000. If preserving the default idle window is intentional, could you spell that out in the description? If Quick's two minutes should be a hard cap, that assertion is the smallest place to show the intended behavior.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you, @devopsfortunato. Streamed and CLI activity refresh the stall window, clean CLI aborts are classified correctly, and settled turns clear their timers. The focused results are recorded; this looks ready to land.

Please clarify the first-output wording: Quick keeps the three-minute idle floor even though its deliberation budget is two minutes. The tests already state that behavior.

  • Synthena

@devopsfortunato

Copy link
Copy Markdown
Contributor Author

Thanks, @AIFlowML and @ashhart. The Math.max(idleMs, cap) behavior is intentional: the room budget only caps the engine's first-byte allowance and never shortens the idle window, so Quick keeps the three-minute idle floor. I reworded the description to say so, and the existing assertion at room-seat-runtime.test.ts:231 already covers it. No code changes.

devopsfortunato and others added 2 commits November 25, 2026 18:54
The per-seat turn timer was a wall clock armed once per turn, so a seat
streaming a healthy reply was aborted at three minutes and a cold engine
prefill was cut before its first byte. Arm the first chunk with the
engine's own first-byte allowance (capped by the room's deliberation
budget) and re-arm the window on every streamed chunk, so only a seat
that stops producing output is skipped. A CLI transport that resolves
cleanly on abort is now reported timed out instead of committed as a
healthy turn.

Refs ashhart#3415
@ashhart
ashhart force-pushed the task/Tensorfold-Contribut+t-mwv9q621-xmspev branch from 9788427 to e1e7440 Compare November 25, 2026 18:54
@ashhart
ashhart merged commit c027c19 into ashhart:main Nov 25, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @devopsfortunato. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

3 participants