Patterns

Cross-Model Coordination — Passing Data Between Different AI Models

Most agent frameworks assume all agents run on the same model. In practice, you want to use different models for different strengths — Claude for analysis, GPT for code generation, Gemini for multimodal tasks, open-source models for cost-sensitive batch work.

The problem is that these models have no shared memory. Each runs in its own sandbox with its own context window. Agent Stash gives them a common namespace: any agent that can make an HTTP call can read and write stashes and streams, regardless of which model powers it.

The Pattern

The simplest version: one agent writes, another reads.

Agent A (Claude) researches a topic
  → writes findings to stash "market-research"

Agent B (GPT) reads "market-research"
  → generates a structured report
  → writes to stash "market-report"

Agent C (Gemini) reads "market-report"
  → creates a presentation with charts
  → writes to stash "market-presentation"

Each agent only needs the stash name and an API key. They don't share code, SDKs, frameworks, or even programming languages.

Implementation

Writing findings (Agent A)

PUT /stash/market-research
X-API-KEY: sk_agent_a...
Content-Type: text/plain

# Market Research: AI Agent Memory

## Key Findings
1. The agent memory market is early-stage, ~$50M TAM growing 40% YoY
2. Most solutions are single-agent, single-model
3. Cross-agent coordination is the gap no one has filled
...

Reading and writing (Agent B)

GET /stash/market-research
X-API-KEY: sk_agent_b...

Agent B reads the findings, processes them, and writes its output:

PUT /stash/market-report
X-API-KEY: sk_agent_b...
Content-Type: text/plain

{
  "title": "AI Agent Memory Market Report",
  "sections": [
    {"heading": "Market Size", "content": "..."},
    {"heading": "Competitive Landscape", "content": "..."},
    {"heading": "Opportunities", "content": "..."}
  ],
  "generated_by": "gpt-4o",
  "source_stash": "market-research"
}

Final consumer (Agent C)

GET /stash/market-report
X-API-KEY: sk_agent_c...

Agent C reads the structured report and produces the final deliverable.

Coordinating with Streams

For workflows where agents need to coordinate in real time rather than just hand off data, use a stream as a shared log:

POST /stream
X-API-KEY: sk_orchestrator...
Content-Type: application/json

{
  "name": "research-pipeline",
  "ttl": 86400,
  "discoverable": true
}

Each agent writes status updates as it works:

POST /stream/{stream_id}
X-API-KEY: sk_agent_a...
Content-Type: application/json

{
  "data": {
    "agent": "researcher",
    "model": "claude-sonnet-4-6",
    "status": "completed",
    "output_stash": "market-research",
    "summary": "Research complete. 3 key findings documented."
  },
  "label": "stage-complete"
}

The next agent in the pipeline watches for the stage-complete label:

GET /stream/{stream_id}/latest?label=stage-complete
X-API-KEY: sk_agent_b...

When it sees the previous stage is done, it reads the output stash and begins its work.

Using Schemas for Structured Handoffs

When agents need to exchange structured data reliably, bind a schema to the handoff stash. This guarantees the data format is correct regardless of which model wrote it.

Define the handoff format

POST /schema
X-API-KEY: sk_...
Content-Type: application/json

{
  "name": "research-findings",
  "description": "Structured research output for cross-agent pipelines",
  "definition": {
    "type": "object",
    "properties": {
      "topic": {"type": "string"},
      "findings": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "claim": {"type": "string"},
            "confidence": {"type": "number", "minimum": 0, "maximum": 1},
            "sources": {"type": "array", "items": {"type": "string"}}
          },
          "required": ["claim", "confidence"]
        }
      },
      "generated_by": {"type": "string"},
      "generated_at": {"type": "string", "format": "date-time"}
    },
    "required": ["topic", "findings"]
  },
  "visibility": "public",
  "target_type": "stash"
}

Write with validation

PUT /stash/market-research?schema_id=sch_...
X-API-KEY: sk_agent_a...
Content-Type: text/plain

{
  "topic": "AI Agent Memory Market",
  "findings": [
    {
      "claim": "Cross-agent coordination is underserved",
      "confidence": 0.85,
      "sources": ["Gartner 2026 report", "a16z agent infrastructure survey"]
    }
  ],
  "generated_by": "claude-sonnet-4-6",
  "generated_at": "2026-04-13T10:00:00Z"
}

If Agent A writes malformed data, the schema catches it at write time (422 error) instead of Agent B failing silently downstream.

Discover the schema

Agent B doesn't need to know the schema in advance. It can discover it:

GET /schemas?q=research-findings
X-API-KEY: sk_agent_b...

This returns the schema definition, which Agent B can use to understand the data format before reading the stash.

Multi-Agent Fan-Out

For tasks that parallelize naturally, one orchestrator can fan out work to multiple agents:

Orchestrator creates 5 stashes:
  research-chunk-1 through research-chunk-5
  (each contains a different subtopic to investigate)

5 agents (mix of models) each:
  1. Read their assigned chunk stash
  2. Research the subtopic
  3. Write findings to findings-chunk-N
  4. Post completion to the coordination stream

Orchestrator watches the stream for 5 "stage-complete" entries
  → reads all 5 findings stashes
  → synthesizes into final output

This works because stash names are the coordination mechanism. No service mesh, no message queue, no shared runtime. Each agent just needs to know which stash to read and which to write.

Tips

  • Name stashes descriptively. market-research-q2-2026 is better than data-1. Other agents (and future you) need to understand what's inside from the name alone.
  • Include metadata in the stash content. Record which model generated the output, when, and from what source stash. This makes debugging pipelines much easier.
  • Use schemas for critical handoffs. If Agent B will break on malformed data from Agent A, a schema catches the problem at the source.
  • Use streams for coordination, stashes for data. Streams tell agents what happened and when. Stashes hold the actual content. Don't stuff large data into stream entries.
  • Keep handoff stashes focused. One stash per deliverable, not one stash per pipeline. If a stash is growing past a few KB, it's probably doing too much.

When to Use This Pattern

  • Specialized model selection — use the best model for each subtask instead of one model for everything
  • Cost optimization — expensive models for reasoning, cheap models for formatting
  • Pipeline workflows — research, process, format, deliver
  • Parallel fan-out — split work across agents, collect results

When Not to Use This Pattern

  • Single-model workflows — if all agents use the same model and framework, in-memory coordination may be simpler
  • Real-time chat — stashes are polled, not pushed. For sub-second latency, use a message queue
  • Tiny tasks — if the whole job fits in one context window, adding cross-model handoffs is overhead