Skip to main content
This guide covers common issues encountered when building and deploying AFK agents, with solutions and debugging tips.

Agent behavior issues

Agent keeps calling the same tool repeatedly

Symptoms: Agent enters a loop, calling the same tool multiple times without making progress. Causes:
  • Tool output doesn’t provide the information the agent needs
  • Agent instructions don’t clarify when to stop
  • Missing a tool that would help the agent determine completion
Solutions:
Debug: Enable verbose logging to see tool call inputs/outputs:

Agent ignores tools and doesn’t call them

Symptoms: Agent responds with text but doesn’t use available tools. Causes:
  • Instructions don’t mention the tools or when to use them
  • Tool descriptions are unclear
  • Model being used doesn’t support function calling well
Solutions:

Agent produces inconsistent outputs

Symptoms: Same input produces different outputs on different runs. Causes:
  • Temperature is set too high
  • Missing structured output configuration
  • Non-deterministic system prompt
Solutions:

Memory issues

Conversation doesn’t persist between runs

Symptoms: Agent doesn’t remember previous messages. Causes:
  • Not using thread_id to link conversations
  • Memory store not configured correctly
  • Using in-memory store (loses state on restart)
Solution:
Check memory backend:

Resume doesn’t work

Symptoms: Calling runner.resume() doesn’t continue from where the run stopped. Solutions:
Debug checkpoints:

LLM issues

Rate limit errors

Symptoms: RateLimitError or 429 responses from LLM provider. Solutions:

Timeout errors

Symptoms: Requests hang or timeout before completing. Solutions:

Model not found errors

Symptoms: ModelNotFoundError or InvalidRequestError. Solutions:

Streaming issues

Streaming doesn’t work

Symptoms: run_stream() doesn’t return events or returns them all at once. Solutions:

Streaming disconnects early

Symptoms: Stream ends before completion. Solutions:

Cost issues

Unexpected high costs

Symptoms: API costs much higher than expected. Causes:
  • Agent in a loop making many LLM calls
  • No cost limits configured
  • Expensive model being used unnecessarily
Solutions:

Token limit errors

Symptoms: ContextLengthExceeded or similar errors. Solutions:

Tool issues

Tool validation errors

Symptoms: ToolValidationError when tools are called. Solutions:

Tool not found errors

Symptoms: Agent can’t find or call a tool. Solutions:

Debug mode

Enable debug mode for detailed logging:

Getting help

If you can’t resolve an issue:
  1. Check the GitHub Issues for known issues
  2. Enable debug logging and capture the full traceback
  3. Include these details when reporting:
    • AFK version (pip show afk)
    • Python version
    • LLM provider and model
    • Minimal reproduction code
    • Full error traceback

Next steps

Core Concepts

Understand how AFK components work together.

Evals

Test agent behavior before shipping.

Building with AI

Common patterns and anti-patterns.

API Reference

Detailed API documentation.