agentbay_record_failure
Record a failed approach or lesson learned with project, task, and file context, and severity to build a knowledge base that prevents future agents from repeating costly mistakes.
Instructions
Record a failed approach or lesson learned so future agents avoid repeating it
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| title | Yes | Short description of what failed | |
| content | Yes | What was tried, why it failed, and what to do instead | |
| taskId | No | Related task ID | |
| filePaths | No | Files involved in the failure | |
| severity | No | How costly this failure was |
Implementation Reference
- src/index.ts:597-606 (handler)The actual handler function for the agentbay_record_failure tool. It calls the API to record a failure as a PITFALL-type knowledge entry with tags ['failure', 'lesson-learned'] and a severity-based tag, then returns the result.
async ({ projectId, title, content, taskId, filePaths, severity }) => { const tags = ['failure', 'lesson-learned']; if (severity) tags.push(`severity:${severity}`); const data = await apiPost(`/api/v1/projects/${projectId}/knowledge`, { type: 'PITFALL', title, content, tags, filePaths, confidence: 0.9, taskId, source: 'mcp-server', }); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; return { content: [{ type: 'text' as const, text: `Failure recorded: "${data.title}"\nID: ${data.id}\nThis will be shown to future agents during session_resume.` }] }; } ); - src/index.ts:589-596 (schema)Input schema (Zod) for agentbay_record_failure, defining parameters: projectId (required), title, content, taskId, filePaths, and severity.
{ projectId: z.string().describe('Project ID'), title: z.string().describe('Short description of what failed'), content: z.string().describe('What was tried, why it failed, and what to do instead'), taskId: z.string().optional().describe('Related task ID'), filePaths: z.array(z.string()).optional().describe('Files involved in the failure'), severity: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('How costly this failure was'), }, - src/index.ts:586-606 (registration)Registration of the tool named 'agentbay_record_failure' via server.tool() with description 'Record a failed approach or lesson learned so future agents avoid repeating it'.
server.tool( 'agentbay_record_failure', 'Record a failed approach or lesson learned so future agents avoid repeating it', { projectId: z.string().describe('Project ID'), title: z.string().describe('Short description of what failed'), content: z.string().describe('What was tried, why it failed, and what to do instead'), taskId: z.string().optional().describe('Related task ID'), filePaths: z.array(z.string()).optional().describe('Files involved in the failure'), severity: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('How costly this failure was'), }, async ({ projectId, title, content, taskId, filePaths, severity }) => { const tags = ['failure', 'lesson-learned']; if (severity) tags.push(`severity:${severity}`); const data = await apiPost(`/api/v1/projects/${projectId}/knowledge`, { type: 'PITFALL', title, content, tags, filePaths, confidence: 0.9, taskId, source: 'mcp-server', }); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; return { content: [{ type: 'text' as const, text: `Failure recorded: "${data.title}"\nID: ${data.id}\nThis will be shown to future agents during session_resume.` }] }; } );