Skip to main content
You can embed dynamic values from agents, test cases, and simulations into your metric prompts and test scenarios using template variables. The system automatically replaces these placeholders with actual values during evaluation.

Supported Sources

The template system supports these sources:
  • {{agent.*}} - References agent attributes
  • {{test_case.*}} - References test case attributes
  • {{test_case.expected_behaviors}} - References test case criteria (used by Composite Evaluation)
  • {{sim_wrapper.api.*}} - References values returned by a pre-simulation API call
  • {{persona.*}} - References a persona’s initialization parameters (chat agent initialization payloads only)
  • {{customer_metadata.*}} - References metadata you provide at conversation upload time (see Customer Metadata below)

Basic Usage

The simplest form is accessing a top-level attribute:
Example: Imagine one agent has the attribute location with value “San Francisco”, and another agent has value “London”.

Retrieve test-case attributes during a simulation

Your agent’s tool handler can retrieve test-case data using the current simulation ID. For example, a refund tool can fetch the account details configured for that test case while the conversation is running.

Configure the attributes and simulation ID

Add the data in the test case’s Attributes field. In the Test Cases API, these values live in expected_output_json:
Pass the simulation ID to your backend using {{simulation_output_id}} in a supported connection field. For a chat agent, configure a custom header:
Inbound voice agents can pass the same placeholder through custom SIP headers. Your backend uses the received value as simulation_id in the attribute request. Keep your Coval API key on the backend.

Fetch a named attribute

Use an API key with simulations:read permission. Set SIMULATION_ID to the received ID and WORKSPACE_ID to the workspace containing the simulation:
The response is the attribute value directly, without a resource envelope:
Omit X-Coval-Workspace-Id to use the organization’s default workspace, or set it to the workspace containing the simulation.
Attribute names are exact, case-sensitive top-level keys. Unlike template variables, this endpoint does not interpret dots or array indexes as paths. Fetch account_status and read tier from the returned object. A name such as screen.name looks up the literal key screen.name. URL-encode special characters, for example account%20status for account status.

Retrieve an image attribute

An attribute can reference an existing image attachment on the test case by its exact Name:
The name must match exactly one attachment. Fetching receipt returns raw PNG or JPEG bytes with the corresponding Content-Type:
This example assumes the attachment is a PNG. Use the response’s Content-Type to choose the appropriate file format in your tool handler.

Handle responses and changing data

The endpoint reads the current active test case, both during a simulation and after it finishes. Edits to its attributes affect subsequent requests, including requests for older simulations. Responses use Cache-Control: no-store. The endpoint does not preserve an attribute snapshot or record tool-call events. An attribute set to JSON null returns 200 with null. An absent key returns 404. An ordinary object returns unchanged unless its type is image_ref, which is reserved for image references. See Retrieve a named simulation attribute for the full endpoint reference.

Customer Metadata (Upload-Time Values)

When you submit an uploaded conversation, you can attach arbitrary metadata to it. Those values are stored with the conversation and can be referenced in any LLM judge metric prompt using {{customer_metadata.<key>}}. The value is substituted per conversation at evaluation time, so the same metric can be judged against a different ground-truth value for each uploaded call. This is the recommended way to evaluate uploaded conversations against facts that are only known at upload time — order totals, prices, account balances, confirmation numbers, expected outcomes, and similar per-call ground truth. 1. Provide the value when you upload the conversation (POST /v1/conversations/uploaded:submit):
You can also add metadata key/value pairs from Uploaded in the sidebar, or with coval uploaded-conversations submit --metadata milk_price='$2.50'. 2. Reference the value in your metric prompt:
For the example above the metric resolves to “…the verified price… is $2.50..." and returns **YES**. Uploading a different call with `"metadata": { "milk_price": "$3.50” }` — even with the identical transcript — resolves to “$3.50" and returns **NO**, because the agent quoted $2.50. The upload-time value, not the transcript alone, drives the judgment.
If a metric prompt references a {{customer_metadata.<key>}} that a conversation did not supply, that metric fails for that conversation with a clear error. Make sure every conversation you attach the metric to includes the key, or scope the metric to the conversations that carry it.

Nested Paths

You can access nested attributes using dot notation:
Example: If your agent has a nested structure:
You can access it in your prompt:

Array Indexing

Access specific elements in arrays using bracket notation:
Example: If your test case has an array:
You can reference specific flights:

Array Access Without Indexing

Access entire arrays without indexing - they’ll be returned as strings:
Example:

Dynamic Keys via Multi-Pass Resolution

The system supports dynamic key resolution through multiple passes, allowing you to use one template variable to determine another:
How it works:
  1. First pass: Resolves {{test_case.username}} → “user1”
  2. Second pass: Resolves {{agent.users.user1.email}} → “test@example.com”
Example: If your test case specifies a username:
And your agent has user-specific data:
You can use dynamic resolution:

Complete Example

Here’s a comprehensive example combining multiple features: Agent attributes:
Test case:
Metric prompt:

Use Cases

In Metric Prompts

Attributes are commonly used in metric prompts to create context-aware evaluations. See Configure metrics for examples of using attributes in evaluation metrics.

In Test Scenarios

You can embed agent attributes directly into test case scenarios and expected behaviors. This allows the same test set to work with different agents that have different attribute values. See Test Sets for more information.

In Criteria

Use attributes in criteria definitions to create dynamic validation that adapts to the specific agent or test case being evaluated. These criteria are used by the Composite Evaluation metric.

Passing State Into Your Agent

Beyond evaluation, you can inject template values into your agent’s connection configuration so your backend resolves the right context — for example, an account or customer ID that determines which records the agent looks up. Connection fields support different template sources depending on the simulator. This works across simulator types: For example, a chat agent can carry per-test-case state in a header:
with each test case supplying its own account_id attribute. The same {{test_case.<attribute>}} pattern applies to the voice fields above. (The scenario text of every test case also supports these variables, regardless of simulator type.) Inbound SIP headers can additionally use {{run_metadata.<key>}} for values supplied with a specific run rather than stored on the agent or test case. See Passing context to an inbound voice agent.