@qubiit/lmagent 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +18 -0
- package/AGENTS.md +169 -0
- package/CLAUDE.md +122 -0
- package/CONTRIBUTING.md +90 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/config/commands.yaml +194 -0
- package/config/levels.yaml +135 -0
- package/config/models.yaml +192 -0
- package/config/settings.yaml +405 -0
- package/config/tools-extended.yaml +534 -0
- package/config/tools.yaml +437 -0
- package/docs/assets/logo.png +0 -0
- package/docs/commands.md +132 -0
- package/docs/customization-guide.md +445 -0
- package/docs/getting-started.md +154 -0
- package/docs/how-to-start.md +242 -0
- package/docs/navigation-index.md +227 -0
- package/docs/usage-guide.md +113 -0
- package/install.js +1044 -0
- package/package.json +35 -0
- package/pyproject.toml +182 -0
- package/rules/_bootstrap.md +138 -0
- package/rules/agents-ia.md +607 -0
- package/rules/api-design.md +337 -0
- package/rules/automations-n8n.md +646 -0
- package/rules/code-style.md +570 -0
- package/rules/documentation.md +98 -0
- package/rules/security.md +316 -0
- package/rules/stack.md +395 -0
- package/rules/testing.md +326 -0
- package/rules/workflow.md +353 -0
- package/scripts/create_skill.js +300 -0
- package/scripts/validate_skills.js +283 -0
- package/skills/ai-agent-engineer/SKILL.md +394 -0
- package/skills/ai-agent-engineer/references/agent-patterns.md +149 -0
- package/skills/api-designer/SKILL.md +429 -0
- package/skills/api-designer/references/api-standards.md +13 -0
- package/skills/architect/SKILL.md +285 -0
- package/skills/architect/references/c4-model.md +133 -0
- package/skills/automation-engineer/SKILL.md +352 -0
- package/skills/automation-engineer/references/n8n-patterns.md +127 -0
- package/skills/backend-engineer/SKILL.md +261 -0
- package/skills/backend-engineer/assets/fastapi-project-structure.yaml +74 -0
- package/skills/backend-engineer/references/debugging-guide.md +174 -0
- package/skills/backend-engineer/references/design-patterns.md +208 -0
- package/skills/backend-engineer/scripts/scaffold_backend.py +313 -0
- package/skills/bmad-methodology/SKILL.md +202 -0
- package/skills/bmad-methodology/references/scale-adaptive-levels.md +141 -0
- package/skills/browser-agent/SKILL.md +502 -0
- package/skills/browser-agent/scripts/playwright_setup.ts +16 -0
- package/skills/code-reviewer/SKILL.md +306 -0
- package/skills/code-reviewer/references/code-review-checklist.md +16 -0
- package/skills/data-engineer/SKILL.md +474 -0
- package/skills/data-engineer/assets/pg-monitoring-queries.sql +154 -0
- package/skills/data-engineer/references/index-strategy.md +128 -0
- package/skills/data-engineer/scripts/backup_postgres.py +221 -0
- package/skills/devops-engineer/SKILL.md +547 -0
- package/skills/devops-engineer/references/ci-cd-patterns.md +265 -0
- package/skills/devops-engineer/scripts/docker_healthcheck.py +125 -0
- package/skills/document-generator/SKILL.md +746 -0
- package/skills/document-generator/references/pdf-generation.md +22 -0
- package/skills/frontend-engineer/SKILL.md +532 -0
- package/skills/frontend-engineer/references/accessibility-guide.md +146 -0
- package/skills/frontend-engineer/scripts/audit_bundle.py +144 -0
- package/skills/git-workflow/SKILL.md +374 -0
- package/skills/git-workflow/references/git-flow.md +25 -0
- package/skills/mcp-builder/SKILL.md +471 -0
- package/skills/mcp-builder/references/mcp-server-guide.md +23 -0
- package/skills/mobile-engineer/SKILL.md +502 -0
- package/skills/mobile-engineer/references/platform-guidelines.md +160 -0
- package/skills/orchestrator/SKILL.md +246 -0
- package/skills/orchestrator/references/methodology-routing.md +117 -0
- package/skills/orchestrator/references/persona-mapping.md +85 -0
- package/skills/orchestrator/references/routing-logic.md +110 -0
- package/skills/performance-engineer/SKILL.md +549 -0
- package/skills/performance-engineer/references/caching-patterns.md +181 -0
- package/skills/performance-engineer/scripts/profile_endpoint.py +170 -0
- package/skills/product-manager/SKILL.md +488 -0
- package/skills/product-manager/references/prioritization-frameworks.md +126 -0
- package/skills/prompt-engineer/SKILL.md +433 -0
- package/skills/prompt-engineer/references/prompt-patterns.md +158 -0
- package/skills/qa-engineer/SKILL.md +441 -0
- package/skills/qa-engineer/references/testing-strategy.md +166 -0
- package/skills/qa-engineer/scripts/run_coverage.py +147 -0
- package/skills/scrum-master/SKILL.md +225 -0
- package/skills/scrum-master/references/sprint-ceremonies.md +159 -0
- package/skills/security-analyst/SKILL.md +390 -0
- package/skills/security-analyst/references/owasp-top10.md +188 -0
- package/skills/security-analyst/scripts/audit_security.py +242 -0
- package/skills/seo-auditor/SKILL.md +523 -0
- package/skills/seo-auditor/references/seo-checklist.md +17 -0
- package/skills/spec-driven-dev/SKILL.md +342 -0
- package/skills/spec-driven-dev/references/phase-gates.md +107 -0
- package/skills/supabase-expert/SKILL.md +602 -0
- package/skills/supabase-expert/references/supabase-patterns.md +19 -0
- package/skills/swe-agent/SKILL.md +311 -0
- package/skills/swe-agent/references/trajectory-format.md +134 -0
- package/skills/systematic-debugger/SKILL.md +512 -0
- package/skills/systematic-debugger/references/debugging-guide.md +12 -0
- package/skills/tech-lead/SKILL.md +409 -0
- package/skills/tech-lead/references/code-review-checklist.md +111 -0
- package/skills/technical-writer/SKILL.md +631 -0
- package/skills/technical-writer/references/doc-templates.md +218 -0
- package/skills/testing-strategist/SKILL.md +476 -0
- package/skills/testing-strategist/references/testing-pyramid.md +16 -0
- package/skills/ux-ui-designer/SKILL.md +419 -0
- package/skills/ux-ui-designer/references/design-system-foundation.md +168 -0
- package/skills_overview.txt +94 -0
- package/templates/PROJECT_KICKOFF.md +284 -0
- package/templates/SKILL_TEMPLATE.md +131 -0
- package/templates/USAGE.md +95 -0
- package/templates/agent-python/README.md +71 -0
- package/templates/agent-python/agent.py +272 -0
- package/templates/agent-python/config.yaml +76 -0
- package/templates/agent-python/prompts/system.md +109 -0
- package/templates/agent-python/requirements.txt +7 -0
- package/templates/automation-n8n/README.md +14 -0
- package/templates/automation-n8n/webhook-handler.json +57 -0
- package/templates/backend-node/Dockerfile +12 -0
- package/templates/backend-node/README.md +15 -0
- package/templates/backend-node/package.json +30 -0
- package/templates/backend-node/src/index.ts +19 -0
- package/templates/backend-node/src/routes.ts +7 -0
- package/templates/backend-node/tsconfig.json +22 -0
- package/templates/backend-python/Dockerfile +11 -0
- package/templates/backend-python/README.md +78 -0
- package/templates/backend-python/app/core/config.py +12 -0
- package/templates/backend-python/app/core/database.py +12 -0
- package/templates/backend-python/app/main.py +17 -0
- package/templates/backend-python/app/routers/__init__.py +1 -0
- package/templates/backend-python/app/routers/health.py +7 -0
- package/templates/backend-python/requirements-dev.txt +6 -0
- package/templates/backend-python/requirements.txt +4 -0
- package/templates/backend-python/tests/test_health.py +9 -0
- package/templates/checkpoint.yaml +117 -0
- package/templates/database/README.md +474 -0
- package/templates/frontend-react/README.md +446 -0
- package/templates/plan.yaml +320 -0
- package/templates/session.yaml +125 -0
- package/templates/spec.yaml +229 -0
- package/templates/tasks.yaml +330 -0
- package/workflows/bugfix-backend.md +380 -0
- package/workflows/documentation.md +232 -0
- package/workflows/generate-prd.md +320 -0
- package/workflows/ideation.md +396 -0
- package/workflows/new-agent-ia.md +497 -0
- package/workflows/new-automation.md +374 -0
- package/workflows/new-feature.md +290 -0
- package/workflows/optimize-performance.md +373 -0
- package/workflows/resolve-github-issue.md +524 -0
- package/workflows/security-review.md +291 -0
- package/workflows/spec-driven.md +476 -0
- package/workflows/testing-strategy.md +296 -0
- package/workflows/third-party-integration.md +277 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Workflow para crear o mejorar un agente de IA
|
|
3
|
+
level: 2-3
|
|
4
|
+
personas: [ai-agent-engineer, backend-engineer]
|
|
5
|
+
version: 2.1
|
|
6
|
+
type: workflow
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# New AI Agent Workflow
|
|
10
|
+
|
|
11
|
+
> **Tiempo estimado**: 4-8 horas | **Level**: 2-3
|
|
12
|
+
|
|
13
|
+
Este workflow guía la creación o mejora de un agente de IA.
|
|
14
|
+
|
|
15
|
+
## Pre-requisitos
|
|
16
|
+
|
|
17
|
+
1. Leer [AGENTS.md](../AGENTS.md)
|
|
18
|
+
2. Leer [rules/agents-ia.md](../rules/agents-ia.md)
|
|
19
|
+
3. Leer [personas/ai-agent-engineer.md](../personas/ai-agent-engineer.md)
|
|
20
|
+
|
|
21
|
+
## Información Requerida
|
|
22
|
+
|
|
23
|
+
Antes de comenzar, necesito entender:
|
|
24
|
+
|
|
25
|
+
1. **Propósito del agente**: ¿Qué tarea debe realizar?
|
|
26
|
+
2. **Usuario objetivo**: ¿Quién lo usará? (humano, n8n, otro sistema)
|
|
27
|
+
3. **Herramientas necesarias**: ¿Qué acciones debe poder ejecutar?
|
|
28
|
+
4. **Conocimiento requerido**: ¿Qué contexto/datos necesita?
|
|
29
|
+
5. **Límites**: ¿Qué NO debe poder hacer?
|
|
30
|
+
6. **Modelo preferido**: ¿GPT-4, Claude, Gemini, etc.?
|
|
31
|
+
7. **Presupuesto por ejecución**: ¿Límite de costo?
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Paso 1: Diseñar el Agente
|
|
36
|
+
|
|
37
|
+
### 1.1 Definir Arquitectura
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
¿El agente necesita...?
|
|
41
|
+
|
|
42
|
+
┌──────────────────┐
|
|
43
|
+
│ Usar herramientas│──▶ Tool-based Agent (ReAct)
|
|
44
|
+
└──────────────────┘
|
|
45
|
+
|
|
46
|
+
┌──────────────────┐
|
|
47
|
+
│ Múltiples pasos │──▶ Multi-step Agent
|
|
48
|
+
│ de razonamiento │
|
|
49
|
+
└──────────────────┘
|
|
50
|
+
|
|
51
|
+
┌──────────────────┐
|
|
52
|
+
│ Coordinar otros │──▶ Orchestrator Agent
|
|
53
|
+
│ agentes │
|
|
54
|
+
└──────────────────┘
|
|
55
|
+
|
|
56
|
+
┌──────────────────┐
|
|
57
|
+
│ Solo responder │──▶ Simple LLM Chain
|
|
58
|
+
│ preguntas │
|
|
59
|
+
└──────────────────┘
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 1.2 Definir Herramientas
|
|
63
|
+
|
|
64
|
+
| Tool | Propósito | Parámetros |
|
|
65
|
+
|------|-----------|------------|
|
|
66
|
+
| [tool_name] | [descripción] | [param1, param2, ...] |
|
|
67
|
+
| [tool_name] | [descripción] | [param1, param2, ...] |
|
|
68
|
+
|
|
69
|
+
### 1.3 Definir Prompt del Sistema
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
## Role
|
|
73
|
+
[Descripción del rol del agente]
|
|
74
|
+
|
|
75
|
+
## Available Tools
|
|
76
|
+
[Lista de herramientas con descripciones]
|
|
77
|
+
|
|
78
|
+
## Guidelines
|
|
79
|
+
[Instrucciones de cómo debe comportarse]
|
|
80
|
+
|
|
81
|
+
## Output Format
|
|
82
|
+
[Formato esperado de respuestas]
|
|
83
|
+
|
|
84
|
+
## Constraints
|
|
85
|
+
[Límites y restricciones]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Paso 2: Plan de Implementación
|
|
91
|
+
|
|
92
|
+
### Archivos a Crear
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
## Configuración
|
|
96
|
+
- [ ] `agents/config/agents.yaml` - Registrar agente
|
|
97
|
+
|
|
98
|
+
## Prompts
|
|
99
|
+
- [ ] `agents/python/prompts/personas/{agent_name}.md` - System prompt
|
|
100
|
+
|
|
101
|
+
## Herramientas (si son nuevas)
|
|
102
|
+
- [ ] `agents/python/tools/{tool_name}_tool.py` - Implementación
|
|
103
|
+
- [ ] `agents/config/tools.yaml` - Registrar tool
|
|
104
|
+
|
|
105
|
+
## Tests
|
|
106
|
+
- [ ] `agents/python/tests/test_{agent_name}.py` - Tests del agente
|
|
107
|
+
|
|
108
|
+
## API (si se expone via HTTP)
|
|
109
|
+
- [ ] `app/routers/agents/{agent_name}.py` - Endpoint
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Paso 3: Implementar Herramientas
|
|
115
|
+
|
|
116
|
+
### 3.1 Crear Tool (si es nueva)
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# agents/python/tools/{tool_name}_tool.py
|
|
120
|
+
|
|
121
|
+
from lmagent.tools.base import BaseTool, ToolResult
|
|
122
|
+
from pydantic import Field
|
|
123
|
+
import structlog
|
|
124
|
+
|
|
125
|
+
logger = structlog.get_logger()
|
|
126
|
+
|
|
127
|
+
class {ToolName}Tool(BaseTool):
|
|
128
|
+
"""
|
|
129
|
+
{Descripción de la herramienta}.
|
|
130
|
+
|
|
131
|
+
Usa esta herramienta cuando necesites:
|
|
132
|
+
- [caso de uso 1]
|
|
133
|
+
- [caso de uso 2]
|
|
134
|
+
|
|
135
|
+
NO uses para:
|
|
136
|
+
- [caso donde NO aplica]
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
name: str = "{tool_name}"
|
|
140
|
+
description: str = "{Descripción corta para el LLM}"
|
|
141
|
+
|
|
142
|
+
async def execute(
|
|
143
|
+
self,
|
|
144
|
+
param1: str = Field(..., description="Descripción del parámetro"),
|
|
145
|
+
param2: int = Field(10, description="Parámetro opcional con default")
|
|
146
|
+
) -> ToolResult:
|
|
147
|
+
"""Ejecuta la herramienta."""
|
|
148
|
+
logger.info(
|
|
149
|
+
"{tool_name}_execute",
|
|
150
|
+
param1=param1,
|
|
151
|
+
param2=param2
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
# Implementar lógica
|
|
156
|
+
result = await self._do_work(param1, param2)
|
|
157
|
+
|
|
158
|
+
return ToolResult(
|
|
159
|
+
success=True,
|
|
160
|
+
data=result,
|
|
161
|
+
metadata={"param1": param1}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
except Exception as e:
|
|
165
|
+
logger.error("{tool_name}_error", error=str(e))
|
|
166
|
+
return ToolResult(
|
|
167
|
+
success=False,
|
|
168
|
+
error=str(e),
|
|
169
|
+
metadata={"suggestion": "Sugerencia para el agente"}
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 3.2 Registrar en tools.yaml
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
# agents/config/tools.yaml
|
|
177
|
+
|
|
178
|
+
tools:
|
|
179
|
+
{tool_name}:
|
|
180
|
+
name: "{Tool Name}"
|
|
181
|
+
module: "agents.python.tools.{tool_name}_tool"
|
|
182
|
+
class: "{ToolName}Tool"
|
|
183
|
+
description: "{Descripción}"
|
|
184
|
+
category: "{category}"
|
|
185
|
+
parameters:
|
|
186
|
+
- name: param1
|
|
187
|
+
type: string
|
|
188
|
+
required: true
|
|
189
|
+
description: "Descripción"
|
|
190
|
+
- name: param2
|
|
191
|
+
type: integer
|
|
192
|
+
default: 10
|
|
193
|
+
description: "Descripción"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Paso 4: Crear el Prompt
|
|
199
|
+
> 💡 **Tip**: Pídele al `/prompt` engineer que redacte esto por ti.
|
|
200
|
+
|
|
201
|
+
### 4.1 Escribir System Prompt
|
|
202
|
+
El path estándar es `agents/python/prompts/personas/{agent_name}.md`.
|
|
203
|
+
|
|
204
|
+
```markdown
|
|
205
|
+
# agents/python/prompts/personas/{agent_name}.md
|
|
206
|
+
|
|
207
|
+
You are {Agent Name}, an AI assistant specialized in {domain}.
|
|
208
|
+
|
|
209
|
+
## Your Role
|
|
210
|
+
{Descripción detallada del rol}
|
|
211
|
+
|
|
212
|
+
## Available Tools
|
|
213
|
+
|
|
214
|
+
You have access to the following tools:
|
|
215
|
+
|
|
216
|
+
### {tool_1_name}
|
|
217
|
+
{Descripción de cuándo y cómo usar}
|
|
218
|
+
|
|
219
|
+
### {tool_2_name}
|
|
220
|
+
{Descripción de cuándo y cómo usar}
|
|
221
|
+
|
|
222
|
+
## How to Use Tools
|
|
223
|
+
|
|
224
|
+
When you need to take an action:
|
|
225
|
+
1. Think about which tool is most appropriate
|
|
226
|
+
2. Call the tool with the required parameters
|
|
227
|
+
3. Wait for the result
|
|
228
|
+
4. Use the result to inform your next step or response
|
|
229
|
+
|
|
230
|
+
## Response Guidelines
|
|
231
|
+
|
|
232
|
+
- Be concise and direct
|
|
233
|
+
- When using data from tools, cite the source
|
|
234
|
+
- If a tool fails, explain what happened and try an alternative
|
|
235
|
+
- If you cannot complete a task, explain why
|
|
236
|
+
|
|
237
|
+
## Constraints
|
|
238
|
+
|
|
239
|
+
- Maximum cost per session: ${max_cost}
|
|
240
|
+
- Maximum iterations: {max_iterations}
|
|
241
|
+
- Do not {restriction_1}
|
|
242
|
+
- Do not {restriction_2}
|
|
243
|
+
|
|
244
|
+
## Examples
|
|
245
|
+
|
|
246
|
+
### Example 1: {scenario}
|
|
247
|
+
|
|
248
|
+
User: "{user_input}"
|
|
249
|
+
|
|
250
|
+
Thinking: {thought_process}
|
|
251
|
+
Action: {tool_name}({params})
|
|
252
|
+
Observation: {result}
|
|
253
|
+
Response: "{final_response}"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Paso 5: Configurar el Agente
|
|
259
|
+
|
|
260
|
+
### 5.1 Registrar en agents.yaml
|
|
261
|
+
|
|
262
|
+
```yaml
|
|
263
|
+
# agents/config/agents.yaml
|
|
264
|
+
|
|
265
|
+
agents:
|
|
266
|
+
{agent_name}:
|
|
267
|
+
name: "{Agent Display Name}"
|
|
268
|
+
description: "{Descripción corta}"
|
|
269
|
+
|
|
270
|
+
# LLM Configuration
|
|
271
|
+
model: "gpt-4o" # o claude-sonnet-4, gemini-2.5-pro
|
|
272
|
+
temperature: 0.7
|
|
273
|
+
max_tokens: 4096
|
|
274
|
+
|
|
275
|
+
# Agent Configuration
|
|
276
|
+
max_iterations: 10
|
|
277
|
+
max_cost: 2.00
|
|
278
|
+
|
|
279
|
+
# System Prompt
|
|
280
|
+
system_prompt: "prompts/personas/{agent_name}.md"
|
|
281
|
+
|
|
282
|
+
# Tools
|
|
283
|
+
tools:
|
|
284
|
+
- http_request
|
|
285
|
+
- database_query
|
|
286
|
+
- {custom_tool}
|
|
287
|
+
|
|
288
|
+
# Guardrails
|
|
289
|
+
guardrails:
|
|
290
|
+
require_confirmation: ["database_write", "send_email"]
|
|
291
|
+
blocked_actions: ["delete_production"]
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Paso 6: Exponer via API (Opcional)
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
# app/routers/agents/{agent_name}.py
|
|
300
|
+
|
|
301
|
+
from fastapi import APIRouter
|
|
302
|
+
from pydantic import BaseModel
|
|
303
|
+
|
|
304
|
+
router = APIRouter(prefix="/agents/{agent-name}", tags=["agents"])
|
|
305
|
+
|
|
306
|
+
class AgentRequest(BaseModel):
|
|
307
|
+
input: str
|
|
308
|
+
context: dict = {}
|
|
309
|
+
max_cost: float = 2.00
|
|
310
|
+
|
|
311
|
+
class AgentResponse(BaseModel):
|
|
312
|
+
success: bool
|
|
313
|
+
output: str
|
|
314
|
+
cost: float
|
|
315
|
+
iterations: int
|
|
316
|
+
trajectory_id: str | None = None
|
|
317
|
+
|
|
318
|
+
@router.post("/run")
|
|
319
|
+
async def run_agent(request: AgentRequest) -> AgentResponse:
|
|
320
|
+
"""
|
|
321
|
+
Ejecuta el agente {agent_name}.
|
|
322
|
+
|
|
323
|
+
## Uso en n8n
|
|
324
|
+
|
|
325
|
+
1. HTTP Request node
|
|
326
|
+
2. POST {{$env.BACKEND_URL}}/agents/{agent-name}/run
|
|
327
|
+
3. Body: {"input": "tu pregunta o tarea"}
|
|
328
|
+
"""
|
|
329
|
+
agent = await load_agent("{agent_name}")
|
|
330
|
+
agent.cost_tracker.max_cost = request.max_cost
|
|
331
|
+
|
|
332
|
+
result = await agent.run(
|
|
333
|
+
user_input=request.input,
|
|
334
|
+
context=request.context
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
return AgentResponse(
|
|
338
|
+
success=True,
|
|
339
|
+
output=result,
|
|
340
|
+
cost=agent.cost_tracker.total,
|
|
341
|
+
iterations=agent.iteration_count,
|
|
342
|
+
trajectory_id=agent.trajectory_id
|
|
343
|
+
)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Paso 7: Testing
|
|
349
|
+
|
|
350
|
+
### 7.1 Tests del Agente
|
|
351
|
+
|
|
352
|
+
```python
|
|
353
|
+
# agents/python/tests/test_{agent_name}.py
|
|
354
|
+
|
|
355
|
+
import pytest
|
|
356
|
+
from unittest.mock import AsyncMock, patch
|
|
357
|
+
|
|
358
|
+
class TestAgent{AgentName}:
|
|
359
|
+
"""Tests para {agent_name}."""
|
|
360
|
+
|
|
361
|
+
@pytest.mark.asyncio
|
|
362
|
+
async def test_basic_query(self, agent):
|
|
363
|
+
"""Debe responder a query básica."""
|
|
364
|
+
result = await agent.run("Test query")
|
|
365
|
+
assert result is not None
|
|
366
|
+
assert len(result) > 0
|
|
367
|
+
|
|
368
|
+
@pytest.mark.asyncio
|
|
369
|
+
async def test_uses_correct_tool(self, agent, mock_llm):
|
|
370
|
+
"""Debe usar la herramienta correcta."""
|
|
371
|
+
mock_llm.return_value = MockResponse(
|
|
372
|
+
tool_calls=[{"name": "{tool_name}", "args": {...}}]
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
with patch.object(agent.tools['{tool_name}'], 'execute') as mock_tool:
|
|
376
|
+
mock_tool.return_value = ToolResult(success=True, data={})
|
|
377
|
+
await agent.run("Query that requires {tool_name}")
|
|
378
|
+
mock_tool.assert_called_once()
|
|
379
|
+
|
|
380
|
+
@pytest.mark.asyncio
|
|
381
|
+
async def test_handles_tool_error(self, agent):
|
|
382
|
+
"""Debe manejar errores de tools."""
|
|
383
|
+
with patch.object(agent.tools['{tool_name}'], 'execute') as mock_tool:
|
|
384
|
+
mock_tool.return_value = ToolResult(
|
|
385
|
+
success=False,
|
|
386
|
+
error="Simulated error"
|
|
387
|
+
)
|
|
388
|
+
result = await agent.run("Query")
|
|
389
|
+
# Debería manejar el error gracefully
|
|
390
|
+
assert "error" in result.lower() or agent.iteration_count > 1
|
|
391
|
+
|
|
392
|
+
@pytest.mark.asyncio
|
|
393
|
+
async def test_respects_cost_limit(self, agent):
|
|
394
|
+
"""Debe respetar límite de costo."""
|
|
395
|
+
agent.cost_tracker.max_cost = 0.001 # Muy bajo
|
|
396
|
+
|
|
397
|
+
with pytest.raises(CostLimitExceeded):
|
|
398
|
+
await agent.run("Expensive query")
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### 7.2 Test Manual
|
|
402
|
+
|
|
403
|
+
1. Ejecutar agente con queries de ejemplo
|
|
404
|
+
2. Verificar que usa tools correctamente
|
|
405
|
+
3. Verificar manejo de errores
|
|
406
|
+
4. Verificar límites de costo
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Paso 8: Documentación
|
|
411
|
+
|
|
412
|
+
### Documentar en README del agente
|
|
413
|
+
|
|
414
|
+
```markdown
|
|
415
|
+
# {Agent Name}
|
|
416
|
+
|
|
417
|
+
## Descripción
|
|
418
|
+
{Qué hace este agente}
|
|
419
|
+
|
|
420
|
+
## Uso
|
|
421
|
+
|
|
422
|
+
### Via Python
|
|
423
|
+
```python
|
|
424
|
+
from agents.python.runner import load_agent
|
|
425
|
+
|
|
426
|
+
agent = await load_agent("{agent_name}")
|
|
427
|
+
result = await agent.run("Tu pregunta o tarea")
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Via API
|
|
431
|
+
```bash
|
|
432
|
+
curl -X POST {backend_url}/agents/{agent-name}/run \
|
|
433
|
+
-H "Content-Type: application/json" \
|
|
434
|
+
-d '{"input": "Tu pregunta o tarea"}'
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Via n8n
|
|
438
|
+
[Instrucciones de configuración]
|
|
439
|
+
|
|
440
|
+
## Herramientas Disponibles
|
|
441
|
+
| Tool | Descripción |
|
|
442
|
+
|------|-------------|
|
|
443
|
+
| {tool_1} | {descripción} |
|
|
444
|
+
| {tool_2} | {descripción} |
|
|
445
|
+
|
|
446
|
+
## Ejemplos
|
|
447
|
+
[Ejemplos de uso con inputs y outputs]
|
|
448
|
+
|
|
449
|
+
## Límites
|
|
450
|
+
- Costo máximo: ${max_cost}
|
|
451
|
+
- Iteraciones máximas: {max_iterations}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Checklist Final
|
|
457
|
+
|
|
458
|
+
### Implementación
|
|
459
|
+
- [ ] Prompt del sistema escrito y probado
|
|
460
|
+
- [ ] Herramientas implementadas (si nuevas)
|
|
461
|
+
- [ ] Agente registrado en agents.yaml
|
|
462
|
+
- [ ] API endpoint creado (si aplica)
|
|
463
|
+
|
|
464
|
+
### Testing
|
|
465
|
+
- [ ] Tests unitarios pasando
|
|
466
|
+
- [ ] Test manual con casos de uso reales
|
|
467
|
+
- [ ] Verificación de límites de costo
|
|
468
|
+
|
|
469
|
+
### Documentación
|
|
470
|
+
- [ ] README del agente
|
|
471
|
+
- [ ] Ejemplos de uso
|
|
472
|
+
- [ ] Documentación para n8n (si aplica)
|
|
473
|
+
|
|
474
|
+
### Seguridad
|
|
475
|
+
- [ ] Guardrails configurados
|
|
476
|
+
- [ ] Permisos de tools revisados
|
|
477
|
+
- [ ] Logging de auditoría habilitado
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## 🛠️ Herramientas Sugeridas
|
|
482
|
+
|
|
483
|
+
| Fase | Herramienta |
|
|
484
|
+
|------|-------------|
|
|
485
|
+
| Diseño | `write_to_file` (prompts, configs) |
|
|
486
|
+
| Implementación | `run_command` (tests), `view_file` |
|
|
487
|
+
| Testing | `run_command` (evals), `browser_subagent` |
|
|
488
|
+
| Docs | `mcp_context7_query-docs` (LangChain, etc.) |
|
|
489
|
+
|
|
490
|
+
## ⚠️ Errores Comunes
|
|
491
|
+
|
|
492
|
+
| Error | Solución |
|
|
493
|
+
|-------|----------|
|
|
494
|
+
| Tools sin schema estricto | SIEMPRE definir con Pydantic/Field |
|
|
495
|
+
| Sin limite de costo | Configurar `max_cost` desde el inicio |
|
|
496
|
+
| Prompt vago | Ser específico en rol, tools y constraints |
|
|
497
|
+
| Sin evals | Implementar tests de Faithfulness y Tool Accuracy |
|