Skip to main content

Module message_agent

Module message_agent 

Source
Expand description

Built-in message_agent tool — agent-to-agent messaging for host-integrated bot sessions.

§Why this lives in the engine

The tool has to be visible to the model in the session’s tool list and it must run in the same turn loop as every other tool. Delivery itself is host-owned (a desktop app knows its roster and its bot sessions; a bare CLI does not), so the engine exposes a process-global MessageAgentHandler that an embedding host installs once. When no handler is installed the tool is not registered at all — a CLI session never advertises a tool it cannot service.

§Semantics (mirrors hermes tools/bot_mode_dm.py)

FIRE-AND-FORGET: a successful send returns a dispatch ack ({status:"queued", delivery_id}). The reply arrives later through the host’s own delivery path; the tool never blocks waiting for it.

The schema models two distinct inputs instead of one shape with a mode flag:

  • send: target + message are required (optionally constraints, expecting, expects_reply);
  • cancel: cancel (a delivery_id from your own ack) is given, and target/message must be absent.

Mixing both is an error — the tool never guesses which call the model meant. The host receives the caller’s session id (resolved from the harness binding) so it can attribute the message without trusting model input.

Structs§

MessageAgentAck
MessageAgentInput
MessageAgentRequest
A validated dispatch request handed to the host (source id filled in).
MessageAgentTool

Constants§

MESSAGE_AGENT_TOOL_NAME
MESSAGE_MAX_CHARS

Traits§

MessageAgentHandler
Host delivery door. Implementations enqueue the message and return at once.

Functions§

create_message_agent_tool
handler_installed
set_handler
Install the host delivery door (once per process). Returns false when a handler was already installed.