ISwarmMessage

Interface representing a swarm message within the swarm system. Encapsulates a single message exchanged between agents, tools, users, or the system, used extensively in agent workflows (e.g., ClientAgent) for history tracking, completion generation, and event emission. Messages are stored in history (e.g., via IHistory.push), generated by completions (e.g., ICompletion.getCompletion), and emitted via the bus (e.g., IBus.emit), serving as the core data structure for communication and state management.

agentName: string

The name of the agent associated with the message. Links the message to a specific agent instance (e.g., this.params.agentName in ClientAgent), ensuring context within multi-agent swarms. Used consistently in history pushes and bus events (e.g., context.agentName in IBus.emit).

mode: ExecutionMode

The execution mode indicating the source or context of the message. Aligns with ExecutionMode ("user" or "tool") from Session.interface:

  • "user": Messages from user input or stateless runs (e.g., commitUserMessage, RUN_FN).
  • "tool": Messages from tool outputs or system actions (e.g., commitToolOutput, _resurrectModel). Drives processing logic, such as validation or tool call handling in ClientAgent.
payload: Payload

Optional payload data attached to the message, providing additional context or metadata. Can be an object of any shape or null if no payload is needed; undefined if not present. Example: { image_id: <uuid> } when user send a message