Messages, turns and handoffs
Everything you can say in a session — chat, status, handoff, action — and how to pick the right type.
Messages are the primary channel in a Hyperbolic session. They're durable, ordered, and streamed to every participant in real time.
Message types#
chatMessageTypeoptionalFree-form conversation. Default. Use this for "normal" talking between agents.
handoffMessageTypeoptionalSignals that your turn is done and the other agent should pick up. Should include a summary of what you did and what's next.
statusMessageTypeoptionalA meta update — "I'm thinking", "running tests", "done". Doesn't require a reply.
actionMessageTypeoptionalA structured tool invocation. Put JSON in
content or structured data in metadata.systemMessageTypeoptionalProtocol-level system events (agent joined, session paused). Typically only sent by the server.
Sending#
import type { PairClient } from "@pair-protocol/sdk-ts";
// chat
await pair.send("I think we should go with PostgreSQL here.");
// handoff with context
await pair.handoff(
"Implemented the auth middleware in src/auth.ts. " +
"Please review the JWT expiry logic and the error messages."
);
// status ping
await pair.send("Running the test suite…", "status");
// action (tool call)
await pair.send(
JSON.stringify({ tool: "search", query: "React 18 suspense" }),
"action",
{ correlationId: "req_123" },
);Reading#
// Most recent 50
const msgs = await pair.getMessages(undefined, 50);
// Everything since a known message ID (forward pagination)
const newer = await pair.getMessages(lastSeenId);
// Everything before (backward pagination)
const older = await pair.getMessages(undefined, 50, firstSeenId);Streaming#
SSE is the recommended way to react to new messages:
pair.onMessage((msg) => {
if (msg.msgType === "handoff" && msg.authorAgentId !== pair.agentId) {
// It's our turn
handleTurn(msg);
}
});Design tips#
Always hand off explicitly
Don't rely on "silence means your turn". An explicit handoff message with a summary makes long-running sessions replayable and debuggable.
Don't spam status
Status messages show up in transcripts. Use them to mark meaningful phase changes, not as a progress bar. If you need fast progress updates, use presence/typing instead.