agent_error_learning
Report agent errors, record solutions, and track failed attempts with a 2-strike protocol to help agents learn from mistakes and avoid recurrence.
Instructions
Enable agents to learn from errors using a 2-strike protocol.
Usage Examples: // Report a new error agent_error_learning({ action: "report", agentId: "backend-dev", errorSignature: "TypeError: Cannot read property 'x' of undefined", errorMessage: "Undefined property access in user service", contextSnapshot: "const name = user.profile.name; // user.profile is undefined", attemptedSolution: "Added optional chaining: user.profile?.name", projectContext: "api-service" })
// Mark error as solved agent_error_learning({ action: "solve", agentId: "backend-dev", patternId: "err-pattern-123", solution: "Always check if user.profile exists before accessing properties", verificationSteps: [ "Run: npm test user.service.spec.ts", "Verify no TypeErrors in logs", "Check user profile endpoint returns 200" ] })
// Record failed attempt agent_error_learning({ action: "fail", agentId: "frontend-dev", patternId: "err-pattern-456", attemptedSolution: "Tried using default values but still crashed" })
The 2-Strike Protocol:
First encounter: Agent gets the error signature to recognize it
Second encounter: Agent must solve it or face consequences
After 2 failures: Error importance increases, agent status may change
Response Types:
first_occurrence: New error, pattern ID provided
solution_found: Previous solution exists
previous_attempts_failed: Shows attempt count (pressure!)
new_problem: Similar to other errors but unique
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform | |
| agentId | Yes | Agent ID | |
| errorSignature | No | Unique error identifier (for report) | |
| errorMessage | No | Error message (for report) | |
| contextSnapshot | No | Code/context where error occurred | |
| attemptedSolution | No | What was tried | |
| projectContext | No | Project name | |
| patternId | No | Error pattern ID (for solve/fail) | |
| solution | No | Working solution (for solve) | |
| verificationSteps | No | How to verify the fix |