Communication¶
- class terrarium.core.blackboard.Blackboard(blackboard_id='-1', participants=<factory>, initial_context='', agents=<factory>, logs=<factory>, template=<factory>, verify_template=0, suspended=False)[source]¶
Bases:
objectAppend-only event log.
Provides methods for posting, scanning, and creating text summaries for LLM prompting. Each blackboard has a unique ID and tracks its participants.
- class terrarium.core.blackboard.Event(id, ts, agent, kind, payload=<factory>, refs=<factory>, blackboard_id=None)[source]¶
Bases:
objectEvent object for blackboard communication between agents.
- Variables:
id (str) – Unique identifier for the event
ts (float) – Timestamp when event was created
agent (str) – Name of agent that created the event
kind (str) – Type of event (proposal, counter-offer, introduction, explanation, etc.)
payload (Dict[str, Any]) – Free-form dictionary containing event-specific data
refs (List[str]) – List of event IDs this event references
blackboard_id (int | None) – ID of the blackboard this event belongs to
- Parameters:
- class terrarium.core.blackboard.Megaboard[source]¶
Bases:
objectFactor graph-based blackboard system for multi-agent communication.
Maintains multiple blackboards with template verification and factor graph initialization. Designed for structured agent communication and optional external tool integration.
Initialize the Megaboard system.
- clear_blackboards()[source]¶
Clear all blackboards. Used when starting a new simulation.
- Return type:
None
- create_channel(agent_name, participants, message='', phase=None, iteration=None)[source]¶
Open a private channel between the caller and the given agents.
The channel is a normal blackboard, so only its participants can read or post to it. Reuses an existing private channel with the same membership.
- get(blackboard_id, agent, limit=None)[source]¶
Get recent events from the blackboard for the specified agent.
- get_agent_blackboard_contexts(agent_name)[source]¶
Get context summaries for all blackboards that an agent participates in. This is used as context in agent prompts.
- get_agent_blackboards(agent_name)[source]¶
Get list of blackboard string IDs that an agent participates in.
- get_blackboard_by_string_id(blackboard_id)[source]¶
Get a Blackboard object given a string ID. Returns None if not found or invalid ID.
- Parameters:
blackboard_id (str)
- Return type:
Blackboard | None
- handle_tool_call(tool_name, agent_name, arguments, phase=None, iteration=None)[source]¶
Handle blackboard tool calls by routing to appropriate methods.
- Parameters:
- Returns:
Dictionary with tool execution result
- Return type:
- is_private_channel(blackboard_id)[source]¶
Whether a blackboard is an agent-created private channel.
- log_action_to_blackboards(agent_name, action, result, phase=None, iteration=None)[source]¶
Log an action to all blackboards that the agent belongs to.
- post(blackboard_id, agent, kind, payload=None, phase=None, iteration=None)[source]¶
Post a new event to the specified blackboard.
- Parameters:
blackboard_id (int) – ID of the target blackboard
agent (str) – Name of the agent posting the event
kind (str) – Type of event being posted
phase (str | None) – Current simulation phase (planning/execution) - will be stored in payload
iteration (int | None) – Current iteration number - will be stored in payload
- Returns:
The unique ID of the created event
- Return type:
- post_system_message(blackboard_id, kind, payload=None, phase=None, iteration=None)[source]¶
Post a system message to the blackboard (bypasses agent membership check).
- Parameters:
- Returns:
The unique ID of the created event
- Return type:
- recall(blackboard_id, agent, query, limit=5)[source]¶
Search the FULL, uncompacted event log for a blackboard for events matching query — the retrieval-backed compaction technique. The underlying blackboard.logs list is never pruned by compaction (only the prompt string built from it is lossy), so this recovers detail a compacted summary may have dropped, scoped to a keyword query rather than dumping the entire history back.
Matching is a simple case-insensitive substring match against each event’s formatted text, keeping the most recent matches.
- terrarium.core.blackboard.format_blackboard_events_for_prompt(events)[source]¶
Render blackboard event logs into a compact, readable transcript for prompts.
- class terrarium.communication_protocols.base.BaseCommunicationProtocol[source]¶
Bases:
ABCAbstract interface for communication protocols.
A protocol coordinates agent turns, manages environment tool calls, and provides access to shared state (e.g., blackboards).
Communication protocol for managing multi-agent interactions and phases.
- class terrarium.communication_protocols.sequential.SequentialCommunicationProtocol(config, tool_logger, run_timestamp=None)[source]¶
Bases:
BaseCommunicationProtocolManages the overall communication protocol.
This class is environment-agnostic and handles: - Phase management (planning, execution) - Agent turn ordering and iteration
- async agent_execution_turn(agent, agent_name, agent_context, environment, iteration)[source]¶
Handle a single agent’s execution turn with retry logic.
- async agent_planning_turn(agent, agent_name, agent_context, environment, iteration, planning_round)[source]¶
Handle a single agent’s planning turn.
- bind_environment(environment)[source]¶
Bind a concrete environment instance and initialize its tool handlers.
This resets blackboards so each simulation run starts clean.
- Parameters:
environment (Any)
- Return type:
None
Note
terrarium.communication_protocols.distributed is currently a placeholder module and is not included in the generated API reference.