How to Hand Off a Task Between Two AI Agents Without Losing Context
Hand off a task the moment one agent finishes its piece of the work, not after you've let three more tasks pile on top of it. The ai agent handoff context problem isn't really a timing problem. It's a structure problem. Do it right and timing stops mattering.
The short answer
Hand off immediately, with a written state file, not a verbal summary. I run a daily stack of five agents doing research, writing, QA, and publishing. Every handoff happens through a single markdown file, not a chat message, not a memory of "what we discussed." The reason is simple. Agents don't remember. Chat history gets truncated, summarized, or dropped entirely once you cross a context window. If the handoff lives only in conversation, it's gone the moment that conversation ends. A file is permanent. A conversation is not.
What changes the timing
Most of the time, immediate handoff is right. But a few things push it earlier or later:
- Task complexity. A simple copy edit can wait and get batched. A multi-step research task that feeds a campaign brief cannot. Hand that off the second the research agent closes its loop.
- Window size of the receiving agent. If Agent B has a small context window, you need a tighter, more compressed handoff file. If it has a large one, you can pass more raw material and let it sort through it.
- Number of hops. One handoff is low risk. Three or four handoffs in a chain (research to draft to edit to QA) compound context loss fast. Each hop needs its own clean file, not a reference to "see above."
- Human review in between. If a person touches the work between agents, the file needs a section for human notes, separate from agent notes. Otherwise the next agent can't tell instruction from commentary.
The file structure that works
I use the same template for every handoff, regardless of which two agents are involved. It's a single file, one per task, named with the task ID. Five sections:
- Goal. One sentence. What is this task trying to produce, for whom, by when.
- State. What's been done already. Bullet points, not prose. "Researched 12 competitor pricing pages. Found 3 use annual-only pricing."
- Decisions made. Anything the first agent chose and why. This is the section people skip and it's the one that matters most. Without it, Agent B re-litigates choices Agent A already settled.
- Open questions. What Agent A couldn't resolve. Flag it explicitly instead of letting Agent B guess.
- Output location. Exact file path or URL where the work product lives. Not "the doc," not "you know which one." The literal path.
On a $2.2B infrastructure project I ran marketing for, we used a version of this same structure for vendor handoffs, just on paper instead of markdown. Same logic. Whoever picks up the work needs the decisions and the open questions, not just the finished pages. The file is the brief. The conversation is disposable.
The handoff prompt
Along with the file, I use one standing prompt template to introduce the receiving agent to the task:
"You are picking up a task from another agent. Read the attached state file fully before doing anything. Do not repeat work listed under State. Do not reverse decisions listed under Decisions Made unless they conflict with your instructions below. Resolve the items under Open Questions as part of your output. Confirm you've read the Goal and State sections before starting."
That last line matters more than it looks. Agents, like people, skim. Asking for confirmation forces an actual read rather than a scan.
Signs you are overdue
You'll know your handoff process is broken when you see:
- The second agent re-does research the first agent already finished.
- Output that contradicts a decision made two steps earlier, with no acknowledgment it was ever made.
- You, the human, having to paste in context by hand every single time.
- Tasks that take 3x longer with two agents than they would with one agent doing the whole thing.
The most common mistake
People hand off the output and skip the reasoning. They'll paste the finished draft into the next agent's prompt and think that's enough. It isn't. The draft shows what was decided. It doesn't show why. Without the "why," the next agent in the chain treats every choice as reversible, and you end up with an editor agent undoing structure the writer agent built for a reason. The fix costs one extra paragraph. Skipping it costs a full re-do.
What happens if you wait too long
Delay the handoff, or skip the file, and context decays fast. In my experience it's close to linear. Wait one extra work session and you lose roughly a third of the useful detail, because the first agent's "memory" of the task (its context window) has moved on to other prompts by then. Wait a full day and you're down to headlines only. The receiving agent gets a task with no texture, so it fills gaps with assumptions. Those assumptions are usually wrong in the small ways that cost you an editing pass to catch.
On the DTC brand I scaled from $100K to $3M, the campaigns that slipped were never the ones where one person did the work start to finish. They were the ones with a handoff in the middle and no written record of what happened before it.
Practical takeaway: build the five-section file once, reuse it for every task, and never let a handoff happen through chat alone. The file is cheap insurance against work you'd otherwise have to do twice.