Agent Trajectory Monitors

Agent Trajectory Monitors check which steps an agent takes, in what order, and how often. They alert when a required step is missing, a step happens too often or too rarely, steps occur in an unexpected order or combination, or a tool repeats the same call with the same result. For example, use them to catch a database write before a permission check. They work like Validation Monitors, but check individual steps (spans) within agent runs (traces).

Creating Agent Trajectory Monitors

Agent Trajectory monitors can be created by navigating to Add monitor → Agent trajectory.

Choose data

📘

If your agent isn't in the Choose data → Agent list, Monte Carlo hasn't seen its traces yet, or the agent isn't in the domain selected for the monitor. For OpenTelemetry agents, check the setup. For a platform agent (Snowflake Cortex, Databricks), confirm the agent is listed in the Agents section of Settings → Integrations. For an agent whose traces land in a warehouse table, confirm that trace table is listed there.

  1. Agent: Select an agent to monitor. The agent appears here once Monte Carlo has detected its traces.
  2. Time Filter: Select a time window of last hour, day, or week. This monitor validates new traces that appear within this time window each time it runs.
    • Note: The time window cannot be greater than the schedule interval.

For repeats, use Traces scope. Entire conversations supports only occurs and does not occur conditions. Switching to it removes repeat and relationship conditions from the editor, so review the remaining conditions before saving.

Define alert conditions

Alert conditions determine when Monte Carlo should generate a new Alert based on the trajectory patterns you've configured.

Users can set alert conditions on workflow, task, and span_name. These can be selected from the span groups tree which appears when users clicks on Select span input field.

The following alert conditions are currently supported

  1. (workflow/task/span) occurs more than, less than, or exactly x times
  2. (workflow/task/span) occurs with (workflow/task/span)
  3. (workflow/task/span) occurs without (workflow/task/span)
  4. (workflow/task/span) occurs before (workflow/task/span)
  5. (workflow/task/span) occurs after (workflow/task/span)
  6. (workflow/task/span) does not occur before (workflow/task/span)
  7. (workflow/task/span) does not occur after (workflow/task/span)
  8. (workflow/task/span) repeats more than or exactly x times

Use repeats to detect consecutive calls to the same tool with matching input and output within one agent run. This can help identify agent loops. Use occurs to limit the total number of calls, regardless of their input or output.

  • Note: Workflows can only be compared with other workflows, tasks with other tasks, and spans with other spans

Detect repeated tool calls

repeats is available for Snowflake, including Cortex agents; Databricks, including Genie; and ClickHouse, including agents that send traces to the Agent Observability Data Platform. It is unavailable for BigQuery, Redshift, and Athena. If an existing condition uses repeats with an unsupported source, the editor marks it unsupported.

For example, looking up five different orders can be legitimate work. Repeatedly looking up the same order and receiving the same answer may indicate a problem.

  1. Under Define alert conditions, choose Select span and select a workflow, task, or tool-call span. repeats checks consecutive calls to the same tool within that selection. For an individual span identified as not being a tool call, the editor disables repeats with the message: "Repeats requires tool calls. Choose a tool call, task, or workflow".
  2. Select repeats. Its hint is same input and output, in a row.
  3. Choose more than or exactly, then enter the count. The count includes the first call: three matching calls in a row count as three.
  4. Finish the schedule and notification settings, then select Add. When editing an existing monitor, select Update.
A trajectory condition uses repeats, with more than and exactly available as comparisons.

Example: alert when lookup_order repeats more than two times.

ConditionWhen it matches
repeats more than 2 timesThe longest matching sequence has three or more calls.
repeats exactly 3 timesThe longest matching sequence has three calls. A run with a longer matching sequence does not match, even if it also contains a separate three-call sequence.

When you select a workflow or task, repeats uses the longest matching sequence across all tools in that selection. If one tool repeats three times and another repeats four times, the count is 4, so exactly 3 does not match. Select an individual tool-call span if you want to check only that tool.

Use more than when you want to catch any sequence above an acceptable length. Its minimum count is 1, which alerts on two or more matching calls. The minimum count for exactly is 2.

Another tool call breaks the sequence. For example, lookup_order → send_email → lookup_order is not a repeat of lookup_order. Reasoning or planning steps between the calls do not break it. A change in the tool's input or output starts a new sequence.

Choose a threshold that fits the tool's expected behavior. A tool that polls for a job to finish may legitimately make the same call and receive the same answer several times. A repeats condition identifies repeated work; a match does not by itself prove that the agent is stuck.

