feat: implement multi-bot orchestration system with LLM routing
Implementa el sistema de orquestación para salas Matrix con múltiples bots. El orquestador es un "special agent" sin identidad Matrix que coordina qué bot responde y cuándo, usando LLM (Claude) para routing y evaluación de calidad. Cambios principales: - pkg/orchestration/task.go: tipos puros (TaskEvent, BotResponse, QualityScore, RoutingDecision) - shell/orchestration/: runtime del orquestador (orchestrator.go, router.go, evaluator.go) - agents/specials/orchestrator/: config + prompts (routing, quality, refinement) - internal/config/: SpecialConfig, OrchestrationCfg, LoadSpecial() - shell/bus/bus.go: protocolo request-reply (SendAndWait, Reply) para delegación - shell/matrix/listener.go: InterceptFunc para interceptar eventos en salas orquestadas - agents/runtime.go: SetBus, listenBus, handleTaskEvent para recibir tareas del orquestador - cmd/launcher/main.go: creación de bus compartido, arranque del orquestador antes de bots Incluye deduplicación para evitar que múltiples listeners en la misma sala disparen el orquestador más de una vez por mensaje. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
special:
|
||||
id: orchestrator
|
||||
type: orchestrator
|
||||
enabled: true
|
||||
description: "Middleware de coordinación multi-bot. Sin identidad Matrix."
|
||||
|
||||
llm:
|
||||
primary:
|
||||
provider: anthropic
|
||||
model: claude-sonnet-4-6
|
||||
api_key_env: ANTHROPIC_API_KEY
|
||||
max_tokens: 512
|
||||
temperature: 0.2
|
||||
|
||||
orchestration:
|
||||
max_iterations: 3
|
||||
quality_threshold: 0.8
|
||||
delegation_timeout: 30s
|
||||
rooms:
|
||||
- room_id: "${MATRIX_ROOM_SHARED}"
|
||||
participants:
|
||||
- assistant-bot
|
||||
- asistente-2
|
||||
@@ -0,0 +1,11 @@
|
||||
You are a quality evaluator for AI agent responses. Evaluate whether the response fully and correctly answers the user's question.
|
||||
|
||||
Criteria:
|
||||
- Accuracy: Is the information correct?
|
||||
- Completeness: Does it address all parts of the question?
|
||||
- Usefulness: Is the response actionable and helpful?
|
||||
|
||||
Respond ONLY with valid JSON (no markdown, no extra text):
|
||||
{"score": <0.0-1.0>, "continue": <true|false>, "reason": "<brief explanation>"}
|
||||
|
||||
Set "continue" to true only if the response is clearly incomplete or incorrect and another agent could do better.
|
||||
@@ -0,0 +1,10 @@
|
||||
The previous response needs improvement. Choose the best agent to complement or improve the answer.
|
||||
|
||||
Available agents (the previous respondent has been excluded):
|
||||
{{PARTICIPANTS}}
|
||||
|
||||
Previous response that needs improvement:
|
||||
{{LAST_RESPONSE}}
|
||||
|
||||
Respond ONLY with valid JSON (no markdown, no extra text):
|
||||
{"bot_id": "<agent_id>", "reason": "<brief explanation of why this agent can improve>"}
|
||||
@@ -0,0 +1,9 @@
|
||||
You are an AI agent coordinator. Your job is to decide which agent should respond to a user's question.
|
||||
|
||||
Available agents:
|
||||
{{PARTICIPANTS}}
|
||||
|
||||
Analyze the user's question and choose the single best agent to handle it based on their descriptions and capabilities.
|
||||
|
||||
Respond ONLY with valid JSON (no markdown, no extra text):
|
||||
{"bot_id": "<agent_id>", "confidence": <0.0-1.0>, "reason": "<brief explanation>"}
|
||||
Reference in New Issue
Block a user