Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
e3e5ceb
1
Parent(s): 723c24c
fix: clear pending_approval before tool execution starts
Browse filesMoves session.pending_approval = None to right after parsing approval
decisions, before tool execution begins. Previously it was cleared after
all tools finished, so a page refresh during execution would re-show
the approval dialog.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- agent/core/agent_loop.py +4 -3
agent/core/agent_loop.py
CHANGED
|
@@ -652,6 +652,10 @@ class Handlers:
|
|
| 652 |
else:
|
| 653 |
rejected_tasks.append((tc, tool_name, approval_decision))
|
| 654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
# Notify frontend of approval decisions immediately (before execution)
|
| 656 |
for tc, tool_name, tool_args, _was_edited in approved_tasks:
|
| 657 |
await session.send_event(
|
|
@@ -780,9 +784,6 @@ class Handlers:
|
|
| 780 |
)
|
| 781 |
)
|
| 782 |
|
| 783 |
-
# Clear pending approval
|
| 784 |
-
session.pending_approval = None
|
| 785 |
-
|
| 786 |
# Continue agent loop with empty input to process the tool results
|
| 787 |
await Handlers.run_agent(session, "")
|
| 788 |
|
|
|
|
| 652 |
else:
|
| 653 |
rejected_tasks.append((tc, tool_name, approval_decision))
|
| 654 |
|
| 655 |
+
# Clear pending approval immediately so a page refresh during
|
| 656 |
+
# execution won't re-show the approval dialog.
|
| 657 |
+
session.pending_approval = None
|
| 658 |
+
|
| 659 |
# Notify frontend of approval decisions immediately (before execution)
|
| 660 |
for tc, tool_name, tool_args, _was_edited in approved_tasks:
|
| 661 |
await session.send_event(
|
|
|
|
| 784 |
)
|
| 785 |
)
|
| 786 |
|
|
|
|
|
|
|
|
|
|
| 787 |
# Continue agent loop with empty input to process the tool results
|
| 788 |
await Handlers.run_agent(session, "")
|
| 789 |
|