Handoffs and Delegation in OpenAI Agents SDK, CrewAI, and LangGraph
How handoff history, task outputs, and graph state shape specialist delegation in OpenAI Agents SDK, CrewAI, and LangGraph, with a worked context-flow example.
The context problem
A workflow can use several agents and still pass the entire chat through every step. Changing the active agent does little to reduce context if every handoff carries the history; the useful comparison is who keeps control and which data crosses each boundary. OpenAI’s Swarm repository directs users to the Agents SDK, its maintained replacement, so I’d use that SDK when building a new workflow.
Handoffs, task delegation, and recursion
With a handoff, another agent takes over. A manager can instead call a specialist for a bounded task and continue once the result comes back, retaining control throughout. OpenAI’s orchestration guide makes this distinction explicit through handoffs and agents as tools.
Recursive Delegation adds another rule: a worker can delegate part of its own task to further workers. Calling an existing worker, or connecting a parent graph to a fixed subgraph, does not by itself establish recursive spawning; your code must define which workers may delegate further and enforce stopping conditions. Select context at each level.
For research or diagnosis where a manager must combine findings, I’d start with bounded specialist calls. A handoff fits routing a conversation to someone who should answer directly.
OpenAI Agents SDK: choose who owns the turn
With agents as tools, the manager keeps control and calls workers through Agent.as_tool(), which fits workflows where it needs to compare results before giving the final answer. Scope the worker’s input to its task, then decide which output the manager receives.
A handoff makes the receiving agent active for the rest of the current turn, with the previous chat history passed along by default. Input filters can change that history. The input_type setting describes structured data supplied to the handoff callback; it does not select the conversation history.
Check how the run stores conversations. Server-managed conversations do not support handoff input filters, so the docs direct you to a separate run with selected input, without reusing the original conversation or response IDs, when history must be excluded. Even where filters are supported, a shorter transcript alone does not prove that private data was removed.
CrewAI: task outputs are context too
CrewAI organizes work around agents, tasks, and a crew process; its hierarchical process uses a manager to assign work among crew members and check results. You can supply a custom manager or let the crew create one using a configured manager model. You define the crew members. The hierarchy does not establish an expanding tree of newly spawned workers.
The task docs describe an explicit context attribute for choosing other tasks whose outputs feed an assignment, and they also describe passing task output into the next task by default. A role and backstory tell you little about how much prior data an agent will receive.
Use task dependencies to make the intended flow visible, then inspect what the crew actually supplies during a run. Task descriptions and expected outputs should specify the evidence a worker needs and the result it must return; memory and tool settings also need review before claiming isolation. Choosing a hierarchical process leaves those choices with you.
LangGraph: state mapping defines the boundary
LangGraph makes parent-to-subgraph state flow explicit, with its subgraph guide showing different paths depending on whether their state schemas share keys.
A compiled subgraph added directly as a node reads and updates shared state channels, so sharing a messages channel can carry chat history across the boundary. With different schemas, a wrapper node maps parent state into subgraph input and maps selected results back after the call completes. Apply Select, Don’t Dump in that mapping. A state schema alone cannot keep unrelated text out of a field named messages.
Persistence is a separate choice. The default per-invocation mode starts fresh on each call, while per-thread mode retains state across calls on the same thread; fresh state can still receive a large history through its input mapping. Keep those decisions separate when debugging what a worker saw. Nested graphs describe composition, with dynamic recursive delegation requiring your own logic beyond adding a subgraph node.
Worked example: an export failure
Consider this support request: “Why have exports stopped downloading since we changed plans?” The manager holds the complaint, account ID, and symptom timeline, with access to case records, but needs findings about policy and the download failure before it can blame the plan change.
The policy worker gets the question about export eligibility, relevant plan terms, and the account’s entitlement record; the diagnostic worker gets the failed download’s error text and log excerpts for that export. Each task requests a finding with links to evidence and any missing facts. Neither needs the full support chat. Relevant timestamps must still accompany the records so the manager can compare them without asking workers to repeat their work.
| Framework | How to express this flow |
|---|---|
| OpenAI Agents SDK | The manager calls policy and diagnostic agents as tools, then uses their returned findings to answer. |
| CrewAI | Define policy and diagnostic tasks, then supply their outputs as context to a synthesis task. Check automatic output forwarding when arranging tasks. |
| LangGraph | Wrapper nodes select each worker’s input and return findings into parent state for synthesis. |
Suppose the policy finding confirms that exports are allowed, while diagnostics finds an expired download link. Before answering, the manager checks that the records concern the same export attempt; missing timestamps would mean asking for evidence before deciding whether the findings explain the reported failure.
Recursion would arise if the diagnostic worker could ask a further worker to inspect the link-signing flow, passing the relevant trace and a narrower question, then receiving evidence back. Your code would need to permit that delegation and bound its depth and total work. Calling a worker supplies none of those policies.
Don’t use a framework name as evidence that contexts are isolated. Inspect the input assembled for each model call, including tool results and stored history, because a focused task description cannot compensate for a shared transcript appended behind it.