AgentDirectory names chat sessions so that their agents can message each other. Each member’s root agent gets a send_to_agent tool. A message lands in the recipient’s inbox and starts a turn there, or joins the turn it is running. The recipient answers with a message of its own, and both traces show the exchange.
<>&.
The tool
send_to_agent(to, message, reply_to=None, priority="normal") returns the recipient’s receipt: status ("sent" or "duplicate"), event_id, message_id and state ("pending" until a turn of the recipient takes the message).
- Who sent it. The directory stamps the sender on the message, so a model cannot claim to be another agent.
- What the recipient sees. The message arrives as a runtime notice,
<session_event source="agent" from="concierge" message_id="am_…">. The notice says the text is not the user’s, and that the agent’s reply goes to its own user. To answer the other agent, it sends a message of its own withreply_to=<message_id>. A turn started only by agent messages may stay silent. - Priority.
"normal"waits for the recipient’s next turn, and starts one when it is idle."urgent"joins the turn it is running, after the current tool batch. Neither cuts anything the recipient is doing. - A read-only turn has no
send_to_agent. A message starts work in another agent, so a turn withtool_policy="read_only"(a wake, by default) is not offered the tool. A wake leaves messages from agents for a turn of their own, which has the session’s tools. - Your rails apply. The sender’s
tool_argsguardrails see every call, as for any tool: a block refuses it, and an escalation asks a person first. A message counts as neither a refused call nor one that went through formax_consecutive_denials.
send_to_agent. If the agent has a tool of that name already (its own, or an MCP server’s), the agent’s tool is named message_agent instead, for the rest of the turn.
Screening and refusals
The recipient’s input guardrails screen each message as it arrives, as they screen a user’s prompt. A rail’sctx.payload is the message, with its envelope in metadata["peer"]. The message is taken on the loop that serves the recipient’s session, from whatever thread or loop sends it. A redaction rewrites the text, and the run that takes it records the rails that fired. A block refuses the message.
A refused message raises PeerRejected (the tool tells the model why). Its reason is one of:
accepts limits who may message a member: directory.join(session, "billing", accepts={"concierge"}), or a function of the sender’s name. The tool’s description only lists the agents that accept the agent.
Loops and repeats
- Hop limit. Each message carries
hops: one more than the deepest agent message the sending turn received (a turn that waited for an approval keeps its count), or than the message it answers. AtAgentDirectory(max_hops=6)the tool refuses, and tells the model to stop and tell its user where things stand. - Duplicates. Each message has an id, unique per sender. A send that runs again after a pause (it was cut before its answer came back) keeps its id. A message sent again with an id the recipient has (that replay,
directory.send(message_id=...), a retry over HTTP) is delivered once. So is the same text from the same sender, answering the same message, while the first copy is still waiting.
Agents on another server
ARemotePeer reaches a chat session served by another Timbal server, through POST /chat/sessions/{id}/agent_messages:
headers go with a message: the run’s platform credentials never do. The route answers 202 with the receipt, and a refusal as {"detail", "reason"} (403 for not_accepted and blocked, 404, 409 for closed, 422 for invalid).
The route takes the sender’s name as the caller gives it, so accepts is routing, not authentication: anyone who may call the server’s API may message its sessions, as they may send them user messages.