From 4910a703a78a296a45207d52c171d971b7db212e Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 15 Jun 2026 19:41:33 -0400 Subject: [PATCH] more manual corrections --- simulation/user_agent.py | 2 +- tests/test_ai_loop_regressions_20260614.py | 1 - tests/test_conductor_engine_v2.py | 44 +++++++++++----------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/simulation/user_agent.py b/simulation/user_agent.py index 7ec59288..63d7aaab 100644 --- a/simulation/user_agent.py +++ b/simulation/user_agent.py @@ -72,7 +72,7 @@ class UserSimAgent: break try: ai_client.set_custom_system_prompt(self.system_prompt) - response = ai_client.send(md_content="", user_message=last_ai_msg) + response = ai_client.send_result(md_content="", user_message=last_ai_msg) finally: ai_client.set_custom_system_prompt("") return response diff --git a/tests/test_ai_loop_regressions_20260614.py b/tests/test_ai_loop_regressions_20260614.py index 99b2e573..d35c2d2d 100644 --- a/tests/test_ai_loop_regressions_20260614.py +++ b/tests/test_ai_loop_regressions_20260614.py @@ -55,7 +55,6 @@ def test_fr1_error_becomes_discussion_entry(mock_app: App, monkeypatch: pytest.M err = ErrorInfo(kind=ErrorKind.NETWORK, message="connection refused", source="ai_client.test") err_result = Result(data="", errors=[err]) monkeypatch.setattr(ai_client, "send_result", lambda *a, **kw: err_result) - monkeypatch.setattr(ai_client, "send", lambda *a, **kw: "") monkeypatch.setattr(ai_client, "set_custom_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_base_system_prompt", lambda *a, **kw: None) monkeypatch.setattr(ai_client, "set_use_default_base_prompt", lambda *a, **kw: None) diff --git a/tests/test_conductor_engine_v2.py b/tests/test_conductor_engine_v2.py index f07ef08c..195eba4b 100644 --- a/tests/test_conductor_engine_v2.py +++ b/tests/test_conductor_engine_v2.py @@ -34,9 +34,9 @@ def test_conductor_engine_run_executes_tickets_in_order(monkeypatch: pytest.Monk vlogger.log_state("T1 Status", "todo", "todo") vlogger.log_state("T2 Status", "todo", "todo") - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) # We mock run_worker_lifecycle as it is expected to be in the same module with patch("src.multi_agent_conductor.run_worker_lifecycle") as mock_lifecycle: # Mocking lifecycle to mark ticket as complete so dependencies can be resolved @@ -75,15 +75,15 @@ def test_run_worker_lifecycle_calls_ai_client_send(monkeypatch: pytest.MonkeyPat ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1") context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[]) from src.multi_agent_conductor import run_worker_lifecycle - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) mock_send.return_value = "Task complete. I have updated the file." result = run_worker_lifecycle(ticket, context) assert result == "Task complete. I have updated the file." assert ticket.status == "completed" mock_send.assert_called_once() - # Check if description was passed to send() + # Check if description was passed to send_result() args, kwargs = mock_send.call_args # user_message is passed as a keyword argument assert ticket.description in kwargs["user_message"] @@ -98,9 +98,9 @@ def test_run_worker_lifecycle_context_injection(monkeypatch: pytest.MonkeyPatch) context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[]) context_files = ["primary.py", "secondary.py"] from src.multi_agent_conductor import run_worker_lifecycle - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) # We mock ASTParser which is expected to be imported in multi_agent_conductor with patch("src.multi_agent_conductor.ASTParser") as mock_ast_parser_class, \ patch("builtins.open", new_callable=MagicMock) as mock_open: @@ -144,9 +144,9 @@ def test_run_worker_lifecycle_handles_blocked_response(monkeypatch: pytest.Monke ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1") context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[]) from src.multi_agent_conductor import run_worker_lifecycle - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) # Simulate a response indicating a block mock_send.return_value = "I am BLOCKED because I don't have enough information." run_worker_lifecycle(ticket, context) @@ -157,16 +157,16 @@ def test_run_worker_lifecycle_step_mode_confirmation(monkeypatch: pytest.MonkeyP """ - 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), + Test that run_worker_lifecycle passes confirm_execution to ai_client.send_result when step_mode is True. + Verify that if confirm_execution is called (simulated by mocking ai_client.send_result 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 src.multi_agent_conductor import run_worker_lifecycle - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) # Important: confirm_spawn is called first if event_queue is present! with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \ @@ -201,9 +201,9 @@ def test_run_worker_lifecycle_step_mode_rejection(monkeypatch: pytest.MonkeyPatc 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 src.multi_agent_conductor import run_worker_lifecycle - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \ patch("src.multi_agent_conductor.confirm_execution") as mock_confirm: mock_spawn.return_value = (True, "mock prompt", "mock context") @@ -213,7 +213,7 @@ def test_run_worker_lifecycle_step_mode_rejection(monkeypatch: pytest.MonkeyPatc mock_event_queue = MagicMock() run_worker_lifecycle(ticket, context, event_queue=mock_event_queue) - # Verify it was passed to send + # Verify it was passed to send_result args, kwargs = mock_send.call_args assert kwargs["pre_tool_callback"] is not None @@ -257,9 +257,9 @@ def test_conductor_engine_dynamic_parsing_and_execution(monkeypatch: pytest.Monk assert engine.track.tickets[0].id == "T1" assert engine.track.tickets[1].id == "T2" assert engine.track.tickets[2].id == "T3" - # Mock ai_client.send using monkeypatch + # Mock ai_client.send_result using monkeypatch mock_send = MagicMock() - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) # Mock run_worker_lifecycle to mark tickets as complete with patch("src.multi_agent_conductor.run_worker_lifecycle") as mock_lifecycle: def side_effect(ticket, context, *args, **kwargs): @@ -297,7 +297,7 @@ def test_run_worker_lifecycle_pushes_response_via_queue(monkeypatch: pytest.Monk context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[]) mock_event_queue = MagicMock() mock_send = MagicMock(return_value="Task complete.") - monkeypatch.setattr(ai_client, 'send', mock_send) + monkeypatch.setattr(ai_client, 'send_result', mock_send) monkeypatch.setattr(ai_client, 'reset_session', MagicMock()) from src.multi_agent_conductor import run_worker_lifecycle with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \ @@ -326,11 +326,11 @@ def test_run_worker_lifecycle_token_usage_from_comms_log(monkeypatch: pytest.Mon {"direction": "OUT", "kind": "request", "payload": {"message": "hello"}}, {"direction": "IN", "kind": "response", "payload": {"usage": {"input_tokens": 120, "output_tokens": 45}}}, ] - monkeypatch.setattr(ai_client, 'send', MagicMock(return_value="Done.")) + monkeypatch.setattr(ai_client, 'send_result', MagicMock(return_value="Done.")) monkeypatch.setattr(ai_client, 'reset_session', MagicMock()) monkeypatch.setattr(ai_client, 'get_comms_log', MagicMock(side_effect=[ - [], # baseline call (before send) - fake_comms, # after-send call + [], # baseline call (before send_result) + fake_comms, # after-send_result call ])) from src.multi_agent_conductor import run_worker_lifecycle, ConductorEngine track = Track(id="test_track", description="Test")