#7 Добавить основные модели ивентов агента. Добавлены основные инветы #8

Merged
mrkan merged 5 commits from feature/stream-events-schema into master 2026-04-08 20:41:11 +00:00
Showing only changes of commit bd516cee43 - Show all commits

View file

@ -226,20 +226,19 @@ class AgentApi:
outgoing_msg = ServerMessage.validate_json(
msg.data)
if isinstance(outgoing_msg, MsgEventTextChunk):
if isinstance(outgoing_msg, (MsgEventTextChunk,
MsgEventToolCallChunk,
MsgEventToolResult,
MsgEventCustomUpdate,
MsgEventEnd)):
if self._current_queue:
await self._current_queue.put(outgoing_msg)
# Если очереди нет (клиент отменил запрос), но токены идут — шлем их в коллбек
elif self.callback:
self.callback(outgoing_msg)
else:
logger.warning(
f"[{self.id}] AgentEvent without active request")
elif isinstance(outgoing_msg, MsgEventEnd):
if self._current_queue:
await self._current_queue.put(outgoing_msg)
elif isinstance(outgoing_msg, MsgError):
if self.callback:
self.callback(outgoing_msg)