fix: raise Ollama timeout to 300s, add model pre-warming, improve health check

- OllamaBackend enforces _MIN_TIMEOUT=300s (overrides OLLAMA_TIMEOUT env var)
- warm_model() background task loads activeblue-chat into VRAM at startup
- health/detailed reports "warming" vs "ok" via Ollama ps() API
- README updated with May 2026 changes and test coverage details
This commit is contained in:
2026-05-20 05:03:15 +00:00
parent 20a69313d7
commit 564f1a9479
5 changed files with 72 additions and 6 deletions

View File

@@ -1,6 +1,17 @@
# ActiveBlue AI
Multi-agent AI system integrated with Odoo 18 Community Edition.
Multi-agent AI system integrated with Odoo 18 Community Edition, powered by **Ollama** (`activeblue-chat` / llama-based model) running fully on-premise.
## What's New (May 2026)
- **Ollama cold-start fix**: `activeblue-chat` model takes ~124s to load from disk; timeout raised to 300s (enforced in code regardless of env var) and the model is pre-warmed at service startup so the first user message never times out.
- **Model pre-warming**: `_prewarm_ollama()` is launched as a background task during lifespan startup, loading the model into VRAM before any user traffic arrives.
- **Improved health check**: `/health/detailed` now queries Ollama's `ps` endpoint to report whether the model is loaded (`ok`) or still loading (`warming`), giving accurate bot online/offline status.
- **Comprehensive unit test suite**: 433 tests across all 8 specialist agents, all tool layers, PeerBus, AgentRegistry, ToolCallValidator, and base agent lifecycle. Run with `.venv-test/bin/python -m pytest tests/ -q`.
- **Tool count enforcement**: Each specialist agent is validated at startup to have ≤ 8 tools (`AgentConfigError` otherwise).
- **PeerBus inter-agent communication**: Agents can call each other with depth-limited routing, timeout safety, and call-log tracking.
- **Auto-RAG**: All agents automatically fetch Odoo 18 workflow guidance from `odoo_doc_agent` before answering.
- **Auto-heal loop**: Background task calls `sysops_agent.auto_heal()` every 2 minutes if any system is degraded.
## Architecture
@@ -100,10 +111,22 @@ See `.env.example` for the full list. Key variables:
### Running tests
```bash
# Using the project test venv (recommended)
.venv-test/bin/python -m pytest tests/ -q
# Or install manually
pip install pytest pytest-asyncio
pytest tests/ -v
```
Test coverage (433 passing, all on Ollama/local mode):
- `tests/test_registry.py` — AgentRegistry lifecycle
- `tests/test_peer_bus.py` — PeerBus routing, depth limits, timeouts
- `tests/test_tool_validator.py` — ToolCallValidator, type coercion, enum guards
- `tests/test_*_tools.py` — 8 files covering every tool method (finance, accounting, crm, sales, project, elearning, employees, expenses)
- `tests/test_*_agent.py` — 8 files covering plan/gather/reason/act/report/sweep/peer_bus for each specialist agent
- `tests/test_dispatch_router.py`, `test_e2e_dispatch.py`, `test_llm_router.py`, `test_odoo_client.py` — integration tests
### Project structure
```