Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
canary: clean up the failed attempt before the bot retries
Antonio Ojeada27d05dbed1
diff --git a/site/content/docs/snippets/banana_bot_playground.py b/site/content/docs/snippets/banana_bot_playground.pyindex 21e40cad..35761abe 100644--- a/site/content/docs/snippets/banana_bot_playground.py+++ b/site/content/docs/snippets/banana_bot_playground.py@@ -31,12 +31,18 @@ class SamClient:# The SDK's SSE-friendly defaults; httpx's default 5s read timeout drops the stream.timeout=httpx.Timeout(30.0, read=300.0),)- self._sse_cm = streamable_http_client(self.server_url, http_client=self._http_client)- res = await self._sse_cm.__aenter__()- read_stream, write_stream = res[0], res[1]- self.session = ClientSession(read_stream, write_stream)- await self.session.__aenter__()- await self.session.initialize()+ try:+ self._sse_cm = streamable_http_client(self.server_url, http_client=self._http_client)+ res = await self._sse_cm.__aenter__()+ read_stream, write_stream = res[0], res[1]+ self.session = ClientSession(read_stream, write_stream)+ await self.session.__aenter__()+ await self.session.initialize()+ except Exception:+ # The retry loop in __aenter__ would otherwise orphan this+ # attempt's http client and half-entered streams.+ await self.close()+ raiseasync def close(self):if self.session: