fix: deliver leftover /steer as out-of-band user message (#60543)#60555
Open
rainbowgore wants to merge 1 commit into
Open
fix: deliver leftover /steer as out-of-band user message (#60543)#60555rainbowgore wants to merge 1 commit into
rainbowgore wants to merge 1 commit into
Conversation
…usResearch#60543) A /steer that lands after the final assistant turn — with no remaining tool batch to drain into — is returned as result["pending_steer"] and delivered as the next user turn. Both delivery sites forwarded it as raw text, so the model received bare /steer text instead of the [OUT-OF-BAND USER MESSAGE] marker the mid-batch and pre-API drain paths use. On the gateway path, a steer whose text starts with "/" could additionally be swallowed by the slash-command discard net. Add format_leftover_steer_for_delivery() beside the existing steer helpers and route both consumers (cli.py, gateway/run.py) through it. Tests: tests/run_agent/test_steer_leftover_marker.py (6 cases) cover both paths, the marker contract, and the gateway slash-command net. 52 passing across the steer, concurrent-interrupt, tui-gateway-queue and turn_finalizer suites.
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
/steermessage being lost / delivered without its trust marker when it arrives after the final assistant turn./steerhas three delivery paths. Two wrap the user's message in the[OUT-OF-BAND USER MESSAGE]marker so the model treats it as a genuine user instruction rather than tool output / prompt injection (apply_pending_steer_to_tool_results, and the pre-API drain inconversation_loop.py). The third — the "leftover" path, taken when a steer lands after the final assistant turn with no remaining tool batch to drain into — did not.turn_finalizer.pyhands the raw steer back asresult["pending_steer"], and both consumers delivered it verbatim as the next user turn, so the model saw bare/steertext instead of the marker.On the gateway path there was a sharper failure: its downstream slash-command discard net drops any pending text starting with
/, so a leftover steer whose text begins with/(e.g. steering with/stop the search) was silently discarded. Wrapping it in the marker means it no longer starts with/, so it survives and is delivered.Approach: add one shared helper next to the existing steer helpers and route both consumers through it, rather than duplicating the wrap at each call site.
Related Issue
Fixes #60543
Type of Change
Changes Made
agent/agent_runtime_helpers.py— addformat_leftover_steer_for_delivery()(format_steer_marker(text).strip(); the marker is the whole standalone message here, so the append-oriented leading newlines are stripped) and export it.cli.py— CLI REPL leftover handler now deliversformat_leftover_steer_for_delivery(_leftover_steer)instead of the raw text.gateway/run.py— gateway leftover handler (TUI / Telegram / Slack / WhatsApp) routed through the same helper.tests/run_agent/test_steer_leftover_marker.py— new regression suite (6 cases).How to Test
/steer "..."so it lands after the final tool batch (the leftover window).[OUT-OF-BAND USER MESSAGE], not as raw/steertext — and that a steer beginning with/is delivered rather than silently dropped.Automated:
tests/run_agent/test_steer_leftover_marker.pycovers both delivery paths, the marker contract, and the gateway slash-command net. Each assertion was confirmed to fail against the pre-fix raw passthrough (red → green).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — CI Python tests green on Linux (amd64 + arm64); targeted steer/finalizer/gateway suites (52) pass locally on macOS.Documentation & Housekeeping
docs/, docstrings) — new helper is documented via docstring; no user-facing docs affected — or N/Acli-config.yaml.example)CONTRIBUTING.md/AGENTS.md)Screenshots / Logs
tests/run_agent/test_steer_leftover_marker.py— 6 passed. Fullpytest tests/ -qresult noted in the checklist above.