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
- Handle file attachments - Receive base64-encoded files from dataset items in your task
- 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.
run_simulation
Execute a multi-turn conversation simulation against a dataset. Your task function is called repeatedly for each turn until the conversation completes.Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Name of the simulation run (required) |
dataset_id | str | ID of the dataset containing conversation scenarios |
task | BaseTask | Task instance that wraps your AI agent |
context | dict? | Optional context data passed to the simulation |
max_concurrency | int | Maximum parallel conversations (default: 5) |
Response
| Field | Type | Description |
|---|---|---|
success | bool | Overall success status |
total_items | int | Number of dataset items |
completed | list[dict] | Successfully completed items |
failed | list[dict] | Failed items with error details |
Completed Item
Completed Item
| Field | Type | Description |
|---|---|---|
run_item_id | str | Unique item identifier |
success | bool | Always True for completed items |
final_turn_id | str | ID of the last turn in the conversation |
Failed Item
Failed Item
| Field | Type | Description |
|---|---|---|
run_item_id | str | Unique item identifier |
success | bool | Always False for failed items |
error | str | Error message describing the failure |
turn_id | str | ID of the turn where failure occurred |
BaseTask
Create a custom task by inheriting from theBaseTask abstract base class. Your implementation wraps your AI agent and handles the conversation flow.
Implementation Requirements
| Requirement | Description |
|---|---|
Inherit BaseTask | Your class must inherit from the BaseTask class |
Implement run() | The run() method must return a TaskResult (can be async) |
| Handle sessions | Maintain conversation context using the session_id |
| Return message | Always return a response message in the TaskResult |
| Accept files | The run() method receives an optional files parameter containing base64-encoded attachments |
File Handling
Dataset items can include file attachments. When present, the simulation framework automatically detectes the required files for a turn and delivers it to your task’srun() method as a list of ProcessedFile objects.
ProcessedFile
Each file delivered to your task is aProcessedFile instance with the following fields:
| Field | Type | Description |
|---|---|---|
file_name | str | Original file name |
content_type | str | MIME type of the file content |
description | str? | Optional description of the file |
data | str | Base64-encoded file content |
Complete Example
Next Steps
- Dashboard Query - Query dashboard metrics
- Usage Utilities - Query traces and spans
- Simulation Overview - Learn about simulation testing
- Evaluation - Evaluate AI outputs
