#5 Реализовать клиентскую часть канала общения. Добавлена обработка инвентов новых моделей событий агента

This commit is contained in:
Ярослав Малинин 2026-04-08 11:29:15 +03:00
parent 7aa0f80d4f
commit bd516cee43

View file

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