fix(agent): collision-safe thread keys

This commit is contained in:
Mikhail Putilovskij 2026-04-08 01:25:52 +03:00
parent 2fad1aaa66
commit 083be77404
2 changed files with 14 additions and 2 deletions

View file

@ -10,7 +10,7 @@ from sdk.interface import MessageChunk, MessageResponse, PlatformError
def build_thread_key(platform: str, user_id: str, chat_id: str) -> str:
return f"{platform}:{user_id}:{chat_id}"
return f"{len(platform)}:{platform}{len(user_id)}:{user_id}{len(chat_id)}:{chat_id}"
@dataclass(frozen=True, slots=True)
@ -75,6 +75,11 @@ class AgentSessionClient:
payload.get("details", "Agent error"),
code=payload.get("code", "AGENT_ERROR"),
)
elif msg_type == "GRACEFUL_DISCONNECT":
raise PlatformError(
"Agent disconnected gracefully",
code="GRACEFUL_DISCONNECT",
)
else:
raise PlatformError(
f"Unexpected agent message: {payload}",