A call with missing, redacted, cut-off, or oversized input or output cannot be part of a matching sequence. It also ends any sequence in progress. The combined input and output limit is 16,384 characters, so repeated calls that return a large file can go undetected. See Details and edge cases below for matching rules and source-specific limits.

To manage the same rule in YAML, see the repeats example in the Monitors-as-Code guide.

Define schedule

Select when the monitor should run. Agent Trajectory monitors run according to the schedule defined below.

  • On a schedule: Input a regular, periodic schedule. Options for handling daylight savings are available in the advanced dropdown.

Send notifications

Select which audiences should receive notifications when an anomaly is detected.

Additional settings exist for setting the description of the monitor which will be set as the header for notifications sent to notification channels, also pre-setting a priority on any incidents generated by the monitor.

See here for more information on Audiences and Notifications. Learn more about setting Monitor tags.

Notes

Text in the Notes section will be included directly in notifications. The "Show notes tips" dropdown includes details on how to @mention an individual or team if you are sending notifications to Slack.

Notes support rich-text formatting, including bold, italic, underline, strike-through, lists, links, and code blocks. Rich-text channels display these styles, while text-only channels show a plain-text equivalent.

Monitor properties can be dynamically inserted into Notes through variables. Supported variables include Created by, Last updated at, Last updated by, Priority, Tags and—for Validation and Custom SQL monitors—Query Result.

Alerts and Notifications

Alerts

Agent Trajectory Monitors generate an Alert whenever traces breach the defined alert conditions.

Alerts from Trajectory Monitors include the following details:

  • Number of traces that violated the conditions
  • List of the invalid traces
  • Historical graph of previous breaches

For a repeats condition, open Trajectory breaches → Matching traces. Each sampled row identifies a matching run and includes a repeat count column for the selected workflow, task, or span. For example, two rows with a repeat count of 3 mean that each of those runs had a longest matching sequence of three calls; they do not mean one sequence of six calls. When the selected target is a workflow or task, its count covers all tools in that selection and does not identify which tool repeated. Select an individual tool-call span to make the count specific to that tool. The table is a sample and may contain fewer rows than the total number of matching runs.

Matching traces lists two example agent runs, each with a repeat count of three.

Each demo run has a longest sequence of three matching lookup_order calls.


Notifications

Alert notifications are sent to your configured audiences and include:

  • Description of the condition that was violated
  • Number of traces that breached the alert condition
  • Details about the most recent breach

Details and edge cases

How are inputs and outputs compared?

Matching ignores capitalization, repeated whitespace in text values, and JSON object key order. Array order and value types still matter: the number 1 differs from the text "1". A missing or blank value, null, or an empty array [] is excluded; an empty object {} is allowed. A redacted or cut-off field excludes the whole call. On ClickHouse and Databricks, values nested more than 64 levels deep are also excluded.

Which calls can break a sequence?

Calls outside the selected agent or time window are not considered. Within that data, another tool call breaks the sequence even if it does not match the alert condition or an additional filter, or if it is nested inside the selected tool's call. An additional filter that excludes send_email does not turn lookup_order → send_email → lookup_order into a repeat. Late-arriving calls can change the result of a later check. The Monitors-as-Code guide explains how to use filters with repeats.

How are calls ordered?

Calls are ordered by their start time. Native Genie uses the saved statement order first. Calls that start at the same time have a fixed order for counting. A repeats match does not prove that parallel calls were retries.

How do native Cortex and Genie calls differ?

Native Cortex excludes generated query IDs and durations from comparison. Native Genie excludes statement IDs and requires a complete captured result.

For native Cortex custom tools, matching uses the captured status and status description, not the full tool return value. Cortex server-skill calls without captured arguments cannot match. Cortex SQL text at the 8,000-character capture limit, when backed by a semantic model, and custom-tool status fields at the 4,000-character capture limit are excluded because they may have been cut off.

When Cortex or Genie data is read through a generic ClickHouse trace table instead, generated IDs remain part of the comparison and may prevent a match.

What limits apply to queries using repeats?

Larger time windows, more calls, and larger input/output values increase query work. Start with the tool and time window you need. ClickHouse queries using repeats have a 512 MiB memory limit; large runs or multiple repeats conditions can exceed it and fail the check.

For a custom ClickHouse connection, the read-only profile must allow the query settings max_block_size, max_threads, and max_memory_usage; a profile with readonly=1 rejects them, while readonly=2 allows settings within its configured constraints.

What happens when a run matches several conditions?

A run that matches several conditions still appears once in the sample. If a repeat-count cell shows NULL, that repeats condition did not match but another condition matched the run. NULL does not mean a repeat count of zero.


Did this page help you?