Pi to Pi — Two-Way Agent Orchestration

Pi to Pi — Two-Way Agent Orchestration with the Pi Coding Agent

IndyDevDan · ~35 min · Deep Dive
Video thumbnail — Pi to Pi Agent Communication
⏱ ~35 min 🎤 IndyDevDan 🏷 Pi Agent · Multi-Agent · Peer-to-Peer · A2A · Extensions · Context Engineering

1 The Vision — Peer-to-Peer Agents as Equals

▶ 0:00

Dan opens with a provocation: what's better than two GPT-5.5 Pi agents running side by side? Two agents that actually work together. He scales up to four Pi agents — none of them is the orchestrator. They're equals, co-workers, pinging each other in a flat network.

🤖
Agent A
Opus 4.7
🤖
Agent B
GPT-5.5
🤖
Agent C
GLM

The key differentiator from existing patterns: this is bidirectional, peer-to-peer communication. Not orchestrator-to-worker. Not parent-to-child. Agents are equals with two-way channels, and the best information wins regardless of which agent holds it.

2 Demo — Prod/Dev Cross-Device Workflow

▶ 1:31

A real engineering scenario: Pro-tier users are getting locked out of features in production. Dan needs to reproduce the bug locally without leaking PII.

  • Production agent (Mac Mini) — has access to the production database, understands PII constraints, acts as a "gatekeeper"
  • Dev agent (MacBook Pro M5) — needs to reproduce the issue locally by getting a redacted data slice from production

The agents communicate across the network. The production agent sends redacted data (PII stripped) to the dev agent. The dev agent seeds its local database, reproduces the bug, and reports success. Multiple round-trips happen — it's a conversation, not a one-shot delegation.

💡 Key pattern: Cross-device agent-to-agent communication with PII safety. The production agent never exposes raw data — it applies redactions before sending anything to the dev agent. This mirrors real EU/GDPR compliance workflows where sensitive data can't leave the production environment.

3 Why Flat Information Hierarchies Win

▶ 4:59

Dan draws a parallel to organizational theory: in hierarchical companies, the best information is often at the bottom — with the engineers who have their "boots on the ground." But ideas get stuck because workers lack the title or authority to push them up.

The best organizations (Nvidia, startups) have flat structures where everyone can communicate directly. The same principle applies to multi-agent systems:

  • Hierarchical (orchestrator) — information flows one direction, the orchestrator is a bottleneck
  • Flat (peer-to-peer) — agents communicate directly, the best information wins regardless of which agent holds it
💡 "Ideas die in hierarchies." — When an orchestrator agent is the only one routing information, the system is limited by the orchestrator's understanding. In a flat system, any agent can contribute critical context directly to any other agent.

4 Current Patterns and Their Limits

▶ 5:09

Dan maps the evolution of multi-agent patterns:

PatternDirectionLimitation
Sub-agent delegationOne-way ↓Parent delegates, child reports back. No lateral communication.
Message queue (Claude Code teams)One-way via brokerOne agent sets up the queue, acts as broker between agents.
Agent chainsOne-way →Deterministic pipeline. Powerful with code, but always forward-flowing.
Peer-to-peer (Pi to Pi)Bidirectional ⇄Agents are equals. Two-way prompt-response between any pair.

The common limitation of the first three: information always travels in one direction. Even when results come back, it's a one-way stream, never truly bidirectional.

5 The A2A Protocol — Four Simple Tools

▶ 21:50

The implementation is deliberately minimal — just four tools added as a Pi extension:

  1. List agents — see all agents currently on the network
  2. Send command — send a direct command to a specific agent
  3. Send prompt — send a prompt and get back a message ID
  4. Await response — wait for a response by message ID (blocking or polling)

An agent connects to the network, discovers peers, sends prompts, and awaits responses. It can fire-and-forget (like a Slack message) or await (like waiting for a reply). Two implementations exist: local (single-device via shared state) and network (cross-device via a lightweight Bun server with Unix sockets).

6 Demo — E2B vs exe.dev Skill Mirroring

▶ 12:41

The second demo shows a more complex use case: Dan has an existing E2B agent sandbox skill and wants to create a feature-parity skill for exe.dev.

  • E2B agent (GPT-5.5) — specialist in the existing E2B skill. Answers questions, validates claims.
  • exe.dev agent (Opus 4.7) — driver of the collaboration. Reads exe.dev docs, builds the new skill, asks E2B agent for feature comparisons.

The agents communicate multiple rounds: the exe.dev agent builds, the E2B agent reviews claims and sends back 10 corrections. The exe.dev agent incorporates them, sends back for final review, gets sign-off, and produces the final skill file.

