feat(mma): Implement HITL execution clutch and step-mode
This commit is contained in:
@@ -138,3 +138,59 @@ def test_run_worker_lifecycle_handles_blocked_response():
|
||||
|
||||
assert ticket.status == "blocked"
|
||||
assert "BLOCKED" in ticket.blocked_reason
|
||||
|
||||
def test_run_worker_lifecycle_step_mode_confirmation():
|
||||
"""
|
||||
Test that run_worker_lifecycle passes confirm_execution to ai_client.send when step_mode is True.
|
||||
Verify that if confirm_execution is called (simulated by mocking ai_client.send to call its callback),
|
||||
the flow works as expected.
|
||||
"""
|
||||
ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1", step_mode=True)
|
||||
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||
|
||||
from multi_agent_conductor import run_worker_lifecycle, confirm_execution
|
||||
|
||||
with patch("ai_client.send") as mock_send, \
|
||||
patch("multi_agent_conductor.confirm_execution") as mock_confirm:
|
||||
|
||||
# We simulate ai_client.send by making it call the pre_tool_callback it received
|
||||
def mock_send_side_effect(*args, **kwargs):
|
||||
callback = kwargs.get("pre_tool_callback")
|
||||
if callback:
|
||||
# Simulate calling it with some payload
|
||||
callback('{"tool": "read_file", "args": {"path": "test.txt"}}')
|
||||
return "Success"
|
||||
|
||||
mock_send.side_effect = mock_send_side_effect
|
||||
mock_confirm.return_value = True
|
||||
|
||||
run_worker_lifecycle(ticket, context)
|
||||
|
||||
# Verify confirm_execution was called
|
||||
mock_confirm.assert_called_once()
|
||||
assert ticket.status == "completed"
|
||||
|
||||
def test_run_worker_lifecycle_step_mode_rejection():
|
||||
"""
|
||||
Verify that if confirm_execution returns False, the logic (in ai_client, which we simulate here)
|
||||
would prevent execution. In run_worker_lifecycle, we just check if it's passed.
|
||||
"""
|
||||
ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1", step_mode=True)
|
||||
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||
|
||||
from multi_agent_conductor import run_worker_lifecycle
|
||||
|
||||
with patch("ai_client.send") as mock_send, \
|
||||
patch("multi_agent_conductor.confirm_execution") as mock_confirm:
|
||||
|
||||
mock_confirm.return_value = False
|
||||
mock_send.return_value = "Task failed because tool execution was rejected."
|
||||
|
||||
run_worker_lifecycle(ticket, context)
|
||||
|
||||
# Verify it was passed to send
|
||||
args, kwargs = mock_send.call_args
|
||||
assert kwargs["pre_tool_callback"] is not None
|
||||
|
||||
# Since we've already tested ai_client's implementation of pre_tool_callback (mentally or via other tests),
|
||||
# here we just verify the wiring.
|
||||
|
||||
Reference in New Issue
Block a user