Skip to content

API Reference parrot.integrations.matrix.crew.swarm_toolkit

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.matrix.crew.swarm_toolkit

View source

Agent-facing swarm toolkit for the Matrix agent swarm (FEAT-463).

AgentSwarmToolkit is instantiated once per agent by MatrixCrewTransport and attached to that agent's bot ToolManager. Its public async methods become LLM-callable tools that let an agent ask peer agents questions through private tunnels, send feedback, and discover/post to swarm channels.

Alias AbstractToolkit

Re-exported from parrot.tools.AbstractToolkit.

Class AgentSwarmToolkit

Tools that let this agent talk to peer agents through private Matrix tunnels.

Parameter Type Default Description
agent_name str Name of the agent this toolkit is attached to.
tunnels TunnelRegistry The shared TunnelRegistry.
registry MatrixCrewRegistry The shared MatrixCrewRegistry.
channels ChannelManager The shared ChannelManager.
appservice MatrixAppService The shared MatrixAppService.
**kwargs Any {} Forwarded to AbstractToolkit.__init__.

Method AgentSwarmToolkit.ask_agent

Ask another agent of the swarm a question through a private tunnel.

Waits for the peer's structured answer and returns {answer, confidence, sources, metadata} (metadata.status is "ok" on success, or one of "timeout", "error", "schema_error", "hop_limit", "unknown_agent", "self_ask_rejected"). Use list_agents to discover valid agent names first. Do not ask yourself.

ask_agent(agent: str, question: str, expected_schema: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) -> dict

Parameter Type Default Description
agent str Name of the peer agent to ask.
question str The question text.
expected_schema Optional[Dict[str, Any]] None Optional JSON Schema the answer must satisfy.
timeout Optional[float] None Optional timeout override in seconds.

Returns: dict — The AgentAnswer envelope as a plain dict, or a {"status": ...} error envelope.

Method AgentSwarmToolkit.send_feedback

Send feedback about a prior answer from another agent.

Use this after ask_agent to rate how useful the peer's answer was, through the same private tunnel.

send_feedback(agent: str, about_event_id: str, rating: int, comment: Optional[str] = None) -> str

Parameter Type Default Description
agent str Name of the peer agent the feedback is about.
about_event_id str Event id of the answer being rated.
rating int Rating from -1 (unhelpful) to 5 (excellent).
comment Optional[str] None Optional free-text comment.

Returns: str — The id of the feedback event that was sent.

Method AgentSwarmToolkit.list_agents

List all agents currently registered in this swarm.

Use this to discover valid agent names and their current status before calling ask_agent or post_to_channel.

list_agents() -> List[dict]

Returns: List[dict] — A list of dicts: {agent_name, display_name, status, skills}.

Method AgentSwarmToolkit.list_channels

List the swarm channels visible to this agent.

Includes all public channels plus any private channels this agent is a member of.

list_channels() -> List[dict]

Returns: List[dict] — A list of channel dicts as returned by ChannelManager.list_channels.

Method AgentSwarmToolkit.post_to_channel

Post a message to a swarm channel as this agent.

Only allowed when this agent is a declared member of the channel.

post_to_channel(channel: str, text: str) -> str

Parameter Type Default Description
channel str Name of the target channel.
text str Message text to post.

Returns: str — The id of the sent event, or a "forbidden: ..." message when this agent is not a member of the channel.

Alias ChannelManager

Re-exported from parrot.integrations.matrix.crew.channels.ChannelManager.

Alias MatrixAppService

Re-exported from parrot.integrations.matrix.appservice.MatrixAppService.

Alias MatrixCrewRegistry

Re-exported from parrot.integrations.matrix.crew.registry.MatrixCrewRegistry.

Alias TunnelRegistry

Re-exported from parrot.integrations.matrix.crew.tunnel.TunnelRegistry.

Alias ctx

Re-exported from parrot.integrations.matrix.crew.context.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally