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

@ -4,6 +4,8 @@ import asyncio
from collections.abc import AsyncIterator
from pathlib import Path
import structlog
from sdk.interface import (
Attachment,
MessageChunk,
@ -16,6 +18,8 @@ from sdk.interface import (
from sdk.prototype_state import PrototypeStateStore
from sdk.upstream_agent_api import AgentApi, MsgEventSendFile, MsgEventTextChunk
logger = structlog.get_logger(__name__)
class RealPlatformClient(PlatformClient):
def __init__(
@ -157,7 +161,13 @@ class RealPlatformClient(PlatformClient):
) -> AsyncIterator[object]:
attachment_paths = self._attachment_paths(attachments)
event_stream = chat_api.send_message(text, attachments=attachment_paths or None)
chunk_index = 0
async for event in event_stream:
if isinstance(event, MsgEventTextChunk):
logger.debug("agent_chunk", index=chunk_index, text=repr(event.text[:40]))
chunk_index += 1
else:
logger.debug("agent_event", index=chunk_index, type=type(event).__name__)
yield event
def _build_chat_api(self, chat_id: str):