Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(approvals): let the browser resume its waits on a later attempt
trohitg00ff0aa89f2b
diff --git a/server/services/approvals/tool_calls.py b/server/services/approvals/tool_calls.pyindex a825fdee..76680626 100644--- a/server/services/approvals/tool_calls.py+++ b/server/services/approvals/tool_calls.py@@ -24,7 +24,9 @@ sent the message, so a later attempt of a call that sends does not send itagain (:func:`resend_refusal`): the model reads that it may have gone out,and with Ask first off the chat's record says so (``outcome: unknown``). Theowner's approved sends already run with no retry-(services/temporal/approved_tool_call_workflow.py).+(services/temporal/approved_tool_call_workflow.py). A tool that Ask first+restricts instead of holding (the browser) keeps its own retries: its later+attempt resumes a wait the worker cut short (``NodeWaitInterrupted``).What a node sends as (its locked ``server_controlled_fields``: the account,the mailbox) never comes from the model, so the row keeps the call's@@ -317,7 +319,7 @@ def resend_refusal(context: Mapping[str, Any], node_cls: Any, node_data: Mappingreturn Noneif context.get("approval_execution") is None and not is_agent_tool_call(context):return None- if not spec.sends(node_data):+ if spec.restrict_while_asking or not spec.sends(node_data):return Nonereturn {"success": False, "error": RESEND_MESSAGE, "error_type": "SendOutcomeUnknown"}diff --git a/server/tests/services/approvals/test_held_activity.py b/server/tests/services/approvals/test_held_activity.pyindex b08f5bb8..46913305 100644--- a/server/tests/services/approvals/test_held_activity.py+++ b/server/tests/services/approvals/test_held_activity.py@@ -136,6 +136,19 @@ async def test_a_later_attempt_still_holds_or_runs_what_does_not_send(harness, sassert result["success"] is True+async def test_a_later_browser_attempt_resumes_instead_of_refusing(harness, service):+ # The browser's later attempt resumes a wait the worker cut short+ # (NodeWaitInterrupted); Ask first restricts it rather than holding it.+ browsing = {"operation": "click", "ref": "e3"}+ call = context(node_id="wf:browser:1", node_data=dict(browsing), tool_args=dict(browsing))+ for rule in (None, False, True):+ if rule is not None:+ await rules.set_ask_first(harness.database, "wf", rule)+ result = await attempt(2).run(get_node_class("browser").as_activity(), call)+ assert result["success"] is True, rule+ assert service.execute_node.await_count == 3++async def test_the_first_attempt_sends_as_before(harness, service):await rules.set_ask_first(harness.database, "wf", False)result = await attempt(1).run(get_node_class("whatsappSend").as_activity(), context())