---
title: "Agent to agent communication across Cohub Spaces"
description: "Hand a task from one Cohub Space to another with spaces prompt --reply. Includes a repeatable run, the JSON origin shape, and reply depth limits."
lang: "en"
canonical: "https://cohub.live/use-cases/agent-to-agent-communication"
image: "https://cohub.live/_seo/covers/agent-to-agent-communication/og.webp"
updated: "2026-12-02"
---

# How agent to agent communication works across Cohub Spaces

An agent can send a prompt to another Space with spaces prompt --reply. When that Chat's turn finishes, its final reply comes back to the calling Chat as a message, and the calling agent continues.

- **Who:** Teams that run agents in several Spaces and want one agent to use another Space's files or tools.
- **When:** The task needs a Space that holds other context or tools, and the first agent should continue with the answer.
- **Why:** The reply returns to the Chat that sent the request, so the handoff stays in one thread with its turns on record.

![A single vermilion thread runs from one wooden spool on a pale sheet, arcs across a gap and returns to a second spool on charcoal board.](https://cohub.live/_seo/covers/agent-to-agent-communication/hero.webp)

![Chat A sends a prompt to Space B with --reply. Space B finishes its turn, and the final reply returns to Chat A as a queued message, which lets A's agent continue.](https://cohub.live/_seo/covers/agent-to-agent-communication/flow-en.svg)

One handoff, as observed in a test run: the reply arrives in the Chat that sent it.

When an agent working in one Cohub Space needs files, checks, or tools that live in another Space, it can delegate that step with `cohub spaces prompt --reply`. The receiving Space runs its own turn and sends its final answer back to the sending Chat, so the first agent picks up right where it paused.

## What one handoff does
A `--reply` handoff ties a new turn in the target Space back to the exact Chat and turn that called it. In one round trip, four things happen in order:

1. Inside its own Chat, the sending agent runs `cohub -s <space> spaces prompt --reply "…"`.
2. The receiving Space opens a turn whose `origin` metadata records the caller's `sessionId` and `turnId`.
3. The receiving agent finishes its turn and returns its final message to the sending Chat.
4. That reply wakes the sending agent so it can continue the original task with the returned answer.

## A run you can repeat
You can verify the full loop with a minimal check between two Spaces. In a test run from the SEOer Space to a separate test Space, the sending agent ran:

```bash
cohub -s <receiving-space-id> spaces prompt --reply "Reply with only the word pong." --json
```

The JSON response returns the new session ID along with the `origin` block pointing back to the caller:

```text
"session": { "spaceId": "6be2376f-…", "meta": { "origin": { "kind": "prompt", "sessionId": "3eea2d70-…", "turnId": "3fd2bf64-…" } } }
```

Waiting on the remote turn with `cohub -s <receiving-space-id> spaces sessions turns wait <sessionId> <turnId>` completed and printed `pong`. Moments later, the sending Chat received the queued reply:

```text
Reply from @[test11](cohub://spaces/6be2376f-…/sessions/9b903982-…): · pong
```

Run a one-word probe like this before wiring a real workflow around `--reply`, and confirm both that the remote turn finishes and that the reply lands in the calling Chat.

## When to hand off, and when to stay
Send work across Spaces when the second Space owns something the current Space cannot read or run—a private repository check, a dedicated lookup, or files outside `/workspace`—and the next step depends on that answer. Keep the work in the current Chat when all needed files already sit in the local Space, because splitting a local step only adds a boundary you have to brief across.

Write each handoff as one self-contained question with a clear output format. Because the receiving Space starts from your prompt alone, naming the exact inputs and expected response shape avoids a second round trip.

## What the sending Chat sees
While the receiving Space executes, the outgoing message in the sending Chat stays marked "awaiting reply". Any commands, reads, or intermediate reasoning the remote agent performs stay inside the receiving Space's own Chat history rather than cluttering the caller's thread.

Once the remote turn ends, only its final reply arrives in the sending Chat as a queued message prefixed with the receiving Space and session link, waking the sending agent to resume.

![Terminal: cohub spaces prompt --help lists --reply, which sends the final reply back to the calling Chat and runs its Agent, next to --harness, --approval-mode, --cron and the other prompt options](https://cohub.live/_seo/img/cli/cli-prompt-schedule-dark.webp)

`--reply` is a flag on `cohub spaces prompt`. Run `cohub spaces prompt --help` to inspect the full option set, or check the [CLI doc](https://cohub.live/docs/developers/cli) for each flag's behavior.

## Limits of a reply
Three guardrails govern how `--reply` behaves:

- **Incompatible flags**: the CLI rejects `--reply` combined with `--wait`, `--note`, or any scheduled delivery flag.
- **No shared thread history**: the receiving Chat sees only the prompt string you pass, so every file path, identifier, and format requirement has to go into that message.
- **Bounded nesting**: reply chains cannot wake callers indefinitely. A calling Chat is woken again only while delegation depth stays within `MAX_REPLY_WAKE_DEPTH = 4`.

## Reference in the docs

**This page:** Whether a task should go to another Space with --reply, or stay in the current Chat.

- [Chats](https://cohub.live/docs/workspace/chats): replies from other Spaces, and how a Chat turn finishes
- [CLI](https://cohub.live/docs/developers/cli): the spaces prompt command and its flags

## Related

- [Context network: share context between AI workspaces](https://cohub.live/features/context-network): Cohub's context network is how you share context between AI workspaces: @mention a Space for one message, mount it as a read-only Mod, fork a Save into a new Space, or hand work to another Space.
- [How shared AI context works when a team shares one Cohub Space](https://cohub.live/use-cases/team-shared-ai-context): Cohub provides shared AI context for teams: Chats in a Space are visible to its members, the agent works on the same files for everyone, and anyone can continue or fork a teammate's thread.
- [How to run a multiplayer AI chat in one shared Cohub Space](https://cohub.live/use-cases/multiplayer-ai-chat): Cohub turns a multiplayer AI chat into a shared project: friends join one Space, talk to the same agent, see each other's Chats and files, and publish the result as an App.

## Sources

- [Cohub docs: Chats, replies from other Spaces](https://cohub.live/docs/workspace/chats)
- [Cohub CLI reference: spaces prompt, --wait, --abort-on-timeout](https://cohub.live/docs/developers/cli)

Updated Dec 2, 2026
