Troubleshooting
Common issues and solutions.
Provider Issues
Section titled “Provider Issues””No LLM providers available”
Section titled “”No LLM providers available””Set API keys:
export OPENAI_API_KEY="sk-..."export ANTHROPIC_API_KEY="sk-ant-..."export GEMINI_API_KEY="..."Rate Limits / 429 Errors
Section titled “Rate Limits / 429 Errors”Use built-in retry:
.withRetry({ retries: 5, minTimeout: 2000 })Gadget Issues
Section titled “Gadget Issues”Gadget Not Being Called
Section titled “Gadget Not Being Called”Improve description:
description: 'ALWAYS use this for ANY math calculation.',Add to system prompt:
.withSystem('Use FloppyDisk to calculate disk requirements.')Parameter Validation Failed
Section titled “Parameter Validation Failed”Add .describe() to schema:
schema: z.object({ number: z.number().describe('Must be a number'),})Gadget Timeout
Section titled “Gadget Timeout”Increase timeout:
class SlowGadget extends Gadget({ timeoutMs: 60000,}) {}
// Or globally.withDefaultGadgetTimeout(30000)Agent Loop Issues
Section titled “Agent Loop Issues”Agent Stuck in Loop
Section titled “Agent Stuck in Loop”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); }}Human Input Not Working
Section titled “Human Input Not Working”Register handler:
.onHumanInput(async (question) => { return await getUserInput(question);})Streaming Issues
Section titled “Streaming Issues”No Output / Empty Response
Section titled “No Output / Empty Response”Consume the stream:
// Wrongconst agent = builder.ask('prompt');
// Rightconst answer = await builder.askAndCollect('prompt');
// Orfor await (const event of agent.run()) {}Testing Issues
Section titled “Testing Issues”Mock Not Matching
Section titled “Mock Not Matching”Use broader matchers:
mockLLM().forAnyModel()Mocks Persisting
Section titled “Mocks Persisting”Clear in beforeEach:
beforeEach(() => { getMockManager().clear();});Still Stuck?
Section titled “Still Stuck?”- Enable monitoring:
.withHooks(HookPresets.monitoring())-
Check the Debugging Guide