Sweep coordinator (Step 16): - SweepCoordinator runs all 8 agents in parallel with 60s per-agent / 300s total timeout - Aggregates findings, actions, errors into SweepCoordinatorResult - Registered in FastAPI lifespan; triggered via POST /sweep Structured logging (Step 18): - logging_utils/structured.py: JSONFormatter emitting ts/level/logger/msg + custom fields - log_directive_event() for structured directive lifecycle logging - push_to_loki() async Loki push (graceful no-op if LOKI_URL unset) - configure_logging() replaces root handler at startup Tests (Steps 17+19): - conftest.py: mock_odoo, mock_pool, mock_llm fixtures - test_tool_validator.py: 9 tests covering validation, coercion, hallucination stripping - test_llm_router.py: 6 tests covering local/cloud/hybrid modes and HIPAA enforcement - test_peer_bus.py: 6 tests covering registration, timeout, depth, circular detection - test_finance_agent.py: 10 tests covering all 6 steps + sweep + peer request - test_memory_manager.py: 3 tests covering context build + hard cap enforcement - test_dispatch_router.py: 3 tests covering dispatch, rate limit, health endpoint - test_odoo_client.py: 4 tests covering search_read, write result, unlink warning - test_e2e_dispatch.py: 2 E2E tests - full dispatch cycle + peer bus communication README (Step 20): architecture diagram, privacy modes, quick start, env vars, structure Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
155 lines
5.0 KiB
Markdown
155 lines
5.0 KiB
Markdown
# ActiveBlue AI
|
|
|
|
Multi-agent AI system integrated with Odoo 18 Community Edition.
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Odoo 18 (ai.activeblue.net)
|
|
└── activeblue_ai module
|
|
├── OWL2 systray brain icon + slide-in chat panel
|
|
├── Models: ab.ai.bot, ab.ai.directive, ab.ai.log, ab.ai.agent.registry
|
|
└── Controllers: /ai/chat, /ai/webhook/callback, /ai/health, /ai/approval/*
|
|
|
|
FastAPI Agent Service (192.168.2.47:8001)
|
|
├── POST /dispatch — route user message to MasterAgent
|
|
├── GET/POST /approval/* — human approval workflow
|
|
├── GET/POST /registry/* — agent registry + LLM backend overrides
|
|
├── POST /sweep — trigger proactive agent sweeps
|
|
└── GET /health — service health + Odoo/Ollama status
|
|
|
|
MasterAgent (singleton)
|
|
├── Classifies intent via LLM
|
|
├── Routes to specialist agents in parallel (asyncio.gather)
|
|
├── Manages 3-tier memory (conversation / operational / knowledge)
|
|
└── Synthesises responses
|
|
|
|
Specialist Agents (8, stateless):
|
|
finance_agent, accounting_agent, crm_agent, sales_agent,
|
|
project_agent, elearning_agent, expenses_agent, employees_agent
|
|
```
|
|
|
|
## Privacy Modes
|
|
|
|
| Mode | Behaviour |
|
|
|---------|--------------------------------------------|
|
|
| `local` | Ollama only for all agents |
|
|
| `hybrid`| Per-agent override (DB → env → fallback) |
|
|
| `cloud` | Claude for non-HIPAA agents |
|
|
|
|
**HIPAA-locked agents** (always Ollama, no exceptions):
|
|
`finance_agent`, `accounting_agent`, `employees_agent`, `expenses_agent`
|
|
|
|
## Quick Start
|
|
|
|
### 1. Clone and configure
|
|
|
|
```bash
|
|
git clone http://192.168.1.64:3000/tocmo0nlord/odoo-ai.git
|
|
cd odoo-ai
|
|
cp .env.example .env
|
|
# Edit .env — set POSTGRES_PASSWORD, ODOO_API_KEY, etc.
|
|
```
|
|
|
|
### 2. Run Odoo 18
|
|
|
|
```bash
|
|
docker compose -f docker-compose.odoo.yml up -d
|
|
```
|
|
|
|
### 3. Run the Agent Service
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
Or for development:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
uvicorn agent_service.main:app --reload --port 8001
|
|
```
|
|
|
|
### 4. Run database migrations
|
|
|
|
```bash
|
|
cd agent_service/migrations
|
|
alembic upgrade head
|
|
```
|
|
|
|
### 5. Install Odoo module
|
|
|
|
In Odoo → Settings → Apps → search "ActiveBlue AI" → Install.
|
|
|
|
## Environment Variables
|
|
|
|
See `.env.example` for the full list. Key variables:
|
|
|
|
| Variable | Description |
|
|
|----------|-------------|
|
|
| `ODOO_URL` | Odoo base URL (e.g. `http://ai.activeblue.net`) |
|
|
| `ODOO_API_KEY` | Odoo user API key |
|
|
| `OLLAMA_URL` | Ollama API URL (e.g. `http://192.168.2.47:11434`) |
|
|
| `ANTHROPIC_API_KEY` | Required only if `LLM_PRIVACY_MODE=cloud` or `hybrid` |
|
|
| `LLM_PRIVACY_MODE` | `local` / `hybrid` / `cloud` (default: `local`) |
|
|
| `POSTGRES_PASSWORD` | Required — no default |
|
|
| `WEBHOOK_SECRET` | Shared secret between Odoo and agent service |
|
|
|
|
## Development
|
|
|
|
### Running tests
|
|
|
|
```bash
|
|
pip install pytest pytest-asyncio
|
|
pytest tests/ -v
|
|
```
|
|
|
|
### Project structure
|
|
|
|
```
|
|
odoo-ai/
|
|
├── agent_service/
|
|
│ ├── agents/ # MasterAgent + 8 specialist agents + PeerBus + SweepCoordinator
|
|
│ ├── llm/ # OllamaBackend, ClaudeBackend, LLMRouter, ToolCallValidator
|
|
│ ├── memory/ # ConversationStore, OperationalStore, KnowledgeStore, MemoryManager
|
|
│ ├── tools/ # OdooClient + per-domain tools (finance, crm, sales, ...)
|
|
│ ├── routers/ # FastAPI routers (dispatch, approval, registry, sweep, health)
|
|
│ ├── prompts/ # System prompts for each agent
|
|
│ ├── migrations/ # Alembic migrations (7 tables)
|
|
│ ├── logging_utils/ # Structured JSON logging + Loki push
|
|
│ ├── config.py # pydantic-settings
|
|
│ ├── app_state.py # Global singletons
|
|
│ └── main.py # FastAPI app + lifespan startup
|
|
├── addons/
|
|
│ └── activeblue_ai/ # Odoo 18 module
|
|
│ ├── models/ # ab.ai.bot, ab.ai.directive, ab.ai.log, ab.ai.agent.registry
|
|
│ ├── controllers/ # webhook, health_proxy, approval + chat
|
|
│ ├── views/ # XML views + menus
|
|
│ ├── security/ # groups + ACL
|
|
│ ├── data/ # cron jobs
|
|
│ └── static/ # OWL2 JS + CSS + XML templates
|
|
├── research/ # Per-domain research notes
|
|
├── tests/ # pytest test suite
|
|
├── docker-compose.odoo.yml # Odoo 18 + PostgreSQL 15
|
|
├── docker-compose.yml # Agent service + PostgreSQL 15
|
|
├── Dockerfile
|
|
├── requirements.txt
|
|
└── .env.example
|
|
```
|
|
|
|
## Agent Tool Limits
|
|
|
|
Each specialist agent is capped at **8 tools** (`MAX_TOOLS_PER_AGENT`). The `ToolCallValidator` raises `AgentConfigError` at startup if exceeded.
|
|
|
|
## Memory Architecture
|
|
|
|
| Tier | Store | TTL | Scope |
|
|
|------|-------|-----|-------|
|
|
| Tier 1 | `ab_conversation_memory` | Hard cap: 200 rows/user | Per user |
|
|
| Tier 2 | `ab_operational_memory` | 90 days | Per agent+scope |
|
|
| Tier 3 | `ab_knowledge_store` | Permanent | Entity-keyed |
|
|
|
|
## License
|
|
|
|
LGPL-3.0
|