2.7 KiB
Track Specification: MMA Pipeline Fix & Worker Stream Verification
Overview
The MMA pipeline has a verified code path from run_worker_lifecycle → _queue_put("response", ...) → _process_event_queue → _pending_gui_tasks("handle_ai_response") → mma_streams[stream_id] = text. However, the robust_live_simulation track's session compression (2026-02-28) documented that Tier 3 worker output never appears in mma_streams during actual GUI operation. The simulation only ever sees 'Tier 1' in mma_streams keys.
This track diagnoses and fixes the pipeline break, then verifies end-to-end that worker output flows from ai_client.send() through to the GUI's mma_streams dict.
Root Cause Candidates (from code analysis)
-
run_in_executorpositional arg ordering:run_worker_lifecyclehas 7 parameters. The call atmulti_agent_conductor.py:118-127passes them positionally. If the order is wrong,loopcould beNoneand_queue_putwould silently fail (theif loop:branch is skipped, falling toevent_queue._queue.put_nowait()which may not work from a thread-pool thread becauseasyncio.Queue.put_nowaitis not thread-safe when called from outside the event loop). -
asyncio.Queuethread safety:_queue_putusesasyncio.run_coroutine_threadsafe()which IS thread-safe. But theelsebranch (event_queue._queue.put_nowait(...)) is NOT —asyncio.Queueis NOT thread-safe for cross-thread access. IfloopisNone, this branch silently corrupts or drops the event. -
ai_client.reset_session()side effects: Called at the start ofrun_worker_lifecycle, this resets the global_gemini_cli_adapter.session_id = None. If the adapter is shared state and the GUI's Tier 2 call is still in-flight, this could corrupt the provider state. -
Token stats stub:
engine.tier_usageupdate usesstats = {}(empty dict, commented "ai_client.get_token_stats() is not available"), soprompt_tokensandcandidates_tokensare always 0. Not a stream bug but a data bug.
Goals
- Fix Tier 3 worker responses reaching
mma_streamsin the GUI. - Fix token usage tracking for Tier 3 workers.
- Verify via
ApiHookClient.get_mma_status()thatmma_streamscontains Tier 3 output after a mock MMA run.
Architecture Reference
- Threading model: docs/guide_architecture.md — see "Cross-Thread Data Structures" and "Pattern A: AsyncEventQueue"
- Worker lifecycle: docs/guide_mma.md — see "Tier 3: Worker Lifecycle"
- Frame-sync: docs/guide_architecture.md — see "Frame-Sync Mechanism" action catalog (
handle_ai_responsewithstream_id)