• 401 Unauthorized: API key missing or wrong. Check .env, then run php artisan config:clear.
  • 404 / model not found: Your account may not have that model. Set OPENAI_MODEL in .env to one listed in your OpenAI dashboard.
  • 429 Too Many Requests: Rate limit or no credit left. Wait, or add billing in the OpenAI dashboard.
  • Undefined array key "content": You assumed output[0] is a message. Use Agent::text($response), which finds the message items.
  • Agent repeats the same answer forever: A return or break is missing when there are no function calls.
  • Invalid type for output: expected a string: A tool returned a number or array. Cast it with (string) or json_encode it.
  • Missing required parameter: tools[0]…: You sent tool objects instead of $tool->definition().
  • expected an object but got an array (text.format): You sent an empty schema. Only add text.format when schema() is not empty.
  • Agent forgets everything each message: The agent is created inside the while loop. Create it once, before the loop.
  • Class "App\Ai\…" not found: Check the file path matches the namespace exactly, including capital letters.
  • Command hangs with no output: Tools are running inside the spinner. Wait, or watch the Running tool: lines.
  • Request timed out: Long answers take time. The Agent sets Http::timeout(120); raise it if needed.