fix(approval): surface pending-approval state with explicit marker visible to LLM

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
This commit is contained in:
LifeJiggy
2026-05-18 19:37:11 -07:00
committed by Teknium
parent 523254b34a
commit 6d495d9e7c
2 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -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": (
+4 -3
View File
@@ -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", ""),