How to Fix 'callback not firing' in CrewAI (TypeScript)
If you’re seeing callback not firing in CrewAI with TypeScript, it usually means the agent or task completed, but your callback never got invoked. In practice, this shows up when the callback is attached in the wrong place, has the wrong signature, or gets lost because of async handling.
This is usually not a CrewAI “core bug”. It’s almost always a wiring issue between your Agent, Task, and the callback function you passed into Crew or Task.
The Most Common Cause
The #1 cause is passing the callback in a way CrewAI TypeScript does not actually consume. In most cases, developers attach it to the wrong object or use a shape that looks correct but never reaches the execution path.
Here’s the broken pattern I see most often:
| Broken | Fixed |
|---|---|
| Callback attached to the wrong place | Callback attached where CrewAI actually reads it |
| Async function not awaited | Proper async callback with awaited execution |
| Wrong parameter shape | Correct signature for task output |
import { Agent, Task, Crew } from "crewai";
const agent = new Agent({
role: "Support Analyst",
goal: "Summarize customer issues",
backstory: "You handle support tickets",
});
const task = new Task({
description: "Summarize this ticket",
agent,
});
const crew = new Crew({
agents: [agent],
tasks: [task],
// ❌ Broken: this callback is ignored in many setups
callback: (result) => {
console.log("Task finished:", result);
},
});
await crew.kickoff();
The fixed version:
import { Agent, Task, Crew } from "crewai";
const agent = new Agent({
role: "Support Analyst",
goal: "Summarize customer issues",
backstory: "You handle support tickets",
});
const task = new Task({
description: "Summarize this ticket",
agent,
// ✅ Put the callback on the task if your version expects task-level hooks
callback: async (output) => {
console.log("Task finished:", output.raw);
},
});
const crew = new Crew({
agents: [agent],
tasks: [task],
});
await crew.kickoff();
The important detail is this: some versions and wrappers only trigger callbacks at task level, not crew level. If you attach it to Crew and nothing happens, that’s not mysterious — it’s just not part of the execution contract for your installed package version.
Other Possible Causes
1. Your callback is synchronous but throws before logging
If your callback throws early, it can look like it never fired.
// Broken
callback: (output) => {
JSON.parse(output.raw); // throws if raw is not valid JSON
console.log("done");
}
// Fixed
callback: async (output) => {
try {
const data = JSON.parse(output.raw);
console.log("done", data);
} catch (err) {
console.error("Callback failed:", err);
}
}
2. You’re using the wrong output property
CrewAI outputs are often wrapped. Logging result directly may show [object Object], or you may be reading a field that doesn’t exist.
// Broken
callback: (output) => {
console.log(output.text); // may be undefined
}
// Fixed
callback: (output) => {
console.log(output.raw);
console.log(output.json ?? output.output ?? output.result);
}
3. The task never actually runs
If your crew has zero executable tasks, an invalid agent config, or an upstream failure, there’s no callback to fire.
// Broken
const crew = new Crew({
agents: [agent],
tasks: [], // nothing runs
});
// Fixed
const task = new Task({
description: "Summarize ticket",
agent,
});
const crew = new Crew({
agents: [agent],
tasks: [task],
});
Also check for runtime errors like:
- •
Error: No tasks provided - •
Error: Agent missing goal - •
Error during kickoff
Those errors happen before any callback path is reached.
4. You forgot to await kickoff
If you don’t await execution, your process can exit before callbacks flush.
// Broken
crew.kickoff();
console.log("exiting");
// Fixed
await crew.kickoff();
console.log("completed");
This matters a lot in Node scripts, serverless handlers, and test runners.
How to Debug It
- •
Confirm the exact object receiving the callback
- •Check whether your installed CrewAI TS version expects callbacks on
Task,Agent, orCrew. - •Search your dependency docs or source for
callbackusage.
- •Check whether your installed CrewAI TS version expects callbacks on
- •
Add a hard log at the top of the callback
- •Don’t inspect fields first.
- •Start with:
callback: (output) => { console.log("CALLBACK HIT", output); }
- •
Wrap kickoff in try/catch
- •Many “callback not firing” cases are actually hidden kickoff failures.
try { await crew.kickoff(); } catch (err) { console.error("Kickoff failed:", err); } - •
Verify execution order
- •Add logs before kickoff, inside the callback, and after kickoff.
- •If you see “before” and “after” but not “inside”, your hook isn’t wired correctly.
- •If you never see “after”, your process may be exiting early or hanging on an unresolved promise.
Prevention
- •Attach callbacks only where your CrewAI TypeScript version documents them.
- •Treat every callback as async-safe and wrap parsing logic in
try/catch. - •Always
await crew.kickoff()in scripts, tests, and server handlers.
If you’re still stuck after checking those points, compare your installed package version against the docs or source for that exact release. With CrewAI TS, these issues are usually version-specific wiring problems rather than runtime magic.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
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