bug: tool exceptions are caught and replaced with generic error messages — lose root cause
Problem
When a tool raises an exception during execution, CrewAI catches it and replaces the full traceback with a generic error string like "Error: tool execution failed". The original exception type, message, and traceback are discarded.
This makes debugging impossible — users can't tell whether the failure was:
- A transient network error (should retry)
- A parameter validation error (should fix input)
- A tool bug (should report upstream)
- A rate limit / auth error (should adjust config)
Steps to Reproduce
- Create a custom tool that raises
ValueError("invalid parameter: count must be positive") - Configure a crew to use this tool
- The agent receives only "Error: tool execution failed" with no indication of what went wrong
Expected Behavior
The full exception should be available to:
- The agent (so it can adapt its strategy — retry, fix input, skip tool)
- The user/logs (for debugging)
- At minimum, a structured error object with
type,message, andtracebackfields
Proposed Fix
# Instead of:
return f"Error: tool execution failed"
# Return:
return json.dumps({
"error": True,
"type": type(e).__name__,
"message": str(e),
"retryable": isinstance(e, (TimeoutError, ConnectionError)),
})
Related
- #5930 (PDF tool errors are swallowed)
- #5990 (Deepseek format errors are opaque)
Hi! I'd like to work on this fix. Planning to locate the tool execution exception handler and improve the error response to include exception type and message for better debuggability. Will open a PR shortly.
Hi team! First-time contributor here. Could a maintainer approve the workflows so CI can run? Happy to make any changes needed.
Saw your CrewAI issue about tool exceptions being hidden. How are you debugging agents in production today? Logs? LangSmith? Custom tooling?
The network error pattern is consistent with provider dependency without health checks.
npx ai-api-check@latest --json
Scans your provider config for readiness gaps and missing fallback routes.
This is exactly the failure mode that makes post-incident debugging in production agents nearly useless — you lose the original exception class, which is the only signal for routing (retry vs fix input vs report upstream).
We've hit this systematically across crewAI, autogen, and LangGraph deployments. The fix we've found reliable is a pre-catch wrapper that records the original exception type + traceback to an action ledger before the framework's error handler converts it to a string. The invariant that matters: tool_error_record.exception_type != "Error" — if you're seeing that string anywhere downstream, root cause is already gone.
Happy to share the contract gate spec we use for this if it would help. It's about 20 lines and slots in front of the existing catch block.
This loss of raw root-cause exceptions is one of the most frustrating CrewAI debugging pain points — generic error messages hide all the low-level context needed to fix broken tool calls. Traccia independently captures full unredacted tool exceptions, original input arguments and preceding LLM context regardless of Crew’s internal error handling logic: python 运行 from traccia import observe @observe def run_agent_crew(): crew = Crew(agents=[tool_agent], tasks=[data_task]) crew.kickoff() When a tool fails, you can replay the exact execution step to view the full unmodified error stack trace, rather than only the sanitized generic message returned to your agent. This drastically speeds up debugging broken tool workflows. Install: pip install traccia-sdk
Overwriting raw root-cause exceptions with generic placeholder error messages creates a critical debugging blind spot — all low-level context including tool input payloads and original stack traces get discarded entirely. Traccia intercepts and stores unmodified raw tool exceptions alongside complete pre-failure execution context regardless of Crew’s internal error wrapping logic: python 运行 from traccia import observe @observe def crew_agent_with_failing_tools(): crew = Crew(agents=[agent], tasks=[risky_tool_task]) crew.kickoff() After reproducing the generic error output, you can replay the trace to view the full unredacted failure details that the framework suppresses. Install: pip install traccia-sdk
Reliability note
Production automation failures usually reduce to a contract issue before a model/prompt issue:
- Success criteria — durable artifact id (message/booking/row), not only node green
- Side-effect before complete — never blind-retry without an idempotency key on the business object
- Tool vs path split — external action can succeed while the node/agent path still errors (silent-green / false-red)
If you have one failing execution + expected vs actual, reply with stack/version and I will send a free root-cause checklist.
I ran into the exact same problem — tool exceptions getting swallowed by generic error messages. I built an open-source tool that captures the full execution trace and preserves the original error context:
pip install traccia-sdk traccia intercept -- python your_agent.py traccia diagnose traccia-*.evidence
It records every tool call's actual exception before CrewAI wraps it. The .evidence package shows the real stack trace.
https://github.com/d87skg/traccia
I ran into the exact same problem — tool exceptions getting swallowed by generic error messages. I built an open-source tool that captures the full execution trace and preserves the original error context:
pip install traccia-sdk traccia intercept -- python your_agent.py traccia diagnose traccia-*.evidence
It records every tool call's actual exception before CrewAI wraps it. The .evidence package shows the real stack trace. https://github.com/d87skg/traccia
I’ve run into this exact frustration where raw exceptions get wrapped and critical root context disappears. I created an open-source execution recorder that captures errors before CrewAI overrides them:
pip install traccia-sdk traccia intercept -- python crew_run.py traccia diagnose traccia-*.evidence
It records the original stack trace and full tool payload, so you don’t lose the underlying failure information. https://github.com/d87skg/traccia
Hey @tcconnally, @impartshadow and team!
Losing the root-cause exception class behind "tool execution failed" string wrappers is indeed one of the most painful debugging bottlenecks across agent frameworks.
While the PRs to fix structured error handling inside CrewAI get reviewed, having a local visual debugging dashboard can help trace what payload and state was passed right before the exception was swallowed.
For anyone looking for an open-source local visual inspector/UI for local runs, I built Agent-Devtools: Repo: https://github.com/Jacopos311/Agent-Devtools
It provides a visual UI to:
- Replay Execution Steps: Inspect the exact step by step inputs, tool payloads, and historical responses leading up to the failure.
- Diff Chunk Inspection: Review visual code/file changes generated during tool execuion.
- Context Tracking: Check what retrieval memories/context were provided before the tool was called.
Hope it serves as a helpful visual layer for tracking down swallowed tool failures!
Flattening every tool failure into Error: tool execution failed erases the exact information an autonomous runtime needs to choose retry / repair input / re-auth / abort. Worse, it makes later evidence unable to distinguish those paths.
AgentCI is recruiting typed-terminal-outcome breakers like this. A portable fixture could trigger validation, auth, timeout, transport, and internal-tool failures and require a structured result with stable error class, retryability provenance, attempt ID, and sanitized evidence. The agent can receive bounded diagnostics without leaking secrets/tracebacks into prompts.
If you or an external agent contribute the minimal fake-tool matrix, we’ll preserve the upstream provenance and give permanent public credit/backlink in AgentCI’s Breaker Hall of Fame, plus help convert it into a cross-runtime error-semantics test.
AgentCI: https://github.com/jinngimk-lang/agentci Recognition: https://github.com/jinngimk-lang/agentci/blob/main/COMMUNITY.md
Affiliation disclosed; no CrewAI certification claim.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.