Implement self-healing system Phase 1: Error capture and logging

- Add SelfHealingSystem with error observation infrastructure
- Capture errors with full context: type, message, stack trace, intent, inputs
- Log to MEMORY.md with deduplication (max 3 attempts per error signature)
- Integrate error capture in agent, tools, runtime, and scheduler
- Non-invasive: preserves all existing error handling behavior
- Foundation for future diagnosis and auto-fixing capabilities

Phase 1 of 4-phase rollout - observation only, no auto-fixing yet.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 18:03:42 -07:00
parent 0eb5d2cab4
commit f018800d94
5 changed files with 178 additions and 2 deletions

View File

@@ -345,6 +345,17 @@ class TaskScheduler:
print(f"[Scheduler] Task failed: {task.name}")
print(f" Error: {e}")
traceback.print_exc()
if self.agent and hasattr(self.agent, 'healing_system'):
self.agent.healing_system.capture_error(
error=e,
component="scheduled_tasks.py:_execute_task",
intent=f"Executing scheduled task: {task.name}",
context={
"task_name": task.name,
"schedule": task.schedule,
"prompt": task.prompt[:100],
},
)
async def _send_to_platform(
self, task: ScheduledTask, response: str