Skip to content

The agent that grows with you

fix(approval): a finite gateway turn declines MCP consent instead of parking it

teknium1b0402824a5a3
diff --git a/tests/tools/test_mcp_trust_gating.py b/tests/tools/test_mcp_trust_gating.py
index 666b6d3b53f..fb20e3dd0f3 100644
--- a/tests/tools/test_mcp_trust_gating.py
+++ b/tests/tools/test_mcp_trust_gating.py
@@ -228,6 +228,7 @@ class TestTrustGateApprovalRouting:
("webhook", "", False),
("telegram", "1", False),
("api_server", "", True),
+ ("local", "", True), # a `chat -q` turn admitted to the gateway: finite, nobody answers
])
def test_unattended_cron_and_single_query_contexts_do_not_use_callback(
self, monkeypatch, platform, cron, single_query
diff --git a/tools/approval_prompt.py b/tools/approval_prompt.py
index 85129a16a91..ab8bb43fe77 100644
--- a/tools/approval_prompt.py
+++ b/tools/approval_prompt.py
@@ -296,6 +296,10 @@ def request_elicitation_consent(message: str, description: str, *,
except Exception as exc: # pragma: no cover -- defensive
logger.warning("Elicitation consent: session lookup failed: %s", exc)
return "decline"
+ # A finite gateway turn (``chat -q`` / ``-z`` over the daemon) has no one to answer: parking the prompt
+ # would detach the viewer mid-turn instead of failing closed like the in-process ``-q`` input() path.
+ if _ctx._is_single_query_approval_context():
+ return "decline"
# api_server is an unattended *platform* for the dangerous-command gate, but a live ``/v1/runs`` run
# registers an approval notify callback and answers via ``POST /v1/runs/{id}/approval``