fix(acp): clear stale interrupted prompt when a new turn starts - #519
Open
hashbender wants to merge 1 commit into
Open
fix(acp): clear stale interrupted prompt when a new turn starts#519hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
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.
What does this PR do?
Fixes a state-machine bug in the ACP adapter where a
/steeron an idle session can resurrect a prompt the user cancelled and moved on from.state.interrupted_prompt_textpowers the "Zed-interrupt salvage" feature (replay an interrupted prompt when/steerarrives right after a client cancel, PR NousResearch#18258). But it is:cancel()— when a turn is actively running, and/steersalvage block.No other path clears it. So this sequence leaks a stale value:
"refactor the auth module". User hits ESC →cancel()storesinterrupted_prompt_text = "refactor the auth module". Turn ends."what's the weather". It runs to completion.interrupted_prompt_textis still"refactor the auth module"— the normal turn never cleared it./steer be conciseon the idle session. The salvage block sees the stale value as truthy and runs:"refactor the auth module\n\nUser correction/guidance after interrupt: be concise"as a real LLM turn.The user expected to nudge the current (nonexistent) turn; instead the agent silently re-executes an abandoned task from two turns ago.
Fix: clear
interrupted_prompt_textat the turn-start transition (whereis_runningflips toTrue), so starting any real turn drops the stale salvage buffer. The/steersalvage path already consumes and clears the field before this point, so legitimate immediate-salvage (steer directly after a client cancel, with no intervening turn) is unaffected.Related Issue
Fixes #
Type of Change
Changes Made
acp_adapter/server.py— inprompt(), setstate.interrupted_prompt_text = ""in theis_running = Trueturn-start transition.tests/acp_adapter/test_acp_commands.py—test_acp_normal_turn_clears_stale_interrupted_prompt: a running-cancel value is cleared by a completed normal turn, and a subsequent/steerruns only the steer text.How to Test
scripts/run_tests.sh tests/acp_adapter/test_acp_commands.py -q— 7 tests pass, including the existing salvage testtest_acp_steer_after_zed_interrupt_replays_interrupted_prompt_with_guidance.acp_adapter/server.pyhunk and rerun-k clears_stale→ the new test fails (interrupted_prompt_textstill holds the abandoned prompt, and/steerresurrects it); restore → it passes.Checklist
Code
fix(acp):)interrupted_prompt_text— none; open PR fix(acp): ignore idle cancel before next prompt NousResearch/hermes-agent#50461 touches idle-cancelcancel_eventpoisoning, a different field/path, and leaves this bug)Documentation & Housekeeping
docs/, docstrings) — N/A (inline comment explains the clear)cli-config.yaml.example— N/ACONTRIBUTING.md/AGENTS.md— N/Ascripts/check-windows-footguns.pyclean)Mirror-of: NousResearch#56624
NousResearch#56624