forked from Rockachopa/Timmy-time-dashboard
fix: log Ollama disconnections with specific error handling (#92)
- BaseAgent.run(): catch httpx.ConnectError/ReadError/ConnectionError, log 'Ollama disconnected: <error>' at ERROR level, then re-raise - session.py: distinguish Ollama disconnects from other errors in chat(), chat_with_tools(), continue_chat() — return specific message 'Ollama appears to be disconnected' instead of generic error - 11 new tests covering all disconnect paths
This commit is contained in:
@@ -14,6 +14,7 @@ import logging
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
from agno.agent import Agent
|
||||
from agno.models.ollama import Ollama
|
||||
|
||||
@@ -120,8 +121,15 @@ class BaseAgent(ABC):
|
||||
Returns:
|
||||
Agent response
|
||||
"""
|
||||
result = self.agent.run(message, stream=False)
|
||||
response = result.content if hasattr(result, "content") else str(result)
|
||||
try:
|
||||
result = self.agent.run(message, stream=False)
|
||||
response = result.content if hasattr(result, "content") else str(result)
|
||||
except (httpx.ConnectError, httpx.ReadError, ConnectionError) as exc:
|
||||
logger.error("Ollama disconnected: %s", exc)
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.error("Agent run failed: %s", exc)
|
||||
raise
|
||||
|
||||
# Emit completion event
|
||||
if self.event_bus:
|
||||
|
||||
Reference in New Issue
Block a user