Private
Public Access
more manual corrections
This commit is contained in:
@@ -72,7 +72,7 @@ class UserSimAgent:
|
|||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
ai_client.set_custom_system_prompt(self.system_prompt)
|
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:
|
finally:
|
||||||
ai_client.set_custom_system_prompt("")
|
ai_client.set_custom_system_prompt("")
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -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 = ErrorInfo(kind=ErrorKind.NETWORK, message="connection refused", source="ai_client.test")
|
||||||
err_result = Result(data="", errors=[err])
|
err_result = Result(data="", errors=[err])
|
||||||
monkeypatch.setattr(ai_client, "send_result", lambda *a, **kw: err_result)
|
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_custom_system_prompt", lambda *a, **kw: None)
|
||||||
monkeypatch.setattr(ai_client, "set_base_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)
|
monkeypatch.setattr(ai_client, "set_use_default_base_prompt", lambda *a, **kw: None)
|
||||||
|
|||||||
@@ -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("T1 Status", "todo", "todo")
|
||||||
vlogger.log_state("T2 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()
|
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
|
# 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:
|
with patch("src.multi_agent_conductor.run_worker_lifecycle") as mock_lifecycle:
|
||||||
# Mocking lifecycle to mark ticket as complete so dependencies can be resolved
|
# 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")
|
ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1")
|
||||||
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
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()
|
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."
|
mock_send.return_value = "Task complete. I have updated the file."
|
||||||
result = run_worker_lifecycle(ticket, context)
|
result = run_worker_lifecycle(ticket, context)
|
||||||
assert result == "Task complete. I have updated the file."
|
assert result == "Task complete. I have updated the file."
|
||||||
assert ticket.status == "completed"
|
assert ticket.status == "completed"
|
||||||
mock_send.assert_called_once()
|
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
|
args, kwargs = mock_send.call_args
|
||||||
# user_message is passed as a keyword argument
|
# user_message is passed as a keyword argument
|
||||||
assert ticket.description in kwargs["user_message"]
|
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 = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
context_files = ["primary.py", "secondary.py"]
|
context_files = ["primary.py", "secondary.py"]
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
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()
|
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
|
# 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, \
|
with patch("src.multi_agent_conductor.ASTParser") as mock_ast_parser_class, \
|
||||||
patch("builtins.open", new_callable=MagicMock) as mock_open:
|
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")
|
ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1")
|
||||||
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
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()
|
mock_send = MagicMock()
|
||||||
monkeypatch.setattr(ai_client, 'send', mock_send)
|
monkeypatch.setattr(ai_client, 'send_result', mock_send)
|
||||||
# Simulate a response indicating a block
|
# Simulate a response indicating a block
|
||||||
mock_send.return_value = "I am BLOCKED because I don't have enough information."
|
mock_send.return_value = "I am BLOCKED because I don't have enough information."
|
||||||
run_worker_lifecycle(ticket, context)
|
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.
|
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 to call its callback),
|
Verify that if confirm_execution is called (simulated by mocking ai_client.send_result to call its callback),
|
||||||
the flow works as expected.
|
the flow works as expected.
|
||||||
"""
|
"""
|
||||||
ticket = Ticket(id="T1", description="Task 1", status="todo", assigned_to="worker1", step_mode=True)
|
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=[])
|
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
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()
|
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!
|
# Important: confirm_spawn is called first if event_queue is present!
|
||||||
with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \
|
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)
|
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=[])
|
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
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()
|
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, \
|
with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \
|
||||||
patch("src.multi_agent_conductor.confirm_execution") as mock_confirm:
|
patch("src.multi_agent_conductor.confirm_execution") as mock_confirm:
|
||||||
mock_spawn.return_value = (True, "mock prompt", "mock context")
|
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()
|
mock_event_queue = MagicMock()
|
||||||
run_worker_lifecycle(ticket, context, event_queue=mock_event_queue)
|
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
|
args, kwargs = mock_send.call_args
|
||||||
assert kwargs["pre_tool_callback"] is not None
|
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[0].id == "T1"
|
||||||
assert engine.track.tickets[1].id == "T2"
|
assert engine.track.tickets[1].id == "T2"
|
||||||
assert engine.track.tickets[2].id == "T3"
|
assert engine.track.tickets[2].id == "T3"
|
||||||
# Mock ai_client.send using monkeypatch
|
# Mock ai_client.send_result using monkeypatch
|
||||||
mock_send = MagicMock()
|
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
|
# Mock run_worker_lifecycle to mark tickets as complete
|
||||||
with patch("src.multi_agent_conductor.run_worker_lifecycle") as mock_lifecycle:
|
with patch("src.multi_agent_conductor.run_worker_lifecycle") as mock_lifecycle:
|
||||||
def side_effect(ticket, context, *args, **kwargs):
|
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=[])
|
context = WorkerContext(ticket_id="T1", model_name="test-model", messages=[])
|
||||||
mock_event_queue = MagicMock()
|
mock_event_queue = MagicMock()
|
||||||
mock_send = MagicMock(return_value="Task complete.")
|
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())
|
monkeypatch.setattr(ai_client, 'reset_session', MagicMock())
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle
|
from src.multi_agent_conductor import run_worker_lifecycle
|
||||||
with patch("src.multi_agent_conductor.confirm_spawn") as mock_spawn, \
|
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": "OUT", "kind": "request", "payload": {"message": "hello"}},
|
||||||
{"direction": "IN", "kind": "response", "payload": {"usage": {"input_tokens": 120, "output_tokens": 45}}},
|
{"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, 'reset_session', MagicMock())
|
||||||
monkeypatch.setattr(ai_client, 'get_comms_log', MagicMock(side_effect=[
|
monkeypatch.setattr(ai_client, 'get_comms_log', MagicMock(side_effect=[
|
||||||
[], # baseline call (before send)
|
[], # baseline call (before send_result)
|
||||||
fake_comms, # after-send call
|
fake_comms, # after-send_result call
|
||||||
]))
|
]))
|
||||||
from src.multi_agent_conductor import run_worker_lifecycle, ConductorEngine
|
from src.multi_agent_conductor import run_worker_lifecycle, ConductorEngine
|
||||||
track = Track(id="test_track", description="Test")
|
track = Track(id="test_track", description="Test")
|
||||||
|
|||||||
Reference in New Issue
Block a user