Skip to content

Troubleshooting

Common issues and solutions.

Set API keys:

Terminal window
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="..."

Use built-in retry:

.withRetry({ retries: 5, minTimeout: 2000 })

Improve description:

description: 'ALWAYS use this for ANY math calculation.',

Add to system prompt:

.withSystem('Use FloppyDisk to calculate disk requirements.')

Add .describe() to schema:

schema: z.object({
number: z.number().describe('Must be a number'),
})

Increase timeout:

class SlowGadget extends Gadget({
timeoutMs: 60000,
}) {}
// Or globally
.withDefaultGadgetTimeout(30000)

Increase iterations:

.withMaxIterations(20)

Add termination gadget:

class Done extends Gadget({
description: 'Call when task is complete',
schema: z.object({ summary: z.string() }),
}) {
execute(params) {
throw new TaskCompletionSignal(params.summary);
}
}

Register handler:

.onHumanInput(async (question) => {
return await getUserInput(question);
})

Consume the stream:

// Wrong
const agent = builder.ask('prompt');
// Right
const answer = await builder.askAndCollect('prompt');
// Or
for await (const event of agent.run()) {}

Use broader matchers:

mockLLM().forAnyModel()

Clear in beforeEach:

beforeEach(() => {
getMockManager().clear();
});
  1. Enable monitoring:
.withHooks(HookPresets.monitoring())
  1. Check the Debugging Guide

  2. Open an issue