import pytest from duck_core.events.store import EventStore from duck_core.model_client import ModelResponse from duck_core.runtime_loop import RuntimeLoop from duck_core.tasks.store import TaskStore class FakeModelClient: async def chat(self, role, messages): return ModelResponse( role=role, model="local-main", content="visible answer", reasoning_content="reasoning trace", raw={}, latency_ms=12.0, prompt_tokens=1, completion_tokens=2, total_tokens=3, ) @pytest.mark.asyncio async def test_runtime_returns_and_logs_reasoning_content(tmp_path): db_path = str(tmp_path / "duck.sqlite3") task_store = TaskStore(db_path) event_store = EventStore(db_path) loop = RuntimeLoop(task_store, event_store, FakeModelClient()) result = await loop.run_chat("hello", "./workspace", debug=True) events = await event_store.list_events(result.task_id) cognition = next(event for event in events if event.event_type == "cognition_response") assert result.final_response == "visible answer" assert result.reasoning_content == "reasoning trace" assert cognition.payload["reasoning_content"] == "reasoning trace"