How does memory handoff work between agents in a pipeline?

Short answer: Each stage writes durable scoped outcomes and the next stage searches them, waiting on commit when order matters instead of pasting full transcripts.

Transcript dumps fill windows and lose constraints as chains grow. Handoffs should carry durable findings and constraints; keep local reasoning local. Engram property scopes like pipeline ids join stages. Wait on run ids before the next agent acts. Continuity lives outside any single context window.

A pipeline of agents does not fail because one model is weak. It fails because the handoff is lossy. Agent A finishes with a rich working context. Agent B starts with a thin prompt. Facts vanish. Constraints soften. Decisions get restated as guesses. Memory handoff is the deliberate transfer of durable state between sequential agents so the next step inherits what the last step earned. This chapter explains why prompt dumps degrade, what belongs in a handoff versus what should stay local, how Weaviate Engram turns handoffs into scoped writes and searches, and how to wait for commits when the next agent must not race the pipeline.

Why Does Passing the Full Transcript Break Down in a Pipeline?

The simplest handoff is paste everything. Agent A dumps its entire chat into Agent B’s system prompt. That works for a two-step demo. It collapses as soon as the chain grows. Context windows fill with narration that the next specialist does not need. Important constraints sit buried under tool noise. Each hop rewrites the story in slightly different words. By step four, the original constraint has become folklore.

Summary handoffs shrink the dump. They also introduce a second failure mode. The summarizing agent decides what matters. Downstream agents cannot recover a fact that was cut. Structured state helps when your fields are known in advance. Many pipelines still need open-ended facts that do not fit a fixed schema. You need a durable store that both agents share, not a larger message.

Shared memory handoffs flip the pattern. The wire message carries identity and intent. The store carries history. Agent B asks for what it needs for this stage. That is how long pipelines stay coherent without copying every token forward.

What Must Travel Across the Handoff, and What Should Stay Local?

Once you accept that the store holds continuity, the next question is selection. Not every token from Agent A deserves to become a memory. Working scratchpads, failed tool attempts, and speculative drafts usually stay local. They pollute retrieval if you write them as facts.

Handoff-worthy content is durable and actionable. Decisions already made. Constraints the next agent must not violate. Artifacts produced so far. Open risks that later stages must watch. In a museum exhibit pipeline, the condition assessor should persist that crate-exh-309 has a hairline crack on panel B and must stay under fifty percent humidity. The packing specialist does not need the assessor’s internal debate about lighting angles.

Scope the handoff to the job. Use a pipeline id so memories for one crate do not bleed into another. Use a group dedicated to that workflow so exhibit logistics do not share topics with unrelated product support. The receiving agent searches under the same group and properties. It never relies on a private chat that already ended.

How Does Weaviate Engram Make Pipeline Handoffs Concrete?

Knowing what to keep still leaves the mechanics. Weaviate Engram is built for this pattern. Agent A calls memories.add with the durable handoff text. Engram extracts memories into your configured topics, merges duplicates, and commits them under the scopes you pass. Agent B calls memories.search with a stage-specific query and the same scopes. The handoff message can be short. It only needs the job id and the next task.

Because storage is asynchronous, a strict pipeline should wait when the next agent depends on the new facts. Use runs.wait on the returned run id before starting Agent B. That prevents a false empty search when the commit is still in flight. Hybrid retrieval works well for handoffs that mix exact ids with natural-language constraints.

Here is a three-agent exhibit crate pipeline writing and reading a scoped handoff in Engram:

import os
from engram import EngramClient, HybridRetrieval

client = EngramClient(api_key=os.environ["ENGRAM_API_KEY"])
crate_id = "crate-exh-309"
group = "exhibit_pipeline"

# Agent A: condition assessor finishes and writes durable findings
run = client.memories.add(
    "Crate crate-exh-309 panel B shows a hairline crack. "
    "Keep relative humidity under 50 percent. "
    "Do not stack. Destination gallery accepts delivery only after 18:00.",
    user_id="ops-floor",
    group=group,
    properties={"pipeline_id": crate_id, "stage": "condition"},
)
client.runs.wait(run.run_id)

# Agent B: packing specialist loads only what this stage needs
pack_ctx = client.memories.search(
    query="humidity limits stacking rules crack damage for packing materials",
    user_id="ops-floor",
    group=group,
    properties={"pipeline_id": crate_id},
    retrieval_config=HybridRetrieval(limit=5),
)

run2 = client.memories.add(
    "Packing for crate-exh-309 uses climate foam insert type CF-2. "
    "Shock watch sticker applied. Ready for transport routing.",
    user_id="ops-floor",
    group=group,
    properties={"pipeline_id": crate_id, "stage": "packing"},
)
client.runs.wait(run2.run_id)

# Agent C: transport router searches across prior stages for the same crate
route_ctx = client.memories.search(
    query="delivery window humidity stacking constraints for transport",
    user_id="ops-floor",
    group=group,
    properties={"pipeline_id": crate_id},
    retrieval_config=HybridRetrieval(limit=8),
)

Notice that Agent C never receives Agent A’s transcript. It receives a search over the same pipeline_id. Omitting stage on search lets later agents see earlier stages. Including stage on write keeps provenance clear when you audit who wrote what.

How Do You Keep Handoffs Reliable When Stages Retry or Branch?

The code above assumes a happy path. Real pipelines retry. A packing agent may fail and restart. A transport agent may branch into air versus ground. If every retry writes the same facts again, search gets noisy. Engram’s pipeline merges and deduplicates within scope when new input overlaps existing memories. That helps, but you should still write outcome language, not process chatter.

Prefer pre-extracted facts when the agent already structured the handoff. String extraction is fine for narrative notes. For hard constraints, a short factual string reduces ambiguity. Mark completion in memory when a stage finishes. Downstream agents can search for packing complete before they route. That beats relying on an in-memory flag that dies with the process.

When two branches write conflicting constraints, treat it as a conflict problem, not a prompt problem. Keep one bounded status memory per crate if you need a single current truth. Search that status at the start of every stage. Then the handoff is a query against a known scope, not a rumor passed in chat.

What Does a Healthy Pipeline Handoff Feel Like in Practice?

After retries and branches, operators still need a feel for success. A healthy handoff is boring. Agent B starts quickly. It cites the same humidity limit Agent A recorded. It does not invent a softer number. Logs show the same group, the same pipeline id, and a completed run before the next stage began.

Unhealthy handoffs feel clever. Long pasted transcripts. Summaries that sound polished but omit the crack. Agents that apologize for missing context they never searched. Fix those by shrinking the wire message and strengthening the store contract. Every stage writes durable outcomes. Every stage searches before it acts. Waiting is explicit when order matters.

Over time the exhibit_pipeline group becomes institutional memory for how crates move. New agents join the cast without inheriting private notebooks. The pipeline id remains the join key. That is the point of memory handoff. Continuity lives outside any single agent’s context window.

Our next chapter, What is global vs local memory in agent swarms?, steps from linear handoffs to swarm-scale visibility. It asks what should be globally readable across many agents, and what must stay local so specialists do not drown in shared noise.