simulation client that lets you:
- Run simulations - Execute multi-turn conversations against your AI agent
- Define tasks - Create custom task implementations to wrap your agent
- Control concurrency - Manage parallel execution for throughput
netra.simulation to run multi-turn simulations and test your AI agents programmatically.
Getting Started
Thesimulation client is available on the main Netra entry point after initialization.
runSimulation
Execute a multi-turn conversation simulation against a dataset. Your task function is called repeatedly for each turn until the conversation completes.Parameters (SimulationOptions)
| Parameter | Type | Description |
|---|---|---|
name | string | Name of the simulation run (required) |
datasetId | string | ID of the dataset containing conversation scenarios |
task | BaseTask | Task instance that wraps your AI agent |
context | Record<string, any>? | Optional context data passed to the simulation |
maxConcurrency | number | Maximum parallel conversations (default: 5) |
Response: SimulationResult
| Field | Type | Description |
|---|---|---|
success | boolean | Overall success status |
totalItems | number | Number of dataset items |
completed | ConversationResult[] | Successfully completed items |
failed | ConversationResult[] | Failed items with error details |
Completed Item (ConversationResult)
Completed Item (ConversationResult)
| Field | Type | Description |
|---|---|---|
runItemId | string | Unique item identifier |
success | boolean | Always true for completed items |
finalTurnId | string | ID of the last turn in the conversation |
Failed Item (ConversationResult)
Failed Item (ConversationResult)
| Field | Type | Description |
|---|---|---|
runItemId | string | Unique item identifier |
success | boolean | Always false for failed items |
error | string | Error message describing the failure |
turnId | string | ID of the turn where failure occurred |
BaseTask
Create a custom task by extending theBaseTask abstract class. Your implementation wraps your AI agent and handles the conversation flow.
Implementation Requirements
| Requirement | Description |
|---|---|
Extend BaseTask | Your class must extend the BaseTask abstract class |
Implement run() | The run() method must return a TaskResult |
| Handle sessions | Maintain conversation context using the sessionId |
| Return message | Always return a response message in the TaskResult |
Complete Example
Next Steps
- Dashboard Query - Query dashboard metrics
- Usage Utilities - Query traces and spans
- Simulation Cookbooks - In-depth tutorials
- Evaluation - Evaluate AI outputs