How to fix CrewAI hierarchical DelegateWorkToolSchema validation error

Upgrade CrewAI to a release containing PR #2608. The schema accepts Union[str, dict] and _run coerces dict args back to strings. Four failures look the same, four fixes.

Manager agent node connected to three worker nodes by violet edges, headline Fix CrewAI DelegateWorkToolSchema validation error, AI Agents cluster label.

TL;DR: If a CrewAI crew running Process.hierarchical raises 2 validation errors for DelegateWorkToolSchema ... Input should be a valid string [type=string_type, input_type=dict], upgrade CrewAI to a release containing PR #2608 (merged 2025-04-17).

The PR widens the schema to accept Union[str, dict] and converts dict arguments back to strings inside the tool's _run. If you cannot upgrade right away, swap the manager LLM from gpt-4o-mini to gpt-4o: the weaker model is the one wrapping arguments in JSON envelopes the schema rejects.

# minimum viable upgrade
pip install -U "crewai>=0.114.0"
# or pin to a known-good post-PR-2608 build
pip install "crewai==0.115.0"

That is the canonical fix. Most posts stop there, which fails for two adjacent failures the prompt produces: the manager agent silently doing the work itself instead of delegating, and a recurrence on newer CrewAI versions where the LLM emits an argument shape the union still does not cover. The four cases need four different responses.

Why DelegateWorkToolSchema rejects dict arguments

In Process.hierarchical, the manager agent calls the built-in "Delegate work to coworker" tool. That tool's Pydantic schema, DelegateWorkToolSchema, declares task: str, context: str, and coworker: str. Older LLMs - particularly gpt-4o-mini - tend to invoke the tool with arguments like {"description": "...", "type": "str"} for task and context, copying a JSON-Schema-style envelope rather than the plain string the schema expects. Pydantic raises type=string_type, input_type=dict and the delegation never reaches the worker. Issue #2606 and issue #1744 are the two big threads that document the failure end to end.

PR #2608 changes the schema to accept either shape, and adds a coercion step that flattens dict args back to a single string before the tool runs.

Two horizontal flow paths showing how CrewAI hierarchical delegation behaves before and after PR 2608. Top path: manager LLM emits dict-shaped task and context, DelegateWorkToolSchema requires str only, Pydantic raises validation error - red REJECTED. Bottom path: same dict args, the patched schema accepts Union[str, dict], the _run method coerces dicts to strings, the worker agent receives a clean string task - green DELEGATED.
PR #2608 widens the schema and coerces dict arguments to strings inside _run. Source: crewAIInc/crewAI #2608.

Four failures that look the same at the prompt

Issues in the CrewAI repo all describe the same hierarchical-delegation pain in slightly different shapes. Match yours before changing code.

Exact symptomIssueFix
string_type validation error on task + context with input_type=dict#2606 / #1744Upgrade CrewAI to a build that contains PR #2608 (this post)
Manager runs the task itself instead of delegating; no schema error printed#2838Prompt/docstring problem, not a schema problem; tighten the manager's system prompt to require the delegation tool
Same string_type error on a recent CrewAI build that already has PR #2608#4783The LLM emitted a shape the union still does not cover; rewrite the manager's system prompt to forbid JSON envelopes for tool args
Coworker not found: ...community thread /6302Coworker name in the manager's task description must match an agent's role exactly, including case

If you upgraded and still see the same error, do not assume the upgrade did not take. Check the issue text against row 3 - input_type may now be list or some other shape, and the prompt-side fix is what actually unblocks you.

How to verify the fix worked

Three checks confirm the upgrade landed and delegation runs cleanly:

  1. Verify the installed version contains PR #2608. Run pip show crewai | grep Version and confirm it is at or after the release containing the PR. If you are unsure of the cutoff release, install crewai==0.115.0 as a known-good baseline.
  2. Inspect the schema file. Run python -c "from crewai.tools.agent_tools.delegate_work_tool import DelegateWorkToolSchema; import inspect; print(inspect.getsource(DelegateWorkToolSchema))". The fields should declare Union[str, dict] on task and context; if they say str only, the install is pre-2608.
  3. Run the crew with verbose=True and watch for the delegation step. You should see "Tool: Delegate work to coworker" with a string task body, then the worker agent picking it up. If the manager ever prints "I will perform the task myself," you are in row 2 of the table above.

If the fix did not work

Three less obvious causes catch people:

  • You upgraded crewai but not crewai-tools. Some delegation paths route through tool descriptions in the tools package. Run pip install -U crewai crewai-tools together.
  • Your manager LLM is still gpt-4o-mini. Even with the union schema, the smaller model produces erratic shapes that occasionally fail. The prompt-side workaround in issue #1744 adds a <note> block to the manager's system prompt forbidding JSON envelopes; pair that with the union fix for resilience.
  • You wrote a custom BaseTool with the same field shape. The PR only patches the built-in delegation tool. Custom tools that inherit a str-only schema raise the same error and need the same Union widening.

Pair this fix with the right LangChain agent iteration limit error handling and the right MultiServerMCPClient NotImplementedError on Windows setup if your stack uses both - the three are the most common stop-the-world failures in a hierarchical agent run.

FAQ

Which CrewAI version contains PR #2608?

The PR was merged on 2025-04-17 against main. The first numbered release that includes it is the one cut after that date - install crewai==0.115.0 or later as a known-good baseline. 0.114.0 predates the merge and reproduces the bug.

Why does this fail with gpt-4o-mini but not gpt-4o?

gpt-4o-mini frequently copies the JSON-Schema description of a parameter into the call site - so a parameter described as a string gets sent as {"description": "...", "type": "str"}. gpt-4o is more reliable at reading the parameter type as the type and emitting plain strings. The PR makes both shapes acceptable.

Will upgrading CrewAI break my existing tasks?

The change is additive: anything that worked with the old str-only schema continues to work. The Union widening only matters when arguments arrive as dicts - a code path that did not work before the PR.

Why does the manager agent run the task itself instead of delegating?

That is a different bug, tracked in issue #2838. PR #2608 does not address it - the manager's system prompt may not be strong enough to force the delegation tool. Add explicit "you must delegate" instructions to the manager's role description and try a stronger LLM.

Can I disable the schema check entirely?

Not without forking. Pydantic raises before the tool's _run sees the arguments, so monkey-patching _run alone does not bypass the validation. The cleaner workaround is the upgrade. If you need a hotfix on an older pinned version, copy delegate_work_tool.py into your repo and apply the PR #2608 diff locally.