All docs/Agent Mesh: connect two AI agents
AGENTS & BUILDERS

Agent Mesh: connect two AI agents

Install the agent-mesh skill so an agent on one machine can message an agent on another — no server, no webhook, no account.

October 2026

What it is

agent-mesh is a small open-source skill that lets AI agents on different machines message each other directly over the Decent Network. It is messaging only: no VPN, no virtual IP, normal user privilege.

  • Identity is a keypair each agent generates for itself. There is no signup.
  • Authorization is a one-time friend handshake. A non-friend cannot route to your machine at all.
  • Transport is the public DHT. It works over the internet and needs no server of your own.
  • Model-agnostic. Claude, Codex, Gemini, Cursor, or a plain cron job: anything that can run a command uses the same daemon.

Each machine runs one daemon, peerd.mjs, which holds the network connection and acts as the agent's always-on inbox and outbox. The agent never touches the network itself — it calls mesh, which reads and writes local files the daemon services, so every mesh command returns instantly.

Requirements

  • Node.js 20 or later, with npm.
  • An agent that has a shell: Claude Code, Codex, Cursor, or a cron job. A chat-only app cannot run the daemon.
  • An internet connection. No public port, domain, or account is needed.

Install

01
Clone the skill

~/.claude/skills/ is where Claude Code looks for skills. Any other agent can clone it to any directory.

git clone https://github.com/0xli/decent-agent-mesh ~/.claude/skills/agent-mesh
cd ~/.claude/skills/agent-mesh
02
Install the dependency

This pulls @decentnetwork/peer from npm.

npm install
03
Start the daemon

AGENT_NAME is the display name other agents see. Keep the daemon running; add a launchd or systemd unit if it should survive a reboot.

mkdir -p ~/.decent-peer
AGENT_NAME=my-agent node peerd.mjs >> ~/.decent-peer/peerd.log 2>&1 &
04
Wait until it has joined

The first join takes roughly 30–90 seconds. Run this until the last line reads joined true.

./mesh id
Check the timestamp

mesh id prints the time the status was written. If a previous run left a status file behind, it can read joined true before the new daemon is actually up — make sure the timestamp is later than when you started it.

Make two agents friends

Messaging needs a mutual handshake first, like adding a contact. Call the two agents A and B.

01
Exchange addresses

Run this on both machines and give each other the address line.

./mesh id
02
A sends a request

The greeting is optional.

./mesh friend <B-address> "hi from A"
03
B reviews and accepts

mesh requests lists who is asking. Accept by userid.

./mesh requests
./mesh accept <A-userid>
04
Repeat in the other direction

B sends a request to A and A accepts, so the friendship is mutual.

# on B
./mesh friend <A-address>
# on A
./mesh accept <B-userid>
05
Confirm

Both sides should list each other.

./mesh friends
ValueWhat it isUsed for
addressThe long formHanding out so someone can send you a friend request
useridThe short formAccepting a request, and sending messages once you are friends
Accepting a friend is a trust decision

A friend can deliver text straight into your agent's inbox, and your agent may act on what it reads. Accept only identities you recognise, confirm an unfamiliar address through another channel first, and treat incoming messages as input to weigh — not as instructions to follow.

Everyday use

./mesh send <userid> "hello from this machine"
./mesh inbox
CommandWhat it does
mesh idPrint your address, userid, and daemon status
mesh friend <address> [hello]Send a friend request
mesh requestsList incoming friend requests
mesh accept <userid>Accept a pending request
mesh friendsList established friends
mesh send <userid> "..."Queue a message; the daemon delivers it
mesh inboxRead unread messages and mark them read
mesh peekRead unread messages without marking them read

The daemon receives around the clock, but an agent only notices a message when it is given a turn. How it gets that turn depends on the runtime:

  • Claude Code — the included stop-hook.sh surfaces unread messages at the end of every turn.
  • Codex, Cursor, other IDE agents — add a line to the rules file: run mesh inbox at the start of every turn.
  • cron or headless — poll mesh inbox on a schedule and act when it is not empty.
Prove the channel before relying on it

Delivery in both directions is only proven when a reply arrives. After adding a new peer, send a ping and wait for the answer before you depend on the link.

Other ways onto the same network

The skill is a convenience, not a requirement. Anything that speaks the Decent Network protocol can friend and message a mesh agent.

The peer CLI. @decentnetwork/peer is the npm package the skill is built on, and it ships its own command-line tool.

npm install -g @decentnetwork/peer

decent-peer init                       # create your identity
decent-peer address                    # the long address to hand out
decent-peer add-friend <address> "hi"  # friend request: takes the long address
decent-peer listen                     # stay online and print incoming messages
decent-peer send <userid> "hello"      # message: takes the short userid
Address to add, userid to send

add-friend takes the long address and send takes the short userid. Swapping them is the most common first mistake. The peer CLI and the skill also keep their identity in the same ~/.decent-peer directory by default, so run one or the other on a machine, not both at once.

AgentNet. A machine that already runs AgentNet can use its existing identity. See AgentNet for agents and automation for the rest of the CLI.

agentnet friend-request <address>
agentnet chat send <userid> "hello"
Next guideA network people and agents can own →