3 KiB
3 KiB
| context | phase | task | total_tasks | status | last_updated |
|---|---|---|---|---|---|
| phase | 04-matrix-mvp-shared-agent-context-and-context-management-comma | 4 | 6 | in_progress | 2026-04-24T12:16:09.301Z |
<current_state> Debugging first-chunk truncation bug in Matrix bot. Logging added to both sdk/real.py and external/platform-agent/src/agent/service.py. Waiting for user to run docker compose up --build and share platform-agent logs with stream_event lines. </current_state>
<completed_work>
- docker-compose.yml: added
./config:/app/config:rovolume mount so MATRIX_AGENT_REGISTRY_PATH works - config/matrix-agents.example.yaml: updated labels to Platform/Media
- sdk/real.py: added structlog debug logging in _stream_agent_events (logs each chunk index + text[:40])
- external/platform-agent/src/agent/service.py: added logging of langgraph_node, content_type, content[:60] for every on_chat_model_stream event
Bot is running and user confirmed it starts correctly with MATRIX_PLATFORM_BACKEND=real. </completed_work>
<remaining_work>
- Task 4: Get platform-agent debug logs (docker compose up --build, reproduce truncation, share stream_event lines)
- Task 5: Analyze: check content_type (str vs list), check langgraph_node (which graph node produces the first chunk)
- Task 6: Fix service.py based on findings </remaining_work>
<decisions_made>
- Bug confirmed to be in platform-agent, NOT in surfaces bot: our sdk/real.py logs show chunk index=0 already has truncated text (e.g. ' Д Е Ё...' instead of 'А Б В Г Д...')
- deepagents framework uses SubAgentMiddleware: main dispatcher agent + general-purpose subagent
- service.py processes ALL on_chat_model_stream events from astream_events v2 with no node filtering
- Two leading hypotheses: (A) chunk.content is a list for some events (multimodal), causing silent skip/error; (B) events from wrong graph node are being captured/not captured </decisions_made>
Two key things to look for in logs:
- content_type=list → fix is
chunk.content[0].get("text", "")or similar - langgraph_node varies between chunks → fix is to filter to the correct node (e.g. only "agent" node)
<next_action> Start with: docker compose up --build. Then send a message with image context (e.g. send an image first, then ask 'Напомни алфавит'). Share platform-agent-1 logs — specifically the stream_event lines showing ns= and content_type= values. </next_action>