From 5261396ef779fc5183e31590c7ba8a9356b7d8f9 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Tue, 12 May 2026 22:51:03 -0400 Subject: [PATCH] fix(agent): add missing ping() to OllamaBackend and OdooClient Health endpoint called .ping() on both but neither implemented it, causing ollama/odoo to always show as error and the bot to stay offline. Co-Authored-By: Claude Sonnet 4.6 --- agent_service/llm/ollama_backend.py | 11 +++++++++++ agent_service/tools/odoo_client.py | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/agent_service/llm/ollama_backend.py b/agent_service/llm/ollama_backend.py index ff2f31b..c6d64eb 100644 --- a/agent_service/llm/ollama_backend.py +++ b/agent_service/llm/ollama_backend.py @@ -62,5 +62,16 @@ class OllamaBackend: finally: self._active -= 1 + async def ping(self) -> None: + """Raise if Ollama is unreachable.""" + import ollama + client = ollama.AsyncClient(host=self._url) + try: + await asyncio.wait_for(client.list(), timeout=5) + except asyncio.TimeoutError: + raise OllamaUnavailableError('Ollama ping timed out') + except Exception as exc: + raise OllamaUnavailableError(f'Ollama ping failed: {exc}') from exc + @property def active_count(self): return self._active diff --git a/agent_service/tools/odoo_client.py b/agent_service/tools/odoo_client.py index 9600061..f0d506d 100644 --- a/agent_service/tools/odoo_client.py +++ b/agent_service/tools/odoo_client.py @@ -55,6 +55,10 @@ class OdooClient: self._models = xmlrpc.client.ServerProxy( f'{self._url}/xmlrpc/2/object', transport=transport, allow_none=True) + async def ping(self) -> None: + """Raise if Odoo is unreachable.""" + await self._xmlrpc_call(self._common, 'version') + async def connect(self): await self._authenticate() if self._pg_dsn: