Repository navigation
fix(host): survive transient readiness stalls on loaded hosts - #1315
Merged
Merged
Conversation
A conversation whose journal shows no open run is the normal case, but the
startup recovery pass returned it as `Err("no interrupted run")` and logged
one line per conversation on every start; the summary then labelled the
candidate count "interrupted and eligible", so a healthy data root read as if
eight conversations needed attention. On a machine where `future tui` hosts
the Agent in-process those lines were written straight onto the TUI's
alternate screen.
- `resume_one` returns an `Outcome` (`Continued` / `NotInterrupted` /
`Held`) so a finished conversation is a silent skip instead of a failure;
`Err` is reserved for a real journal or session read failure
- the pass keeps a tally and emits one summary line only when something was
interrupted, reporting checked / interrupted / continued / left
interrupted / failed / skipped honestly
- the stale "default off" wording is corrected and the duplicated doc block
on `resumeInterruptedOnStart` is folded into the one that says on by
default
Tests cover the healthy (silent) start, the tally/summary, and that a
finished conversation settles as `NotInterrupted` without calling the model.
`future tui` may host the Agent in its own process, so `eprintln!` from the Agent and from the TUI's own supervisor is written to the terminal the TUI owns. Raw mode clears OPOST, so `\n` no longer returns to column 0; and the diff renderer never reads the screen back, so an external write staircases across the frame and the rows it paints afterwards land on the wrong ones. The witness was the startup recovery pass: one line per conversation over a freshly painted welcome screen. - `stderr_log` points fd 2 (POSIX) / the stderr handle (Windows) at `~/.future/tui/stderr.log` for as long as the alternate screen is up, and hands the real stderr back when the terminal is released - the crash hook restores stderr first, so its teardown sequences and the panic note still reach the terminal instead of the log; the signal failsafe and `Drop` restore it too - home the cursor when entering the alternate screen: terminals that keep the cursor row across `1049h` (tmux, for one) would otherwise shift the whole first frame down by the lines printed before the screen was taken - tests: capture/restore/double-restore, the temp-path wiring through `Terminal::start`/`stop`, and the default path under `~/.future/tui/`
A manual-approval run pushes a `System` row ("Allowed: Approve shell
command") into the transcript between a tool call and the text that follows
it. The assistant-text helpers only treated a trailing `Tool` message as the
start of a new assistant message, so the answer was appended to the run's
opening assistant message — above the tool calls and approval rows that
produced it. The user sees the final result at the top with the activity
below it.
- `append_to_last_message` and `update_last_message` start a new assistant
message when the transcript tail is this turn's activity (`Tool`/`System`);
a queued `User` prompt still belongs to the next turn and does not split
the running one
- regression tests at both layers: the chat-area ordering and the app's real
event sequence (agent_start → tool → "Allowed" row → text_chunk →
agent_end)
Measured on a `[manual]` HPC session: the partition table answer rendered
above the `read`/`sinfo` calls and their approval rows.
The host and embedded-Agent Tokio runtimes ran two workers each. The host runtime carries the session loop, the readiness probe, the remote bridge and the store; synchronous file I/O on the data root (session database, credential store, log file - an NFS home on a server) can park a worker in an uninterruptible write. With both workers parked the runtime cannot poll the probe's deadline, so a healthy Agent was reported as a timed-out handshake. Five workers keep the loop and the probe running while several blocking operations are in flight. The stack size and blocking-pool limits are unchanged.
probe_local_agent classified every non-transport failure as Blocked, including ConnectionError::Unverified("handshake timed out"), and every entry point treats Blocked as final. One probe whose 2 s deadline expired while the process was descheduled (a CPU quota on a login node, a page-fault storm, a synchronous write into a stalled shared home) therefore ended the host even though the Agent answered as soon as the process ran again. Retry Unverified answers up to READINESS_PROBE_ATTEMPTS (3) with 250 ms/500 ms/1 s backoff, each attempt on a fresh connection and deadline; definite answers (version/protocol mismatch, changed instance identity, refused start) are still reported immediately. The retry helper and the backoff/classification policy are unit-tested.
ace331
enabled auto-merge (squash)
October 23, 2026 03:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
On an HPC login node the headless host exited on its own:
There was no
received SIGINT/SIGTERM/SIGHUPline and the remote bridge was healthy (normal credential rotation, noauthorization violation); the exit came from the local Agent supervision loop.probe_local_agentclassified a single readiness-handshake timeout —ConnectionError::Unverified("handshake timed out")— asBlocked, and every entry point treatsBlockedas final. The host's data root (session database, credential store, log file, IPC socket) lives on a hard-mounted NFS home there, so a transient stall longer than the 2 s handshake deadline was enough to end the process; with nothing supervising it, the machine then stayed offline.Changes
fix(host): give the headless runtimes five workers(9603307)worker_threads(2)to 5 through one sharedRUNTIME_WORKER_THREADS.fix(host): retry a transient readiness probe with backoff(5c8d7bb)probe_local_agentretriesUnverifiedanswers up toREADINESS_PROBE_ATTEMPTS(3) with 250 ms / 500 ms / 1 s backoff, each attempt on a fresh connection and a fresh deadline.Blocked.Verification
cargo fmt -p future-rpc -p future-cli --checkcargo clippy -p future-rpc -p future-cli --all-targets -- -D warningscargo test -p future-rpc --lib: 226 passed. One environment-dependent test (transport::tests::an_endpoint_that_never_answers_is_bounded_by_the_connect_budget) fails identically on an unmodifiedmaincheckout on this machine because TEST-NET addresses are accepted through the local proxy; it is unrelated to this change and was skipped locally.python3 scripts/docs/check-docs.py: 321 docs OK.Behavior change
A single stall longer than 2 s no longer ends the host; only three consecutive failed probes (~7 s of unresponsiveness, including backoff) still report
Blockedand exit. Running the host under a supervisor (Restart=always) and keeping the data root off a stalled NFS share remain recommended operational hardening.