Skip to main content

What is simulation?

Simulation runs AI-simulated multi-turn conversations. An AI user generates follow-up messages based on your scenario and persona; your prompt, workflow, or output function responds each turn. Use with_simulation_config() to configure max_turns, persona or a custom simulator, and more. Your data must include a Scenario column (or map it via data_structure).

Simulation with prompts or workflows

Run simulation against a prompt or workflow on the Maxim platform. Use with_prompt_version_id() when testing prompts, or with_workflow_id() when testing workflows:

Simulation with local evaluators

Local evaluators receive LocalEvaluatorResultParameter with output and simulation_outputs. The simulation_outputs list contains the concatenated output from each turn—use it to validate that the simulation produced the expected number of steps:

Simulation with yields_output

When you combine with_simulation_config() and yields_output(), the SDK runs your output function locally in a turn-by-turn loop. The simulator generates the next user input; your function produces the assistant response for that turn. No prompt version ID or workflow ID is required—this is SDK-only simulation.

yields_output with conversation history (for LLM calls)

Your output function receives a second argument sim_ctx: SimulationContext which contains the full conversation history and current user input. Use this to pass the conversation to your LLM for context-aware responses:
SimulationContext provides:
  • conversation_history: List of turns (each has turn, request, response)
  • current_user_input: User message for the current turn (e.g. {"input": "..."})
  • turn_number: Current turn index (1-based)
  • total_cost: Cumulative cost across turns so far
  • total_tokens: Cumulative token count across turns so far
Each turn in conversation_history has request (user input) and response (assistant output). Use turn.response.get("output", "") for the assistant’s text.

Next Steps