feat: Node Self-Healing, DAGI Audit, Agent Prompts, Infra Invariants
### Backend (city-service) - Node Registry + Self-Healing API (migration 039) - Improved get_all_nodes() with robust fallback for node_registry/node_cache - Agent Prompts Runtime API for DAGI Router integration - DAGI Router Audit endpoints (phantom/stale detection) - Node Agents API (Guardian/Steward) - Node metrics extended (CPU/GPU/RAM/Disk) ### Frontend (apps/web) - Node Directory with improved error handling - Node Cabinet with metrics cards - DAGI Router Card component - Node Metrics Card component - useDAGIAudit hook ### Scripts - check-invariants.py - deploy verification - node-bootstrap.sh - node self-registration - node-guardian-loop.py - continuous self-healing - dagi_agent_audit.py - DAGI audit utility ### Migrations - 034: Agent prompts seed - 035: Agent DAGI audit - 036: Node metrics extended - 037: Node agents complete - 038: Agent prompts full coverage - 039: Node registry self-healing ### Tests - test_infra_smoke.py - test_agent_prompts_runtime.py - test_dagi_router_api.py ### Documentation - DEPLOY_CHECKLIST_2024_11_30.md - Multiple TASK_PHASE docs
This commit is contained in:
157
docs/tasks/TASK_PHASE_AGENT_SYSTEM_PROMPTS_MVP_v2.md
Normal file
157
docs/tasks/TASK_PHASE_AGENT_SYSTEM_PROMPTS_MVP_v2.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# TASK_PHASE_AGENT_SYSTEM_PROMPTS_MVP_v2
|
||||
|
||||
## Проєкт
|
||||
microdao-daarion (MVP DAARION.city)
|
||||
|
||||
## Фаза
|
||||
Agent System Prompts — Coverage + Runtime Integration
|
||||
|
||||
## Статус
|
||||
✅ **COMPLETED**
|
||||
|
||||
---
|
||||
|
||||
## Мета
|
||||
|
||||
1. Заповнити системні промти для всіх ключових агентів міста (City / District / Node)
|
||||
2. Підключити зберігання промтів у БД до реального DAGI Router runtime
|
||||
|
||||
---
|
||||
|
||||
## Результат
|
||||
|
||||
### 1. Повне покриття агентів (16 агентів)
|
||||
|
||||
#### City / Core
|
||||
- ✅ **DAARWIZZ** — core, safety, governance, tools
|
||||
- ✅ **MicroDAO Orchestrator** — core, safety
|
||||
- ✅ **DevTools Agent** — core, safety, tools
|
||||
|
||||
#### District / MicroDAO
|
||||
- ✅ **GREENFOOD** — core, safety, tools
|
||||
- ✅ **Helion** — core, safety, tools
|
||||
- ✅ **SOUL** — core, safety
|
||||
- ✅ **DRUID** — core, safety, tools
|
||||
- ✅ **NUTRA** — core, safety
|
||||
- ✅ **EONARCH** — core, safety
|
||||
- ✅ **CLAN** — core
|
||||
- ✅ **Yaromir** — core
|
||||
- ✅ **Monitor** — core, safety
|
||||
|
||||
#### Node Agents
|
||||
- ✅ **monitor-node1** (Node Guardian NODE1) — core, safety, governance
|
||||
- ✅ **monitor-node2** (Node Guardian NODE2) — core, safety
|
||||
- ✅ **node-steward-node1** — core
|
||||
- ✅ **node-steward-node2** — core
|
||||
|
||||
### 2. Runtime Integration
|
||||
|
||||
#### Нові API Endpoints
|
||||
|
||||
```
|
||||
GET /internal/agents/{agent_id}/prompts/runtime
|
||||
```
|
||||
Повертає промти для агента (тільки content, без метаданих).
|
||||
|
||||
```
|
||||
GET /internal/agents/{agent_id}/system-prompt
|
||||
```
|
||||
Повертає зібраний system prompt для LLM виклику.
|
||||
|
||||
```
|
||||
POST /internal/agents/prompts/status
|
||||
Body: { "agent_ids": ["agent-1", "agent-2"] }
|
||||
```
|
||||
Перевіряє наявність промтів для списку агентів.
|
||||
|
||||
#### DAGI Router Integration
|
||||
|
||||
Створено `services/router/prompt_builder.py`:
|
||||
- `PromptBuilder` клас для побудови system prompts
|
||||
- Пріоритети: БД → router-config → fallback
|
||||
- Автоматичне завантаження контексту (node, district)
|
||||
- `get_agent_system_prompt()` convenience function
|
||||
|
||||
Оновлено `/v1/agents/{agent_id}/infer`:
|
||||
- Автоматично завантажує system prompt з БД
|
||||
- Fallback на router-config.yml
|
||||
- Логування джерела промту
|
||||
|
||||
### 3. UI Індикатори
|
||||
|
||||
#### DAGIRouterCard
|
||||
- 🧠 іконка біля імені агента якщо `has_prompts = true`
|
||||
- Напівпрозора іконка якщо агент active але без промтів
|
||||
- Tooltip з інформацією про статус
|
||||
|
||||
### 4. Файли
|
||||
|
||||
#### Міграції
|
||||
- `migrations/038_agent_prompts_full_coverage.sql` — повний seed
|
||||
|
||||
#### Backend
|
||||
- `services/city-service/repo_city.py`:
|
||||
- `get_runtime_prompts(agent_id)`
|
||||
- `build_system_prompt(agent, prompts, context)`
|
||||
- `get_agent_with_runtime_prompt(agent_id)`
|
||||
- `check_agents_prompts_status(agent_ids)`
|
||||
|
||||
- `services/city-service/routes_city.py`:
|
||||
- Нові endpoints для runtime prompts
|
||||
- `DAGIRouterAgentItem.has_prompts` поле
|
||||
|
||||
#### Router
|
||||
- `services/router/prompt_builder.py` — новий модуль
|
||||
- `services/router/main.py` — інтеграція з prompt_builder
|
||||
|
||||
#### Frontend
|
||||
- `apps/web/src/hooks/useDAGIAudit.ts` — `has_prompts` в типах
|
||||
- `apps/web/src/components/node-dashboard/DAGIRouterCard.tsx` — UI індикатор
|
||||
|
||||
#### Тести
|
||||
- `tests/test_agent_prompts_runtime.py`
|
||||
|
||||
---
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
| Критерій | Статус |
|
||||
|----------|--------|
|
||||
| Всі агенти з Target Coverage мають core prompt | ✅ |
|
||||
| DAGI Router завантажує промти з БД | ✅ |
|
||||
| Fallback на config якщо БД порожня | ✅ |
|
||||
| UI показує індикатор has_prompts | ✅ |
|
||||
| API для batch перевірки статусу | ✅ |
|
||||
| Unit тести | ✅ |
|
||||
|
||||
---
|
||||
|
||||
## Як застосувати
|
||||
|
||||
```bash
|
||||
# 1. Застосувати міграцію
|
||||
docker exec -i dagi-postgres psql -U postgres -d daarion < migrations/038_agent_prompts_full_coverage.sql
|
||||
|
||||
# 2. Перезапустити city-service
|
||||
docker-compose restart daarion-city-service
|
||||
|
||||
# 3. Перезапустити router (опційно)
|
||||
docker-compose restart daarion-router
|
||||
|
||||
# 4. Зібрати frontend
|
||||
cd apps/web && npm run build
|
||||
|
||||
# 5. Запустити тести
|
||||
pytest tests/test_agent_prompts_runtime.py -v
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Наступні кроки (v3)
|
||||
|
||||
1. **Версіонування промтів** — історія змін з rollback
|
||||
2. **A/B testing** — різні версії промтів для тестування
|
||||
3. **Template system** — шаблони з variables
|
||||
4. **Metrics** — трекінг ефективності промтів
|
||||
5. **UI Editor** — advanced editor з preview
|
||||
|
||||
Reference in New Issue
Block a user