wip: first-chunk debug logging — paused waiting for platform-agent logs

This commit is contained in:
Mikhail Putilovskij 2026-04-24 15:17:08 +03:00
parent 2a23b30f83
commit c34db0e6c0
5 changed files with 61 additions and 111 deletions

View file

@ -1,90 +1,38 @@
{
"version": "1.0",
"timestamp": "2026-04-23T11:46:45.938Z",
"timestamp": "2026-04-24T12:16:09.301Z",
"phase": "04",
"phase_name": "Matrix MVP: shared agent context and context management commands",
"phase_dir": ".planning/phases/04-matrix-mvp-shared-agent-context-and-context-management-comma",
"plan": 3,
"task": 3,
"total_tasks": 3,
"phase_name": "matrix-mvp-shared-agent-context-and-context-management",
"phase_dir": "04-matrix-mvp-shared-agent-context-and-context-management-comma",
"plan": null,
"task": null,
"total_tasks": null,
"status": "paused",
"completed_tasks": [
{
"id": 1,
"name": "Стабилизировать Matrix MVP runtime: numeric platform_chat_id mapping, staged attachments, clean vendored platform repos",
"status": "done",
"commit": "4524a6a"
},
{
"id": 2,
"name": "Локализовать missing-first-chunk bug, оформить финальный bug report и очистить runtime до thin upstream integration boundary",
"status": "done",
"commit": "0c2884c"
},
{
"id": 3,
"name": "Перейти на direct upstream AgentApi per request, убрать local wrapper из prod path и зафиксировать AGENT_BASE_URL как основной runtime contract",
"status": "done",
"commit": "7d58dd1"
}
{"id": 1, "name": "docker-compose config mount + MATRIX_AGENT_REGISTRY_PATH", "status": "done"},
{"id": 2, "name": "debug logging in sdk/real.py (_stream_agent_events)", "status": "done"},
{"id": 3, "name": "debug logging in platform-agent service.py", "status": "done"}
],
"remaining_tasks": [
{
"id": 4,
"name": "Решить, закрываем ли Phase 04 окончательно или продолжаем Matrix через live smoke в реальном окружении",
"status": "not_started"
},
{
"id": 5,
"name": "Если двигаемся дальше по Matrix, прогнать text/tool/file smoke на direct AgentApi per-request path и проверить отсутствие regressions",
"status": "not_started"
},
{
"id": 6,
"name": "Если начинаем новую surface, открыть follow-up phase для prod messenger architecture без собственного transport layer",
"status": "not_started"
}
],
"blockers": [
{
"description": "В worktree остаётся посторонний локальный diff в core/handlers/message.py, не связанный с direct AgentApi fix",
"type": "technical",
"workaround": "Не смешивать с runtime/surface работой без отдельной задачи; handoff commit этот файл не включает"
}
{"id": 4, "name": "run docker compose up --build and get platform-agent logs with stream_event lines", "status": "not_started"},
{"id": 5, "name": "analyze logs: content_type and langgraph_node to find where first chunk is lost", "status": "not_started"},
{"id": 6, "name": "fix in service.py based on findings (filter by node, handle list content, or capture subagent output)", "status": "not_started"}
],
"blockers": [],
"human_actions_pending": [
{
"action": "Выбрать следующий трек: Matrix live validation или планирование новой prod surface вроде Telegram/Max",
"context": "Кодовый фикс уже сделан и запушен; дальше работа зависит от продуктового направления, а не от transport-debug",
"blocking": false
},
{
"action": "При следующем отдельном planning/cleanup коммите привести STATE/roadmap в полное соответствие с direct upstream per-request решением",
"context": "Локальный STATE уже обновлён как checkpoint, но handoff WIP commit включает только HANDOFF и .continue-here",
"blocking": false
}
{"action": "run docker compose up --build and reproduce the alphabet/image truncation bug", "context": "Need platform-agent logs with DEBUG level to see stream_event lines", "blocking": true}
],
"decisions": [
{
"decision": "Для prod path Matrix surface больше не держит собственный transport layer; используется прямой upstream AgentApi с fresh connection per request",
"rationale": "Это убрало reuse-sensitive загрязнение между запросами, после чего missing-first-chunk симптом перестал воспроизводиться локально",
"phase": "04"
},
{
"decision": "AGENT_BASE_URL принят как основной runtime contract; AGENT_WS_URL оставлен только как backward-compat fallback в env wiring",
"rationale": "Так surface говорит с платформой по их реальному API contract, а не через локальный ws shim",
"phase": "04"
},
{
"decision": "Для следующих surfaces не строить custom transport wrapper поверх платформы",
"rationale": "Surface должна владеть integration/session boundary, а не альтернативной stream semantics",
"phase": "04"
}
{"decision": "Bug is in platform-agent service.py __astream, not in surfaces bot", "rationale": "Logs show first text chunk already truncated at index=0 level", "phase": "04"},
{"decision": "deepagents uses dispatcher+subagent architecture", "rationale": "create_deep_agent wraps SubAgentMiddleware with general-purpose subagent", "phase": "04"},
{"decision": "astream_events v2 processes on_chat_model_stream from ALL nodes without filtering", "rationale": "service.py has no namespace/node filtering", "phase": "04"}
],
"uncommitted_files": [
".planning/STATE.md",
"core/handlers/message.py"
"sdk/real.py (debug logging added)",
"docker-compose.yml (config volume mount added)",
"config/matrix-agents.example.yaml (label names updated)",
"external/platform-agent/src/agent/service.py (debug logging added, in submodule)"
],
"next_action": "При возобновлении сначала прочитать обновлённый handoff, затем выбрать один из двух треков: либо Matrix live smoke на direct AgentApi per-request path, либо новая phase/spec для prod surface без собственного transport layer",
"context_notes": "Старый checkpoint про platform triage устарел. После диалога с платформой runtime переведён на прямой upstream AgentApi с fresh connection per request, локальный wrapper убран из prod path, tests прошли, commit 7d58dd1 запушен в origin/feat/matrix-direct-agent-prototype. Важный вывод для будущей архитектуры surfaces: upstream transport считать authoritative, а локально держать только lifecycle, serialization, attachment forwarding, error mapping и reconciliation."
"next_action": "Run: docker compose up --build. Send a message that triggers the bug (e.g. 'Напомни алфавит' after sending an image). Look for stream_event lines in platform-agent-1 logs. Check content_type and langgraph_node values for truncated responses.",
"context_notes": "Investigating first-chunk truncation bug in Matrix bot responses. The bug appears when agent uses tools (image analysis) OR when images are in context. Platform-agent uses deepagents framework (dispatcher+subagent pattern). The hypothesis is that on_chat_model_stream events from multiple graph nodes are all forwarded as MsgEventTextChunk without filtering, OR that chunk.content is sometimes a list instead of str causing validation issues. Added logging to confirm. The fix will likely be in service.py: either filter by langgraph_node or handle list content type."
}