agentskit.js

Self-debug

Agents that read their own traces, diagnose failures, retry with corrections.

#Pattern

  1. Run fails or produces low-confidence output.
  2. Feed the trace (steps, tool calls, errors) back to the agent.
  3. Agent proposes a fix (different tool, different arg, smaller step).
  4. 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 })
}

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page