Skip to content

fix(agent): recover Terminus controls and exited shells - #3983

Draft
lafrancef wants to merge 3 commits into
mainfrom
flafrance/tb21-harness-reliability-20261003
Draft

lafrancef wants to merge 3 commits into
mainfrom
flafrance/tb21-harness-reliability-20261003

Conversation

@lafrancef

@lafrancef lafrancef commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

When a foreground process stops reading stdin, queued input can fill the terminal buffer and trap Ctrl-C behind a paste. Terminus then receives unchanged observations indefinitely. Adding a newline to a standalone control key also turns it into literal text, despite the parser suggesting that newline. If the interactive shell exits, including after an interrupt with set -e enabled, Harbor can return normally before the model declares completion.

Normalize standalone control keys, drain cancelled input until quiet before sending native Ctrl-C (with a five-second limit), and preserve raw-terminal input semantics. Report unchanged terminal buffers as the current screen, and fall back to Harbor token counting when model usage is absent. These fixes apply automatically to the existing Terminus agent configuration.

Preserve an exited shell's output and replace its PTY, discarding pending input and the remaining command batch. The model receives a notice describing the reset shell state and must confirm completion again. Task files and configured environment remain available. A missing tmux session fails explicitly. Shell replacement fails explicitly when terminal recording is enabled; the Gym agent already disables that recording.

Linux and live-sandbox reproductions cover blocked Ctrl-C, raw-terminal input, ordinary shell failure, and interrupts with set -e, including 32,768 queued commands. They verify that recovery retains files without executing pending input. A real Harbor-loop regression verifies that the model sees the reset notice before confirming completion. Model smoke rollouts for this revision are pending; this remains a draft until their agent and verifier traces are inspected. The regression reproductions are included here, so a separate issue is unnecessary.

Normalize standalone control keys, preserve raw-terminal input semantics, and avoid replaying unchanged terminal output as new. Fall back to token counting when a model response omits usage.

Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Read pending input until an idle interval instead of assuming one read window empties a large paste. Bound recovery to five seconds and retain raw-terminal key handling.

Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
Signed-off-by: Frederic Lafrance <flafrance@nvidia.com>
@lafrancef lafrancef changed the title fix(agent): unblock Terminus interrupts behind queued terminal input fix(agent): recover Terminus controls and exited shells Oct 3, 2026

This branch has not been deployed

No deployments
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