Zenaique

Why CrewAI's per task context parameter beats passing every prior output

Flashcard·Medium·4.0 · 0·~30s·Asked atElasticRobinhoodTruera
Attempt it
TL;DR

CrewAI's per-task context parameter caps tokens, cuts role bleed, and turns the workflow into a debuggable DAG. The default feeds every earlier output to every later task and lets all three problems compound.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a writing team where every email about the project is automatically forwarded to everyone. The researcher gets the editor's feedback notes. The editor gets the researcher's scratch links. The manager gets the writer's grammar self-corrections. Nobody can find the email they actually need, and the inbox is enormous. People slowly start sounding like each other because they keep reading each other's drafts. Now imagine instead that each person gets only the documents they need. The writer gets the research and the outline. The editor gets the writer's final draft. Inboxes are smaller, roles are clearer, and it is easier to figure out what went wrong when something does. CrewAI's context parameter is the second option.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

CrewAI's mental model is borrowed from a real team: agents have roles, goals, and backstories; they take on tasks; the crew runs them in order. The metaphor is friendly and the API reflects it, which is why CrewAI is the easiest framework to start with.

The metaphor also hides a design choice that causes problems for teams as their crews grow. By default, every task receives the outputs of all earlier tasks. That works for two agents and breaks at five. The fix is in the API, but it is opt-in: the context parameter on a Task. Most teams discover it the hard way, after a cost incident or a quality regression that traces back to role bleed.

The two mechanisms CrewAI gives you

CrewAI exposes two ways for information to flow between agents on a crew.

Shared memory is an opt-in narrative thread (memory=True on the crew). CrewAI saves task outputs to a memory store and adds the relevant memory entries to the agent prompt at run time. The metaphor is the office chat channel: anyone can scroll back and see what everyone has been doing.

The context parameter on a Task is the explicit data-flow mechanism. When you define a task, you can pass context=[task_a, task_b]. This tells CrewAI to thread the outputs of those specific tasks into this task's prompt and to ignore the rest. Without context, a task receives the outputs of every earlier task. The metaphor is the meeting brief: each task gets exactly the documents it needs to do the work.

The two mechanisms coexist. You can have shared memory on for narrative continuity and context declared on individual tasks for data-flow discipline. The choice between them is the choice between implicit and explicit data dependencies, and that choice has real consequences as the crew grows.

Why passing every output by default scales badly
What explicit context fixes, and the DAG mental model
When shared memory is still worth it
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
python
from crewai import Agent, Task, Crew, Process

researcher = Agent(role="Researcher", goal="Find sources", backstory="...")
writer = Agent(role="Writer", goal="Draft article", backstory="...")
editor = Agent(role="Editor", goal="Polish prose", backstory="...")

research = Task(description="Gather 5 primary sources on X", agent=researcher, expected_output="bullet list")
outline = Task(description="Outline a 1000-word piece", agent=writer, expected_output="outline", context=[research])
draft = Task(description="Write the article", agent=writer, expected_output="article draft", context=[outline, research])
edit = Task(description="Edit for clarity", agent=editor, expected_output="edited article", context=[draft])

crew = Crew(agents=[researcher, writer, editor], tasks=[research, outline, draft, edit], process=Process.sequential)

Real products, models, and research that use this idea.

  • Content-generation crews where a researcher feeds an outliner, the outliner feeds a writer, and the writer feeds an editor. Each task declares only its direct upstream dependencies, which keeps the writer's context to the outline plus brief instead of the full research dump.
  • Sales-enablement workflows on CrewAI where a lead-research task feeds an email-drafting task and a CRM-update task. Explicit context ensures the drafting task does not see the CRM payload schema and vice versa.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you decide whether a task should consume an upstream task's full output or a summary of it?
A

Look at what fields the downstream task actually quotes or transforms. If it only needs a structured subset, add an intermediate summarisation task or pre-process the output before threading it in.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Keeping the default, where every task gets all earlier outputs, and assuming explicit context can be added later. By then the agents depend on the shared view, and the role bleed is built into the crew.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What are the two CrewAI mechanisms for moving information between tasks?

  • How does passing every earlier output by default inflate token cost as crew depth grows?

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Order the steps of one handoff in the OpenAI Agents SDK Runner loop
Order steps·Medium