mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-13 21:21:53 +00:00
The two TestLoopThinkingIntegration tests in test_stream_event.py
broke after the default-loop's _get_router() picked up a backend-
change rebuild path (loop.py line 434+). Sequence:
1. Test sets ``loop._router = router`` (a MagicMock).
2. ``_process_message_inner`` calls ``self._get_router()``.
3. Default-loop branch reads ``Settings.load()`` and compares
``self._router._active_backend_name`` (None on a MagicMock) to
``fresh_settings.agent_backend`` ("claude_agent_sdk" or whatever
the test environment's loaded settings has).
4. Mismatch → tries to rebuild: ``asyncio.create_task(old.stop())``.
5. ``old.stop()`` returns a MagicMock (not a coroutine).
6. ``asyncio.create_task`` raises TypeError; the message handler's
outer try/except logs "❌ Error processing message" and returns
before either thinking_done or the assistant memory write fires.
Fix: set ``loop.agent_id = "test-agent"`` on each test. That sends
``_get_router()`` down the per-agent fast path (line 430-431) which
returns the cached router immediately without any rebuild check.
The per-agent path is the right shape for a unit test that injects
its own router — the rebuild path is for runtime backend swaps,
not test fixture wiring.
Both tests pass locally:
uv run pytest tests/test_stream_event.py::TestLoopThinkingIntegration -v
...
test_loop_thinking_publishes_system_event PASSED
test_loop_thinking_not_in_memory PASSED
2 passed in 0.24s
Also removes the corresponding --deselect lines from
.github/workflows/tests.yaml so the CI gate exercises these tests
again. Closes #1081.