How to Fix 'timeout error' in CrewAI (TypeScript)

By Cyprian AaronsUpdated 2026-04-21
timeout-errorcrewaitypescript

What the timeout error means

In CrewAI TypeScript, a timeout error usually means one of your agent tasks took longer than the configured limit, or the underlying LLM call never returned in time. You’ll typically see it when a tool call hangs, a task loops too long, or your model/provider is slow under load.

The error often shows up as something like:

Error: Request timed out after 30000ms

or, depending on where it fails:

CrewAITimeoutError: Task execution exceeded timeout

The Most Common Cause

The #1 cause is a task that waits on an external dependency without a timeout of its own. In TypeScript projects, this usually happens inside a tool function or async task handler that never resolves fast enough for CrewAI’s execution window.

Here’s the broken pattern versus the fixed pattern.

BrokenFixed
No timeout on external requestExplicit timeout with abort handling
Task waits forever if API stallsFails fast and returns a controlled error
// ❌ Broken: hangs if the upstream API stalls
import { Agent, Task, Crew } from "crewai";

const fetchCustomerData = async (customerId: string) => {
  const res = await fetch(`https://api.example.com/customers/${customerId}`);
  return await res.json();
};

const agent = new Agent({
  name: "SupportAgent",
  goal: "Look up customer details",
});

const task = new Task({
  description: "Fetch customer data for account review",
  agent,
  tool: async () => fetchCustomerData("123"),
});

await new Crew({
  agents: [agent],
  tasks: [task],
}).kickoff();
// ✅ Fixed: bounded external call with AbortController
import { Agent, Task, Crew } from "crewai";

const fetchCustomerData = async (customerId: string) => {
  const controller = new AbortController();
  const timeout = setTimeout(() => controller.abort(), 8000);

  try {
    const res = await fetch(`https://api.example.com/customers/${customerId}`, {
      signal: controller.signal,
    });

    if (!res.ok) {
      throw new Error(`Upstream returned ${res.status}`);
    }

    return await res.json();
  } finally {
    clearTimeout(timeout);
  }
};

const agent = new Agent({
  name: "SupportAgent",
  goal: "Look up customer details",
});

const task = new Task({
  description: "Fetch customer data for account review",
  agent,
  tool: async () => fetchCustomerData("123"),
});

await new Crew({
  agents: [agent],
  tasks: [task],
}).kickoff();

If you’re calling internal services, database clients, or third-party APIs from tools, add timeouts there first. CrewAI can only finish after your code returns.

Other Possible Causes

1. Model provider latency or rate limiting

If your LLM provider is slow or throttling you, CrewAI will sit waiting until the request times out.

const agent = new Agent({
  name: "Analyst",
  goal: "Summarize policy documents",
  llmConfig: {
    model: "gpt-4o",
    timeoutMs: 60000,
    maxRetries: 2,
  },
});

If you’re seeing intermittent failures, check provider status and rate limits before changing your crew logic.

2. Recursive delegation or runaway task loops

A crew can burn through its time budget if an agent keeps delegating without reaching completion.

// Bad pattern: open-ended delegation
const agent = new Agent({
  name: "Planner",
  goal: "Keep refining until perfect",
  allowDelegation: true,
});

Fix it by constraining iterations and making completion criteria explicit.

const agent = new Agent({
  name: "Planner",
  goal: "Produce a final plan in at most two passes",
  allowDelegation: false,
});

3. Tool functions doing heavy CPU work

If your tool parses huge PDFs, runs OCR, or transforms large datasets synchronously, Node will block and CrewAI will look like it timed out.

// Bad: blocking CPU work inside a tool
tool: async () => {
  const result = expensivePdfParse(bigBuffer);
  return result;
}

Move heavy work to:

  • a background job
  • a worker thread
  • a separate service with its own timeout

4. Misconfigured environment variables

A missing API key or wrong endpoint can cause retries that end in timeout rather than an obvious auth failure.

# Example checks
CREWAI_LLM_TIMEOUT=30000
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=...

Also verify:

  • correct base URL for self-hosted models
  • proxy settings in CI/CD
  • no stale secrets in local .env files

How to Debug It

  1. Find the exact layer that times out

    • Is it the crew kickoff?
    • A specific Task?
    • A custom tool function? Add logs before and after every async boundary.
  2. Reduce the crew to one task

    • Remove delegation.
    • Remove all tools except one.
    • Use a small prompt.

    If the timeout disappears, re-add pieces until it breaks again.

  3. Wrap external calls with explicit timeouts

    • Fetch requests should use AbortController.
    • Database queries should use driver-level query timeouts.
    • SDK calls should have per-request limits.
  4. Inspect retries and provider latency

    • Check whether your SDK is retrying silently.
    • Measure response times directly against the model API.
    • Compare local runs vs CI runs to rule out network issues.

A practical logging pattern looks like this:

console.time("crew kickoff");
try {
  const result = await crew.kickoff();
  console.log(result);
} catch (err) {
  console.error("Crew failed:", err);
} finally {
    console.timeEnd("crew kickoff");
}

If crew.kickoff() is fast but one tool is slow, you’ve found the bottleneck. If everything is slow from the start, focus on model/provider configuration first.

Prevention

  • Put hard timeouts on every external dependency used by tools.
  • Keep tasks small and deterministic; avoid “do everything” prompts.
  • Set explicit limits on delegation, retries, and iteration count.
  • Add structured logs around Agent, Task, and Crew.kickoff() so you can isolate failures quickly.

If you’re building production crews in TypeScript, treat timeouts as part of the contract for every tool and every upstream call. That’s what keeps one slow dependency from taking down the whole workflow.


Keep learning

By Cyprian Aarons, AI Consultant at Topiax.

Want the complete 8-step roadmap?

Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.

Get the Starter Kit

Related Guides