Skip to content

latent.simulators.conversation.simulator

ConversationSimulator -- run multi-turn conversations between agents.

Classes

ConversationAgent

ConversationAgent()

Protocol for agents that participate in conversation simulation.

Any object with a respond(context) -> AgentResponse method satisfies this protocol. Callables (functions) are also accepted via _call_agent.

ConversationSimulator

ConversationSimulator(agent_under_test: ConversationAgent, human_agent: ConversationAgent, config: SimulationConfig | None = None)

Run multi-turn conversations between two agents.

Works with any agent that implements the ConversationAgent protocol (i.e. has respond(context) -> AgentResponse) or is callable.

The simulation loop: 1. The agent under test generates an initial response to the scenario. 2. The human agent responds to the agent's message. 3. Steps repeat until termination.

Termination occurs when: - Either agent signals should_end=True - Either agent returns empty text - max_turns is reached

Args: agent_under_test: The agent being evaluated. human_agent: The simulated human (typically a HumanAgent). config: Simulation configuration.

Methods

ConversationAgent.respond

respond(context: list[dict[str, str]] | None = None) -> AgentResponse

ConversationSimulator.simulate

simulate(scenario_context: str | None = None) -> SimulationResult

Run a complete conversation simulation.

Args: scenario_context: Optional initial context/scenario description. If provided, sent as the first user message to the agent under test.

Returns: SimulationResult with the full conversation and metadata.