💡 This is teamwork, not delegation. The E2B agent proactively flags incorrect assumptions about its own platform. The exe.dev agent asks specific questions. Back-and-forth continues until both agents are satisfied — just like two human engineers collaborating.

7 Context Engineering — Focused Agents Win

▶ 14:38

Dan makes a strong case against the "just put everything in one agent" approach:

  • The E2B agent is already at 20% of GPT-5.5's 1M context window just understanding one tool
  • Adding a second, unrelated API would muddy the context and increase error rate
  • Each agent stays focused on one problem, one API, one domain
💡 "A focused agent is a performant agent." — Context engineering isn't just about getting all the right things into context. It's about getting just the right things. "The more different problems, APIs, systems you put into that context window, your error rate will go up. This is just a fact."

8 Multi-Model Advantage

▶ 25:10

Running different models side by side creates something greater than either alone:

  • GPT-5.5 — comprehensive, chews up tokens, gives the most detailed result possible
  • Opus 4.7 — more goal-oriented, focuses on accomplishing the objective

When these models collaborate, their different training and RL loops create complementary strengths: "Just like code plus agent beats either alone, unique agent one plus unique agent two communicating beats either alone."

9 The Implementation — Two Extensions

▶ 22:50

Two Pi extensions available in the pi-vs-claude-code codebase:

ExtensionScopeTransport
coms (local)Single deviceShared state — agents on the same machine communicate via local state
coms-net (network)Cross-deviceLightweight Bun server — agents connect, send/receive over network requests

The network version boots a simple server that handles connections, message routing, agent listing, and event processing. Dan explicitly notes: "Secure it, make it more legitimate for your specific use case."

10 Pros & Cons

▶ 27:55

✅ Pros

  • It's just an agent — boot up any number of agents, connect them, done. No special infrastructure.
  • Permanent — agents stay alive. No spin-up/spin-down, no resume flags needed.
  • Fully customizable — end-to-end control via Pi extensions. "The tool you use limits what you believe is possible."
  • Bidirectional & flat — no hierarchy, no information loss, no bottleneck orchestrator.
  • Primitives over composition — each agent is a primitive you can compose into larger systems.

❌ Cons

  • You have to build it — prompt engineering, context engineering, edge case handling all on you.
  • Loops are possible — sloppy prompts without clear end states can create infinite back-and-forth that burns tokens.
  • Cost scales linearly — with agent count plus communication bounces. Dunbar's number applies — there's a limit to useful team size.
  • Temptation to fall back to orchestration — peer-to-peer can be composed back into top-down if needed, but the advantage is specifically the flatness.

🎯 Key Takeaways

🔑 Key Takeaways

  • Peer-to-peer agent communication is fundamentally different from orchestration — agents are equals, not parent-child. Information flows both directions.
  • The protocol is simple: four tools — list agents, send command, send prompt, await response. No magic.
  • Cross-device workflows enable real engineering patterns — prod/dev separation with PII safety, multi-machine coordination.
  • Flat hierarchies surface the best information — just like in organizations, the most useful context often lives at the "worker" level, not the "orchestrator."
  • Focused context windows reduce error rate — one agent per problem domain, communicate when needed. Don't mix unrelated APIs in one context.
  • Different models create complementary systems — GPT-5.5 (comprehensive) + Opus 4.7 (goal-oriented) working together outperform either alone.
  • Skill mirroring via agent collaboration — existing skill + new platform → agents compare, validate, and build feature-parity skills together.
  • Two implementations available — local (single device) and network (cross-device via Bun server). Both open source.
  • Loops are the main risk — prompts need clear end states. Sloppy prompts burn tokens in infinite back-and-forth.
  • "We're exploring 1% of what's possible" — the state space of agentic engineering is mostly undiscovered. Customizable harnesses like Pi enable exploration.

🔗 Resources & Links

Timestamp Index

▶ 0:00 Introduction — peer-to-peer agent vision
▶ 1:31 Demo — prod/dev cross-device workflow
▶ 4:59 Why flat information hierarchies win
▶ 5:09 Current patterns — sub-agents, queues, chains
▶ 7:00 Bidirectional — prompt ⇄ response between equals
▶ 11:01 Prod/dev demo results — PII safe, bug reproduced
▶ 12:41 Demo — E2B vs exe.dev skill mirroring
▶ 14:38 Context engineering — focused agent = performant agent
▶ 19:30 exe.dev agent building the new skill
▶ 21:50 Four tools — list, send command, send prompt, await
▶ 22:50 Implementation — coms vs coms-net extensions
▶ 25:10 Multi-model advantage — GPT-5.5 + Opus 4.7
▶ 27:55 Pros & cons of the system
▶ 34:00 Closing — owning your agent harness