fix(bash-timeout): native Anthropic bash exception + mutation-proof the detach gate - #426
Merged
Merged
Conversation
code-yeongyu
enabled auto-merge
July 28, 2026 09:02
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.
Summary
Follow-up to #422, fixing two real defects that post-merge review found. Both were confirmed against merged
mainbefore changing anything.1. Native Anthropic bash advertised a ceiling it could not honor
When
PI_ANTHROPIC_BASHis enabled for ananthropic-messagesmodel, the provider replaces the PTYbashtool and theterminalextension steps aside (shouldStepAside). Nothing then implements the cache-deadline auto-detach — butbash-timeoutstill capped the recommended maximum and told the model a still-running command would be handed to a background session. That promised behavior that could not happen.The budget is now suppressed on that path, restoring the byte-identical legacy policy. Failing test captured first, then fixed.
Also addressed from the same review:
kill_bash(detached sessions stay live, so the model needs to be told to reap them)docs/settings.mddocumentspromptCache.cacheAwareTimeoutsandpromptCache.safetyBufferSecondsbuiltin/bash-timeout/changes.mdadded, recording the fork surface and why the exception exists2. The detach linearization gate had tautological coverage
#422's auto-detach suite had 9 green tests but could not fail for the property it protected: deleting both the
queueMicrotaskdeferral and the settled-awareonExitgate fromforeground-detach.tsleft all 9 passing.Root cause: those tests register the exit/abort timers during spawn — before the detach timer exists — so they only exercise "exit was already ordered ahead of D", never the real window between the deadline firing and the queued linearization microtask committing.
test/suite/terminal-detach-gate.test.tsdrivescreateForegroundDetachGatedirectly with fake timers, so the deadline can fire without yielding the microtask queue:onExitdispatching synchronously at registration → exit stays authoritative (coversexitedAtGate)cancel()→ suppresses a pending detachMutation proof
queueMicrotask(linearize)deferralonExitgateThe gate itself was correct — it was simply unprotected.
Verification
npm run checkexit 0. Focused suites 65/65 (bash-timeout-extension, bash-timeout-handlers, terminal-detach-gate, terminal-bash-auto-detach, prompt-surface-stale-wait-idioms, prompt-cache-budget).