Self-debug
Agents that read their own traces, diagnose failures, retry with corrections.
#Pattern
- Run fails or produces low-confidence output.
- Feed the trace (steps, tool calls, errors) back to the agent.
- Agent proposes a fix (different tool, different arg, smaller step).
- Retry with the fix applied.
#Sketch
import { createDurableRunner } from '@agentskit/runtime'
const res = await durable.run({ runId, input })
if (res.status === 'error') {
const trace = await durable.getTrace(runId)
const fix = await debuggerRuntime.run({
input: `Trace failed. Diagnose and suggest fix.\n\n${JSON.stringify(trace)}`,
})
await durable.run({ runId: `${runId}-retry`, input: fix.output })
}#Related
Explore nearby
- PeerAgents
Everything that runs the loop β runtime, tools, skills, delegation, durable execution, topologies, background agents, HITL, self-debug.
- PeerRuntime
Execution engine for autonomous agents β runs a ReAct loop (observe, think, act) until final answer or step limit.
- PeerMulti-Agent Delegation
Coordinate multiple specialist agents from a parent agent using directed delegation.