Skip to content

Agent-to-Agent Handoff ​

Delegate a small review from one agent to another. A delegation carries a task envelope: an objective, boundaries, owned files, and a check that defines completion.

Before you start ​

Open two agent sessions in the same Nexus workspace and connect their MCP clients. Link each session's pane to its own agent (or have the session call agent_enroll) and put the two agents in a shared team or channel — delivery from one agent to another requires it. agent_whoami reports enrolled: true once a session is linked. See Agent-to-Agent Messaging for the full checklist.

Use a project containing a nonempty README.md. This tutorial asks for a review and does not require either agent to modify it.

1. Resolve the recipient ​

From the sending agent, call agent_list_peers on the local Nexus server.

json
{
  "name": "agent_list_peers",
  "arguments": {}
}

These examples are the params for tools/call; modern clients also supply params._meta. Read First tool call for the full JSON-RPC envelope.

Choose the recipient's mesh handle from peers. The broader agents list can include agents that do not currently qualify for delivery. If the recipient is absent from peers, inspect its capability tier and the reported reasons before continuing.

2. Delegate a bounded review ​

Ask the sender to delegate the following envelope, replacing the recipient placeholder:

json
{
  "name": "agent_trigger",
  "arguments": {
    "recipientHandle": "<recipient-handle-from-step-1>",
    "envelope": {
      "contextID": "first-readme-review",
      "objective": "Review README.md and identify up to three unclear setup instructions.",
      "outputFormat": "A short list of findings with section names, or an explicit no-findings result.",
      "toolAndSourceGuidance": "Read README.md in the current project and use read-only commands.",
      "boundaries": "Do not edit files, install dependencies, or contact external services.",
      "filesAndInterfaces": ["README.md"],
      "acceptanceCheck": {
        "passFailCommand": "test -s README.md",
        "endToEndVerification": "Check each finding against README.md and confirm the review names the relevant sections."
      }
    }
  }
}

Supply exactly one recipient identifier: either recipientHandle or agentId. Free text alone is not a valid delegation. See Task envelopes for every field and its validation.

Expected result: accepted: true, delivered: false, a stage, a messageId and a threadId. delivered is always false at send time: the task has been accepted, not read or completed. If the call returns a refusal instead, read its typed reason — see Sending Messages — and do not wait for an answer to a task that was not accepted.

3. Let the recipient read, work and reply ​

NEXUS tells the recipient conversation that mail is waiting; it never types the task into the recipient's terminal. The recipient reads the task with agent_inbox:

json
{
  "name": "agent_inbox",
  "arguments": {}
}

The task arrives as a message of kind task with its taskEnvelope and threadId. When the review is done, the recipient answers on that thread:

json
{
  "name": "agent_reply",
  "arguments": {
    "threadId": "<thread-id-from-step-2>",
    "text": "<the recipient's actual review>"
  }
}

The answer goes to the conversation that sent the task. If the recipient cannot take the task, it calls agent_reject with the thread ID and a reason before starting work.

Do not resend the task to make the recipient respond faster. To see where it is, call agent_message_status with the messageId from step 2; it moves through accepted, queued, notified, received and replied.

4. Verify the handoff ​

The review arrives in the sending session's agent_inbox as a message of kind reply on the same threadId. Confirm that it addresses README.md and respects the read-only boundary.

In this tutorial another agent wrote the acceptance check, so NEXUS does not execute it: the reply's verification reports peer_authored_acceptance_check, and the task stays in TASK_STATE_INPUT_REQUIRED even though the review was delivered. NEXUS runs an acceptance command only when a person wrote the task — for example, one you delegate with Delegate Task… in a linked pane's gear menu. See Task Envelopes. A delivered answer, or an agent saying "done", is not the same as a verified task.

If a send is refused or a task stays queued, read the reason and check the recipient's enrollment, team or channel, workspace scope and delivery rules.

Next ​

Use team tasks when several agents need separate file ownership, or return to Tutorials.

Built with purpose. chainabit.com