The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): release rejected native clarifies before steering
loulanyuec1c3557723b1
diff --git a/gateway/run.py b/gateway/run.pyindex 00ec0536875..ee720f168e5 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -15933,7 +15933,7 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew# Intercept messages that are responses to a pending clarify.# Open-ended prompts and "Other" responses are captured as free text;# direct replies to multi-choice prompts are accepted too ("2" maps- # to the second option, arbitrary text becomes a custom answer). Slash+ # to the second option). Slash# commands still bypass this path so /stop and friends keep working._clarify_mod = Nonetry:@@ -15990,6 +15990,15 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew# the agent's response don't double-post. The agent# itself will produce the next user-facing message.return ""+ # Native-choice prompts deliberately reject unmatched prose+ # so it can continue through normal busy-message routing.+ # Release this clarify first: redirect() degrades to steer()+ # while tools are executing, and that steer cannot drain until+ # the clarify tool returns.+ _clarify_mod.resolve_gateway_clarify(+ _pending_clarify.clarify_id,+ "",+ )# Intercept messages that are responses to a pending /reload-mcp# (or future) slash-confirm prompt. Recognized confirm replies arediff --git a/tests/gateway/test_clarify_thread_followup_not_swallowed.py b/tests/gateway/test_clarify_thread_followup_not_swallowed.pyindex 9082727d1f7..00cc75fa79f 100644--- a/tests/gateway/test_clarify_thread_followup_not_swallowed.py+++ b/tests/gateway/test_clarify_thread_followup_not_swallowed.py@@ -123,11 +123,13 @@ async def test_thread_prose_not_swallowed_by_native_multi_choice_clarify():with pytest.raises(_FellThroughIntercept):await _dispatch(runner, _event("just checking the visual UI, no need to pass any data"))- # The clarify entry must still be pending and unresolved.+ # The prose is not accepted as the answer, but the clarify must be+ # released before normal busy routing so redirect-to-steer can drain.with cm._lock:entry = cm._entries.get("cl-native")assert entry is not None- assert not entry.event.is_set()+ assert entry.event.is_set()+ assert entry.response == ""_clear_clarify_state()