Private
Public Access
0
0

refactor(multi_agent_conductor): migrate worker dispatch to send_result() (G3, public_api_migration_and_ui_polish_20260615 Phase 1.3)

Replaces deprecated ai_client.send(...) with ai_client.send_result(...) for
the 8-arg worker dispatch in run_worker_lifecycle. The new code branches on
result.ok:
  - On success: response = result.data (continue as before)
  - On error: log via comms + push a 'response' event with status='error' +
    push ticket_completed + mark ticket.status='error' + return None

This is the hardest of the 3 production migrations (5 callbacks:
pre_tool_callback, qa_callback, patch_callback, stream_callback + the
worker_comms_callback already wired up).

The 2 tests in test_phase6_engine.py + test_spawn_interception_v2.py now
fail because they mock src.ai_client.send. These will be fixed in
Phase 2.16/2.18 by mocking send_result instead. test_run_worker_lifecycle_abort
still passes because the abort check fires before the send call.
This commit is contained in:
2026-06-15 16:00:05 -04:00
parent 7ea802ab80
commit bdd46299b1
+11 -1
View File
@@ -588,7 +588,7 @@ def run_worker_lifecycle(ticket: Ticket, context: WorkerContext, context_files:
ai_client.set_current_tier(f"Tier 3 (Worker): {ticket.id}")
try:
comms_baseline = len(ai_client.get_comms_log())
response = ai_client.send(
result = ai_client.send_result(
md_content=md_content,
user_message=user_message,
base_dir=".",
@@ -597,6 +597,16 @@ def run_worker_lifecycle(ticket: Ticket, context: WorkerContext, context_files:
patch_callback=ai_client.run_tier4_patch_callback,
stream_callback=stream_callback
)
if not result.ok:
err = result.errors[0] if result.errors else None
err_msg = err.ui_message() if err else "unknown error"
print(f"[MMA] Worker send_result failed for {ticket.id}: {err_msg}")
if event_queue:
_queue_put(event_queue, "response", {"text": f"\n\n[ERROR] {err_msg}", "stream_id": f"Tier 3 (Worker): {ticket.id}", "status": "error", "role": "Vendor API"})
_queue_put(event_queue, "ticket_completed", {"ticket_id": ticket.id, "timestamp": time.time()})
ticket.status = "error"
return None
response = result.data
finally:
ai_client.set_comms_log_callback(old_comms_cb)
ai_client.set_current_tier(None)