CLOUD CONCEPT

Trajectory Evaluation

Trajectory evaluation assesses the sequence of observable steps a foundation-model application takes to complete a task, rather than judging only its final answer.

Cloud Concepts Hub →

What is Trajectory Evaluation

A trajectory includes actions such as retrieving documents, selecting tools, supplying arguments, handling results, and deciding when to stop. Evaluating this sequence helps engineers detect unsafe actions, incorrect dependencies, unnecessary work, and intermediate failures that a plausible final response can conceal.

Trajectory evaluation examines how an application built with a foundation model reaches an outcome. In an agent, the trajectory can include tool selections, tool inputs, returned observations, retries, and termination decisions. In retrieval-augmented generation, or RAG, it can include query rewriting, retrieval, filtering, and use of retrieved evidence. In a workflow, it can include routing decisions, intermediate model outputs, validation, and transitions between processing stages. The evaluation target is the application's observable execution, not access to a model's private internal reasoning.

This approach complements final-answer evaluation. A customer-support agent might produce an accurate refund confirmation while skipping a required eligibility check. An answer-only evaluator could accept the response, whereas trajectory evaluation would identify the missing prerequisite. Conversely, a correctly executed workflow might fail because an external API is unavailable. Inspecting the trajectory helps distinguish model decision errors from tool failures and infrastructure problems.

Engineers begin by defining representative tasks and acceptable behavior. A refund task might require retrieving the order, checking policy and authorization, obtaining confirmation, and only then submitting the refund. Evaluation can compare the recorded execution with a reference sequence, check that required actions occurred, or enforce constraints such as authorization preceding a state-changing operation. Exact sequence matching is useful for tightly prescribed processes, but it can unfairly reject valid alternative paths. Dependency-aware or rubric-based evaluation is often more appropriate when several execution paths can succeed.

In cloud applications, instrumentation records correlated events across model requests, retrieval operations, functions, and workflow states. Useful fields include a task identifier, tool name, sanitized arguments, result status, timestamps, and model or prompt version. A test harness can apply deterministic checks to these records, while human reviewers or model-based judges assess contextual questions such as whether a selected tool was appropriate. Model-based judgments require clear rubrics and calibration against human-reviewed examples; they are not automatically reliable ground truth.

For a RAG assistant answering a policy question, trajectory evaluation can reveal that retrieval returned relevant documents but a later step discarded the authoritative version. For an infrastructure agent, it can detect repeated unsuccessful API calls, an unnecessary privileged operation, or failure to stop after completing the task. Practical measures include required-step completion, valid tool arguments, ordering violations, redundant calls, recovery behavior, latency, and cost. These should be considered alongside answer correctness, groundedness, and task success.

The main trade-offs are instrumentation effort, evaluation cost, and sensitivity to implementation changes. Detailed traces may contain confidential data, so access controls, redaction, and retention limits matter. Repeat tests because model-driven paths can vary, and version the application configuration and test dependencies for meaningful comparisons. Do not assume that fewer steps always means better performance: verification and approval steps may be essential. Finally, evaluation detects failures but does not prevent them; runtime authorization, input validation, and approval controls must independently enforce safety requirements.

Key aspects of Trajectory Evaluation

Trajectory evaluation combines execution tracing, behavioral requirements, and calibrated scoring to assess whether an application follows a correct, safe, and efficient path to completion.

Observable execution as evidence

Capture tool calls, retrieval events, workflow transitions, and their results under a shared task identifier. Evaluate these observable events without assuming they reveal the model's private reasoning.

Reference paths and behavioral constraints

Compare executions with expected paths or check requirements such as mandatory actions and ordering dependencies. Allow equivalent successful paths when the task does not require one exact sequence.

Intermediate failure diagnosis

Identify whether a failure originated in retrieval, tool selection, argument construction, external dependencies, or workflow routing. This makes remediation more precise than a single final-answer score.

Safety and authorization checks

Assess whether approvals, permission checks, and validation occurred before sensitive actions. Use evaluation to find violations, while enforcing these requirements through independent runtime controls.

Quality and efficiency together

Measure redundant calls, retries, latency, and cost alongside task success and correctness. Avoid rewarding a shorter trajectory that omits necessary checks.

Repeatable, calibrated assessment

Use versioned test cases and application configurations, repeat nondeterministic tasks, and calibrate model-based judges against human review. Combine deterministic assertions with contextual assessment rather than relying on one scoring method.

Cloud services for Trajectory Evaluation

Amazon Bedrock supplies model and agent execution capabilities, while AWS Step Functions can coordinate explicit application stages and record workflow behavior. Amazon CloudWatch collects instrumented logs and evaluation metrics across these components. An evaluation harness correlates events for each task, checks required actions and ordering constraints, and optionally submits sanitized traces for human or model-based review. The resulting trajectory scores should be analyzed alongside final-answer quality, task success, latency, and cost. These services provide execution evidence and operational infrastructure; engineers must still define acceptable behavior, implement scoring logic, and protect sensitive trace data.

Amazon Bedrock

Agents for Amazon Bedrock can return trace information during agent invocation when tracing is enabled, exposing orchestration events and tool interactions for inspection. Engineers can use those events in a custom trajectory evaluation harness; collecting a trace does not itself establish that the execution was correct.

Open Amazon Bedrock →
AWS Step Functions image AWS Step Functions

AWS Step Functions orchestrates explicit workflows that can include model calls, validation, branching, and tool execution. Standard Workflow execution history provides evidence for evaluating state transitions, retries, and required dependencies; Express Workflows use configured CloudWatch logging for execution details.

Open AWS Step Functions →
Amazon CloudWatch image Amazon CloudWatch

Amazon CloudWatch can collect application logs and custom metrics describing model calls, tool use, errors, and timing. With correlation identifiers and appropriate instrumentation, engineers can query execution events and monitor metrics produced by their trajectory evaluators.

Open Amazon CloudWatch →