Class ConversationSimulator

java.lang.Object
dev.dokimos.core.conversation.ConversationSimulator

public class ConversationSimulator extends Object
Orchestrates multi-turn conversations between a simulated user and an application.

The simulator manages turn-taking, enforces turn limits, handles stopping conditions, and captures the complete interaction trajectory for evaluation.

Example usage:


 ConversationSimulator simulator = ConversationSimulator.builder()
         .simulatedUser(UserPersonas.aggressiveCustomer(judgeLM))
         .application(myApp)
         .maxTurns(10)
         .scenario("Handle product return request")
         .initialMessage("I want to return this defective product!")
         .build();

 ConversationTrajectory trajectory = simulator.simulate();
 
  • Method Details

    • builder

      public static ConversationSimulator.Builder builder()
      Creates a new builder for constructing a conversation simulator.
      Returns:
      a new builder
    • simulate

      public ConversationTrajectory simulate()
      Runs the conversation simulation.

      The simulation proceeds as follows:

      1. If an initial message is provided, it starts the conversation
      2. Otherwise, the simulated user generates the first message
      3. The application responds to each user message
      4. The simulated user generates the next message based on the response
      5. This continues until maxTurns is reached or stoppingCondition returns true
      Returns:
      the complete conversation trajectory
    • simulateAsync

      public CompletableFuture<ConversationTrajectory> simulateAsync()
      Runs the conversation simulation asynchronously using the common fork-join pool.
      Returns:
      a CompletableFuture that will complete with the trajectory
    • simulateAsync

      public CompletableFuture<ConversationTrajectory> simulateAsync(ExecutorService executor)
      Runs the conversation simulation asynchronously using the provided executor.
      Parameters:
      executor - the executor to use for async execution
      Returns:
      a CompletableFuture that will complete with the trajectory