Cohub
中文Start a Space

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.

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.
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.
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.
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:

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:

"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:

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

--reply is a flag on cohub spaces prompt. Run cohub spaces prompt --help to inspect the full option set, or check the CLI doc 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: replies from other Spaces, and how a Chat turn finishes
  • CLI: the spaces prompt command and its flags

Sources

Published · Updated