From 6d495d9e7cf20f5e855f9646d58c31c7386e6473 Mon Sep 17 00:00:00 2001 From: LifeJiggy <141562589+LifeJiggy@users.noreply.github.com> Date: Mon, 18 May 2026 19:37:11 -0700 Subject: [PATCH] fix(approval): surface pending-approval state with explicit marker visible to LLM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a tool call requires user approval in the non-blocking gateway path, the LLM previously received a result that was indistinguishable from a failed tool call (exit_code=-1, error=message). The LLM could not tell whether the tool was pending approval, had returned empty results, or had failed silently — causing it to burn context on wrong hypotheses. Fix changes the result format to include: - status: pending_approval (clear state name) - approval_pending: True (explicit boolean for LLMs to detect) - error: cleared to empty string (removes misleading error signal) This lets the LLM reason about approval latency vs actual errors, short-circuiting the previous silent failure mode. Fixes #14806 --- tools/approval.py | 3 ++- tools/terminal_tool.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/approval.py b/tools/approval.py index cf5df644ff8..bfc70cd0fb0 100644 --- a/tools/approval.py +++ b/tools/approval.py @@ -1332,7 +1332,8 @@ def check_all_command_guards(command: str, env_type: str, return { "approved": False, "pattern_key": primary_key, - "status": "approval_required", + "status": "pending_approval", + "approval_pending": True, "command": command, "description": combined_desc, "message": ( diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py index 31a1c6fa078..2c522fe7571 100644 --- a/tools/terminal_tool.py +++ b/tools/terminal_tool.py @@ -1863,12 +1863,13 @@ def terminal_tool( approval = _check_all_guards(command, env_type) if not approval["approved"]: # Check if this is an approval_required (gateway ask mode) - if approval.get("status") == "approval_required": + if approval.get("status") == "pending_approval": return json.dumps({ "output": "", "exit_code": -1, - "error": approval.get("message", "Waiting for user approval"), - "status": "approval_required", + "error": "", + "status": "pending_approval", + "approval_pending": True, "command": approval.get("command", command), "description": approval.get("description", "command flagged"), "pattern_key": approval.get("pattern_key", ""),