Files
microdao-daarion/docs/NODA1-AGENT-ARCHITECTURE.md
Apple ef3473db21 snapshot: NODE1 production state 2026-02-09
Complete snapshot of /opt/microdao-daarion/ from NODE1 (144.76.224.179).
This represents the actual running production code that has diverged
significantly from the previous main branch.

Key changes from old main:
- Gateway (http_api.py): expanded from ~40KB to 164KB with full agent support
- Router: new /v1/agents/{id}/infer endpoint with vision + DeepSeek routing
- Behavior Policy: SOWA v2.2 (3-level: FULL/ACK/SILENT)
- Agent Registry: config/agent_registry.yml as single source of truth
- 13 agents configured (was 3)
- Memory service integration
- CrewAI teams and roles

Excluded from snapshot: venv/, .env, data/, backups, .tgz archives

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 08:46:46 -08:00

280 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# NODA1 Agent Architecture
**Дата:** 2026-01-29
**Версія:** 2.0.0
## Огляд
NODA1 використовує уніфіковану систему агентів з єдиним джерелом істини (`config/agent_registry.yml`).
---
## Схема підключення агентів
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ TELEGRAM USERS │
│ (публічні канали та приватні чати) │
└────────────────────────────────┬────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ GATEWAY (dagi-gateway-node1:9300) │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ agent_registry.json (generated from config/agent_registry.yml) │ │
│ │ ─────────────────────────────────────────────────────────────────── │ │
│ │ 11 Telegram Agents: │ │
│ │ • daarwizz (Meta-Orchestrator, Digital Mayor) │ │
│ │ • helion (Energy Research, Energy Union) │ │
│ │ • alateya (R&D Lab OS, Interdisciplinary Research) │ │
│ │ • druid (Ayurveda, Cosmetics R&D) │ │
│ │ • nutra (Nutraceutical Research) │ │
│ │ • agromatrix (AgroMatrix Platform) │ │
│ │ • greenfood (Craft Food ERP) │ │
│ │ • clan (Community Spirit) │ │
│ │ • eonarch (Consciousness Evolution) │ │
│ │ • yaromir (Private Tech Lead) [whitelist] │ │
│ │ • soul (Spiritual Mentor) │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ Features: │
│ • registry_loader.py - читає agent_registry.json │
│ • Multimodal: photo, voice (STT), documents │
│ • Memory context integration │
└────────────────────────────────┬────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ ROUTER (dagi-staging-router:8000) │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ router_agents.json (generated from config/agent_registry.yml) │ │
│ │ ─────────────────────────────────────────────────────────────────── │ │
│ │ 13 Agents with routing: │ │
│ │ • 11 top-level (user-facing) │ │
│ │ • 2 internal (monitor, devtools) │ │
│ │ │ │
│ │ Per agent: keywords[], domains[], llm_profile, visibility │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ Endpoints: │
│ • POST /v1/agents/{agent_id}/infer - виклик агента │
│ • GET /health - статус │
│ • GET /metrics - Prometheus метрики │
│ │
│ Features: │
│ • Tool Manager (11 tools per agent) │
│ • Intent routing │
│ • LLM profile selection │
└────────────────────────────────┬────────────────────────────────────────────┘
┌────────────┼────────────┐
│ │ │
▼ ▼ ▼
┌───────────────────────┐ ┌───────────┐ ┌─────────────────────┐
│ LLM PROVIDERS │ │ MEMORY │ │ CREWAI │
│ ───────────────────── │ │ SERVICE │ │ (dagi-staging- │
│ • Ollama (local) │ │ :8000 │ │ crewai-service) │
│ - qwen3:8b │ ├───────────┤ │ ─────────────────── │
│ - mistral:7b │ │ • Qdrant │ │ crewai_agents.json │
│ - qwen2.5:3b │ │ • Neo4j │ │ │
│ • DeepSeek (cloud) │ │ • Postgres│ │ 11 Orchestrators │
│ • Mistral (cloud) │ └───────────┘ │ + Teams per agent │
└───────────────────────┘ └─────────────────────┘
```
---
## Canonical Source of Truth
```
config/agent_registry.yml ←── ЄДИНЕ джерело істини
│ tools/agents generate
┌────────────────────────────────────────────────────────┐
│ Generated configs (НЕ редагувати вручну!) │
│ │
│ • gateway-bot/agent_registry.json → Gateway │
│ • config/router_agents.json → Router │
│ • config/crewai_agents.json → CrewAI │
└────────────────────────────────────────────────────────┘
```
---
## Агенти за класами
### TOP-LEVEL (User-facing, 11 agents)
| ID | Display | Telegram | Visibility | Domain |
|----|---------|----------|------------|--------|
| `daarwizz` | DAARWIZZ | public | public | Meta-Orchestrator |
| `helion` | Helion | public | public | Energy |
| `alateya` | Aletheia | public | public | R&D Lab |
| `druid` | DRUID | public | public | Ayurveda/Cosmetics |
| `nutra` | NUTRA | public | public | Nutraceuticals |
| `agromatrix` | Степан Матрікс | public | public | Agriculture |
| `greenfood` | GREENFOOD | public | public | Food ERP |
| `clan` | CLAN | public | public | Community |
| `eonarch` | EONARCH | public | public | Consciousness |
| `yaromir` | YAROMIR | whitelist | private | Tech Lead |
| `soul` | SOUL | public | public | Spiritual |
### INTERNAL (Service agents, 2 agents)
| ID | Display | Telegram | Scope | Purpose |
|----|---------|----------|-------|---------|
| `monitor` | MONITOR | off | node_local | Observability, alerts |
| `devtools` | DevTools | off | global | Development tools |
---
## Tools per Agent (Standard Stack)
Всі 11 top-level агентів мають доступ до стандартного стеку:
| Tool | Description |
|------|-------------|
| `memory_search` | Пошук в памяті (Qdrant) |
| `graph_query` | Knowledge Graph запити (Neo4j) |
| `web_search` | Пошук в інтернеті |
| `web_extract` | Витяг даних з веб |
| `crawl4ai_scrape` | Глибокий скрейпінг |
| `remember_fact` | Збереження факту про користувача |
| `image_generate` | Генерація зображень |
| `tts_speak` | Текст у мовлення |
| `presentation_create` | Створення презентацій |
| `presentation_status` | Статус презентації |
| `presentation_download` | Завантаження презентації |
---
## CrewAI Teams
Кожен top-level агент може мати CrewAI команду:
```yaml
# Приклад: ALATEYA має 5 "професорів"
alateya:
team:
- role: "Prof-Erudite"
skills: [search, verification, analogies]
- role: "Prof-Analyst"
skills: [decomposition, triz, formalization]
- role: "Prof-Creative"
skills: [lateral_thinking, cross_domain]
- role: "Prof-Optimizer"
skills: [feasibility, risk_assessment]
- role: "Prof-Communicator"
skills: [synthesis, presentation]
```
---
## Feature Flags
```bash
# Увімкнено по замовчуванню
AGENT_REGISTRY_ENABLED=true
# Генерація конфігів
feature_flags:
registry_enabled: true
generate_prompts: true
generate_router_config: true
generate_crewai_config: true
```
---
## Як додати нового агента
1. Редагувати `config/agent_registry.yml`
2. Створити `gateway-bot/<agent>_prompt.txt`
3. `python3 tools/agents validate`
4. `python3 tools/agents generate`
5. `python3 tools/agents smoke --id <agent_id>`
6. Restart gateway: `docker restart dagi-gateway-node1`
7. Commit changes
---
## Мережева конфігурація
```
dagi-network:
- dagi-gateway-node1
- dagi-staging-router
- dagi-staging-crewai-service
- dagi-memory-service-node1
- dagi-qdrant-node1
- dagi-nats-node1
- swapper-service-node1
- ...
```
---
## Monitoring
- Gateway metrics: `:9300/metrics`
- Router metrics: `:8000/metrics`
- Prober: `:9108/metrics`
- Prometheus: `:9090`
- Grafana: `:3030`
---
## ⚠️ KNOWN GAP: Router → CrewAI Integration (2026-01-29)
### Current State
Router **always** uses direct LLM call. CrewAI service exists but is **not called**.
```
Current: Gateway → Router → LLM (always)
CrewAI (unused!)
```
### Target State
```
Target: Gateway → Router → Decision?
┌───────────┴───────────┐
↓ ↓
Direct LLM CrewAI /crew/run
(simple) (complex tasks)
```
### Integration Point
File: `services/router/main.py` function `agent_infer()`
Add after line ~540:
```python
from crewai_client import should_use_crewai, call_crewai
# Decision: direct LLM or CrewAI?
use_crew, reason = should_use_crewai(agent_id, request.prompt, agent_config)
logger.info(f"🎭 CrewAI decision: {use_crew} ({reason})")
if use_crew:
crew_result = await call_crewai(agent_id, request.prompt, context)
if crew_result["success"]:
return InferResponse(
response=crew_result["result"],
model="crewai",
...
)
# Fallback to direct LLM if CrewAI failed
```
### Prepared Files
- `services/router/crewai_client.py` - ready
- `config/crewai_agents.json` - generated from registry