CrewAI Multi-Agents

Course Content

CrewAI Multi-Agents

9 sections · 53 lessons

How do you avoid redundant work across agents?


What you need to know

Where duplication comes from

  • Overlapping task descriptions. "Research the company" and "analyse the company" both search the web.
  • Shared tools. If the writer has search, it will search.
  • Delegation. A delegated worker starts fresh and often re-gathers context.
  • No cache. The same query sent twice in one run costs twice.

Fixes

ProblemFix
Two tasks cover the same groundSay what each must not do in its description
Later agents re-researchGive them context=[research], not the search tool
Same tool call repeatedCrew(cache=True) to reuse identical tool results
Delegation loopsallow_delegation=False on specialists
Facts rediscovered every runmemory=True, or a Flow step that loads saved results

How caching works now

Since CrewAI 1.15.3, tool-result caching is opt-in: set cache=True on the Crew. Agents take part by default (Agent.cache=True), and a tool can decide what to cache with its cache_function (for example, never cache a "current stock price" call). The cache is keyed on the tool name and its arguments, lives in memory, and never stores a ToolFailure.

Measure it

Python
from collections import Counterfrom crewai.events import crewai_event_bus, ToolUsageFinishedEventtool_calls = Counter()@crewai_event_bus.on(ToolUsageFinishedEvent)def count_tool(source, event):    key = (event.agent_role, event.tool_name, event.from_cache)    tool_calls[key] += 1crew = Crew(agents=[...], tasks=[...], cache=True)result = crew.kickoff(inputs={...})print(tool_calls, result.token_usage)

CrewAI emits an event every time a tool finishes. The handler counts calls per agent and tool, and from_cache shows which calls the cache answered. Compare counts before and after a change.

A real-life example

A content team crew — researcher, writer, editor — was costing Rs 60 per blog post, twice the estimate. A tool-call count showed the problem: 9 web searches by the researcher, 7 by the writer, and 5 by the editor, many for the same queries.

The fixes:

  • The writer and editor lost the search tool. The editor got context=[research_task, draft_task] so it could check facts against the research notes.
  • The researcher's description now said "collect all facts needed for the post; later steps cannot search".
  • Crew(cache=True) caught the researcher's own repeated queries.

Searches fell from 21 to 8 per post, and cost to about Rs 24. Fact-check quality did not drop, because the editor was checking against the same sources the writer used.

Follow-up questions to expect

  • "Does caching work across runs?" — The crew's tool cache lives in memory with the crew object and is not saved to disk; for reuse across runs or servers, put your own cache (for example Redis) inside the tool, or load saved results in a Flow step.
  • "When should you not cache?" — For tools with live data (prices, stock levels) or side effects; use cache_function to skip those.
  • "How do you spot duplication without code?" — Turn on verbose=True or a tracing tool and read the tool calls per agent for a few runs.