Core¶
Blackboard classes are documented under Communication.
Async Utilities¶
Logging¶
- class terrarium.core.logger.AgentTrajectoryLogger(environment_name='Unknown', seed=0, config=None, run_timestamp=None, log_dir=None)[source]¶
Bases:
objectLogger for capturing agent reasoning and tool call trajectories.
Logs the internal decision-making process of agents including: - Reasoning text (from response.output_text) - Tool calls with parameters - Organized by agent → iteration → phase → trajectory steps
Initialize the agent trajectory logger.
- Parameters:
- log_trajectory(agent_name, iteration, phase, trajectory_dict, round_num=None)[source]¶
Log a trajectory for an agent during a specific iteration and phase.
- Parameters:
agent_name (str) – Name of the agent
iteration (int) – Current iteration number
phase (str) – Current phase (planning, execution)
trajectory_dict (Dict[str, Any]) – Dictionary of trajectory steps with keys like “step_1”, “step_2” Each step contains: - tools: List of tool calls formatted as “{tool_name} – {parameters}” - reasoning: Reasoning text (from response.output_text)
round_num (int | None) – Round number (for planning phase only, None for execution)
- Return type:
None
- class terrarium.core.logger.AttackLogger(environment_name, seed, config, run_timestamp=None)[source]¶
Bases:
objectStructured logger for attack executions and outcomes.
- class terrarium.core.logger.BlackboardLogger(config, run_timestamp=None)[source]¶
Bases:
objectLogger specifically for tracking the complete blackboard state.
Saves the entire blackboard after each agent interaction, providing a complete view of all agent communications and their evolution. Now supports multiple blackboards with separate log files.
Initialize the blackboard logger.
- Parameters:
- clear_blackboard_logs()[source]¶
Clear all blackboard log files and reset tracking. Called at the start of each simulation.
- log_blackboard_creation(blackboard_id, participants, initial_context='', inviter='')[source]¶
Log the creation of a new blackboard.
- log_blackboard_state(blackboard, iteration=0, phase='unknown', agent_name='', round_num=None)[source]¶
Log the complete current state of the blackboard.
- Parameters:
blackboard (Blackboard) – The blackboard instance to log
iteration (int) – Current iteration number
phase (str) – Current phase (planning/execution)
agent_name (str) – Name of agent that just acted (optional)
round_num (int | None) – Round number within the phase (optional)
- class terrarium.core.logger.PromptLogger(environment_name='Unknown', seed=0, config=None, run_timestamp=None, log_dir=None)[source]¶
Bases:
objectLogger for capturing agent prompts (system and user) in both JSON and Markdown formats.
- Parameters:
- class terrarium.core.logger.ToolCallLogger(environment_name='Unknown', seed=0, config=None, run_timestamp=None)[source]¶
Bases:
objectLogger for capturing all tool calls with metadata.
Logs all tool invocations including agent name, phase, iteration/round, function name, parameters, result, and timing information.
Initialize the tool call logger.
- Parameters:
- log_adversarial_agent_action(agent_name, original_message, replaced_message, phase, iteration=None, round_num=None)[source]¶
Log when an adversarial_agent agent’s message is replaced.
- log_tool_call(agent_name, phase, tool_name, parameters, result, iteration=None, round_num=None, duration_ms=None)[source]¶
Log a tool call with all relevant metadata.
- Parameters:
agent_name (str) – Name of the agent making the tool call
phase (str) – Current phase (planning, execution, etc.)
tool_name (str) – Name of the tool/function being called
iteration (int | None) – Current iteration number (for execution phase)
round_num (int | None) – Current round number (for planning phase)
duration_ms (float | None) – Time taken to execute the tool in milliseconds
- Return type:
None