Why grading agent output alone misses failures in trace-based agent evaluation with promptfoo
An agent can return a correct final answer and still have failed. It may have called the wrong tool, called the right tools in the wrong order, retried a failing call until it got lucky, or swallowed an error and filled the gap with a plausible guess. An output assertion sees only the last message, so none of these failures show up in a standard eval. The team sees a green run, ships the agent, and discovers the problem later when a customer record is updated through the wrong API or a refund path is skipped. Trace-based evaluation exists for this gap: it grades what the agent did along the way, not only what it said at the end.
According to the promptfoo tracing documentation, trace-aware assertions check tool usage, execution paths, timing and errors. In practice that means asserting that a required tool was called, that a forbidden tool was never called, that steps happened in a required sequence, that no call exceeded a latency budget, and that no span recorded an error that the final answer papered over. A team needs this beyond output assertions when the agent's side effects matter more than its wording, when it runs multi-step tool loops, or when a wrong path can still produce an acceptable answer by chance. Before writing these checks, confirm with your engineers which spans your agent already emits and which tool names and attributes they carry, because assertions can only grade what the trace records.
Decide early which failures are blocking and which are advisory. Authorization failures, writes to the wrong system and skipped confirmation steps usually belong in hard gates, while latency or extra retries may only need reporting. Trace assertions also give graders a second input: the trace can be supplied as context to a model-graded rubric, so the judge can explain whether a path was reasonable rather than guessing from the final text. The sections that follow cover how spans reach promptfoo and how to write the assertions that use them.
How an agent run becomes a graded trace
A test case from promptfoo calls the agent under test, and the agent's OpenTelemetry SDK records spans for each model call, tool call and error. Spans leave the agent's infrastructure either directly or through an optional OpenTelemetry Collector, and promptfoo receives them in the eval run. Trace assertions then check which tools ran, in what order, and whether they failed, and the grader can receive the same trace as context. Check the boundary before any spans cross it, since traces can contain prompts, tool arguments and user data.
Spans cross from the agent's infrastructure into the promptfoo run.
Which trace assertion and context options fit which agent
Use this tab when the main risk is that an agent called the wrong tool, skipped a required tool, or called a tool it should never touch. Trace-aware checks read the tool-call spans that your application records during a run, so the assertion looks at what the agent actually executed rather than what its final text claims. This only works if your instrumentation emits a span for each tool invocation with a name that identifies the tool.
- Required tools: Assert that a specific tool was called at least once for a given test case, such as a lookup before an answer.
- Forbidden tools: Assert that a tool was not called, which is the simplest way to check authorization boundaries.
- Argument checks: Confirm that tool-call attributes carry the expected values, but only if your spans record arguments and you have reviewed what they contain.
- Span naming: Agree tool names with your application team before writing assertions, because the checks match on what the spans record.
- Test coverage: Include negative cases where the correct behavior is to call no tool at all.
Before relying on any tool check, confirm the exact assertion names and syntax in the promptfoo tracing documentation and verify that your spans carry the attributes you intend to test.
Use this tab when correctness depends on sequence, for example when an agent must check permissions before it writes data, or must retrieve context before it drafts an answer. Order checks compare the timing of spans within a single trace, so the trace must preserve parent and child relationships and timestamps accurately. If your agent runs steps concurrently, decide in advance which orderings are required and which are merely allowed.
- Precedence rules: Assert that one tool call happens before another, such as an authorization check before a write.
- Concurrency decisions: Separate hard ordering requirements from steps that may overlap, so tests do not fail on harmless parallelism.
- Retries: Decide whether a retried call counts as a repeat, since a retry can make a simple order check fail for the wrong reason.
- Sub-agent boundaries: Confirm that spans from nested agents or background workers reach the trace with correct parentage.
- Clock quality: Check that timestamps come from synchronized hosts, because skewed clocks can invert the apparent order.
Confirm the ordering assertion names and their exact behavior with concurrent spans in the promptfoo tracing documentation before building a suite around them.
Use this tab when an agent can technically finish but does so slowly, loops through tool calls, or silently swallows failures. Trace-aware checks can read span durations, counts and error status, which makes them useful for catching runaway loops and for confirming that failures are surfaced rather than hidden. These checks depend on the instrumentation recording status codes and timings consistently for every tool and model call.
- Latency ceilings: Assert that the overall run, or a single step, stays under a limit you set from your own service expectations.
- Call budgets: Cap the number of tool or model spans in one run to catch loops that still return a plausible answer.
- Error visibility: Assert that a failed tool call is either retried or reported, and that the final answer does not claim success after an error span.
- Status discipline: Make sure your application marks failed spans as errors, since unmarked failures pass these checks unnoticed.
- Threshold sourcing: Derive limits from measured baselines on your own infrastructure, not from generic numbers.
Confirm the timing and error assertion syntax, and the units each one expects, in the promptfoo tracing documentation.
Use this tab when the quality of an answer depends on how the agent reached it, and no deterministic check captures that. A model grader can receive the trace as context, so it can judge whether the agent used retrieved evidence, followed a sensible plan, or recovered sensibly from a tool error. This adds grading cost and variability, so reserve it for questions that objective assertions cannot express.
- Evidence use: Ask the grader whether the final answer rests on the tool results recorded in the trace, not on unsupported claims.
- Plan quality: Ask whether the sequence of steps was reasonable for the task, with the rubric written in plain terms.
- Trace size: Long traces inflate grader cost and can dilute the judgment, so trim spans to the fields the rubric needs.
- Sensitive content: Traces may contain user data or credentials, so review what gets sent to the grader model and where that model runs.
- Judge separation: Use a grader model separate from the model under test, as with other model-graded assertions.
Confirm how promptfoo passes trace context to graders, and which options control it, in the promptfoo tracing documentation before you write rubrics that depend on it.
Direct export or an OpenTelemetry Collector in front of promptfoo
This table compares sending spans straight from the agent to promptfoo with routing them through an OpenTelemetry Collector, running as an agent beside services or as a gateway. Read each row as a question to answer for your own agent fleet, and note that the Collector adds processing and authentication options in exchange for another component to run.
| Consideration | Direct export from the agent | Collector as agent or gateway in front of promptfoo |
|---|---|---|
| Pipeline components | Agent SDK exports spans to the promptfoo tracing endpoint with no intermediate service | Agent exports to a Collector, which forwards to promptfoo or to a second backend |
| Processing before storage | Limited to what the SDK does in the agent process | Can filter, sample, redact attributes and add resource fields before data leaves the network |
| Batching and retries | Depends on the SDK's exporter settings in each agent | Collector batching and export queues can be configured once for many services |
| Authentication | Each agent holds its own credentials for the trace endpoint | Authenticator extensions can check incoming connections, such as OIDC, and add credentials to outgoing requests |
| Deployment shape | Agent runs as the only service on the path | Agent sidecar or node-level agent per host, or a central gateway that many sources send to |
| Operations cost | Fewer moving parts, but credential rotation and exporter tuning repeat in every service | Another service to deploy, upgrade, monitor and secure, with configuration owned by a platform team |
| Component stability | Depends on your language's trace SDK, which is documented as stable in most languages | Core components have mixed stability levels, so check each component's README before relying on it |
| Verify before choosing | Confirm the promptfoo endpoint and auth method with your agent framework's exporter | Confirm which receivers, processors and exporters your chosen Collector build includes |
How to set up trace-based evals step by step
This sequence takes a team from a version check to a trace-aware grader, with a verification point at each stage so each layer is confirmed before the next is added. The result is an eval suite that grades which tools an agent called, in what order, and how the run unfolded, not only the final answer.
Confirm promptfoo and Node.js requirements
The engineer running evals checks that the promptfoo version in use is installed and that the machine meets its runtime requirement. The published npm release 0.124.1 requires Node.js 22.22.0 or newer, so the first check is
node --versionagainst that floor. Confirm the version in your CI images and developer machines as well, since an older runtime fails at install or at startup. The step is done whennpx promptfoo@latest --versionruns cleanly on every machine that will execute the suite.Instrument the agent with an OpenTelemetry SDK
The team that owns the agent adds an OpenTelemetry SDK for the language the agent is written in. Trace APIs and SDKs are stable in most languages, including Go, Java, JavaScript, Python and .NET, while log SDK maturity varies, so traces are the safer signal to start with. Wrap each model call and each tool invocation in a span, and record tool name, arguments summary, status and errors as span attributes. Check the language status on the OpenTelemetry status page before committing. The step is done when running one agent task locally produces spans for every tool call in a console or test exporter.
Export spans to promptfoo
Point the agent's trace exporter at the endpoint that promptfoo accepts, following the promptfoo tracing documentation for the exact configuration keys and the port it listens on. For a shared environment, an OpenTelemetry Collector can sit between the agent and promptfoo as an agent or gateway, which also gives you one place to apply processing and authentication. Keep credentials for the exporter in configuration, not in code. The step is done when a single eval run shows the spans for that run inside promptfoo, with the trace ID linked to the test case that produced it.
Write a small suite with one tool-call and one order assertion
The eval author writes a promptfoo configuration with one test case that asks the agent for a task requiring a specific tool, such as looking up an order before issuing a refund. Add a trace assertion that checks the named tool was called, and a second assertion that checks the order of two tool calls, for example that the lookup span starts before the refund span. Keep the suite to these two checks until they behave predictably. Trace-aware assertions check tool usage, execution paths, timing and errors. The step is done when the assertions are written against real span names from the exported trace, not names guessed from the code.
Run the suite and confirm the spans arrive
Run the suite from the command line and open the results for each test. Inspect the trace attached to the test and confirm the expected tool spans are present with the names and attributes the assertions reference. A common failure is a passing test that checks nothing because the span name never matched, so deliberately break one assertion once to confirm it fails. The step is done when a known-good run passes, a deliberately wrong expectation fails, and both results trace back to spans you can read.
Add a trace-aware grader
Once the objective trace assertions are reliable, add a model-graded check that receives the trace as context, so the grader can judge whether the agent recovered sensibly from a tool error or chose a reasonable path. Promptfoo allows traces to be given to graders as context. Write the rubric to judge specific observable behavior in the trace, and keep objective checks in place for anything a span can prove. Ask the grader's owner to review a sample of graded runs against human judgment before relying on the score. The step is done when a deliberately bad trace receives a failing grade and a good trace passes, confirming the grader reads the trace it is given.
Security risks in agent traces: data, credentials and trust
Traces record what an agent saw and did, so they can hold more sensitive content than the final answer does. The cards below cover where that exposure sits in a promptfoo setup: the trace payload, the exporter credentials, the receiving pipeline, the judge model and the place the data is stored.
Prompts, tool outputs and personal data
Span attributes often carry full prompts, retrieved documents, database rows and tool responses. A single customer record returned by a lookup tool can appear in a span that is then exported, stored and shown in a report. Before enabling tracing, list which attributes the agent records, decide which fields to redact or truncate at the instrumentation layer, and confirm who can open stored traces.
promptfoo tracing docsCredentials in exporter configuration
The exporter that sends spans to a Collector or backend usually needs a token or client secret. Placing that value directly in a configuration file or a CI variable that many jobs can read widens its exposure. Load the credential from a secrets store at runtime, scope it to write-only telemetry, and rotate it on the same schedule as other service credentials.
Receiver authentication with OIDC
A Collector that accepts spans from many test runners is an entry point. Collector authenticator extensions can check incoming connections on receivers, for example with OIDC, so unknown senders are refused. Decide which workload identities may send traces, configure the receiver to require them, and test that an unauthenticated request is rejected before the pipeline goes live.
Collector security best practicesSending traces to a judge model
When an llm-rubric or other model-graded assertion receives the trace as context, the trace content goes to the grader model. If that grader is a hosted provider, prompts, tool outputs and personal data leave your environment on every run. Confirm which provider receives the trace, whether its data terms allow the content, and whether a self-hosted judge model can be used for sensitive suites.
Evaluation data inside your infrastructure
promptfoo documentation states that evals run locally on your machine and talk directly with the LLM. That keeps the test harness under your control, but traces and results still need a defined home. Decide where the Collector runs, where spans are stored, how long they are kept, and whether the self-hosted promptfoo server or a shared results store will hold them.
promptfoo self-hosting docsCollector trust and release verification
The Collector runs in your pipeline and handles every span, so its build matters. Collector releases ship the contrib distribution with signed artifacts, SHA256 checksums and SBOM files. Verify those on download, pin a version, and review which receivers, processors and exporters your build includes, since core components have mixed stability levels.
Collector release artifactsQuestions teams ask before trace-based agent evaluation
What does trace-based agent evaluation cost and what drives it?
Cost comes mainly from people time, not licenses. The promptfoo Community edition is free under the MIT license, and the OpenTelemetry Collector is licensed under Apache-2.0, so the software line items are usually small. The larger components are instrumentation effort in the agent code, operating a Collector and a trace backend, and the size of the suite. Instrumentation scales with how many tools, sub-agents and model calls you want to see. Collector operation adds recurring work for upgrades, configuration and security review. Suite size drives model grader calls and CI run time, which recur with every run. Ask any partner for a quote that lists these components separately, along with what is one-time setup and what is ongoing.
How long does a first working trace-based eval setup take?
The first working setup usually takes longer than teams expect, because most of the time goes to instrumentation and agreeing on what a correct run looks like, not to writing assertions. The sequence is roughly: confirm the agent's tool calls and model calls are emitted as spans, route those spans to promptfoo, write a small set of trace assertions for one important scenario, then widen coverage. Duration depends on how many agent paths exist, how many languages and services the agent spans, and whether a Collector already runs in your environment. Ask for a timeline tied to a written scope with named milestones, since no general duration is fixed.
What must our team provide before the work starts?
The work depends on three inputs from your side. First, access to the agent code and the runtime where it executes, so spans can be added at the right points. Second, an agreed span naming and attribute convention, covering tool names, step order, error status and timing, so assertions read the same way across services. Third, test scenarios written by the people who know correct agent behavior, including the tasks the agent must refuse or stop on. Also plan for access to a Collector or a place to run one, and to the model providers used as graders. Missing scenarios are the most common reason a suite grades the wrong things.
Can our in-house team build trace-based agent evals alone?
Yes, if your team already runs OpenTelemetry instrumentation and has someone who owns agent behavior. Promptfoo is open source and can run from the CLI in a pipeline, and the trace assertion features are documented. Teams usually struggle in three places: keeping span names stable as the agent changes, deciding which trace facts belong in a deterministic assertion versus a model grader, and operating the Collector securely over time. A partner is most useful when those areas are new to you, or when you need the work finished against a fixed scope. Either way, assign a named owner for the span convention and the scenario set.
Is self-hosted promptfoo ready for shared production use?
Not as a shared production server in its default form. The self-hosting documentation says the self-hosted app stores data in a local SQLite database that cannot be shared across replicas, and that it has no RBAC, horizontal scaling, built-in authentication or SSO. It states the setup is not recommended for production use. Running promptfoo locally or in CI works well for individual teams. For shared access with team sharing, role-based access control and SSO, the promptfoo Enterprise or On-Premise editions add those features, priced by custom quote. Confirm current limits against the self-hosting documentation before you decide.
How does the Collector change the security and operations work?
The Collector sits between your agent and promptfoo, so it becomes an additional system to secure and keep current. Its configuration needs review for who can send data to it and where it exports. Collector authenticator extensions can check incoming connections, for example with OIDC, and add credentials to outgoing requests. Releases are frequent, so plan an upgrade routine and verify the signed artifacts, checksums and SBOM files that ship with each release. Some Collector components are at different stability levels, so check each component's README before you rely on it. Trace data can contain prompts and tool arguments, so decide what gets recorded before it leaves your network.
How big should the first trace-based eval suite be?
Start with a small suite built around the most consequential agent behaviors, then expand. A useful first set covers one successful task path, one path where a required tool must not be called, one error or timeout path, and one case where order matters, such as a lookup before a write. Each added scenario adds instrumentation checks, grader calls and CI time, so suite size is a direct cost driver. Grow the suite only when a real regression or incident shows a gap. Ask for a scenario list in the scope so the team can see what is covered and what is deliberately left out.
What to confirm with your agent and platform team
Before you write any trace assertion, confirm with the engineers who own the agent that its framework emits OpenTelemetry spans at all. Ask whether the agent framework or SDK is instrumented natively, through a community instrumentation library, or not at all, and whether tool calls, model calls and retries each produce their own span. The promptfoo tracing documentation describes how spans reach the evaluation, so check the current requirements there against the agent's actual version. If instrumentation is partial, a trace assertion will pass on whatever it can see, so ask the team to list which steps are missing before anyone writes a rule that depends on them.
Next, agree the span attributes that identify a tool call. Assertions on tool usage and order depend on stable attribute names, so ask which attribute carries the tool name, which carries arguments, and whether those names change between agent releases. Ask also how errors are recorded (status code, exception event or a custom attribute) and whether timing is measured on the same span the assertion will read. Write these names down as a contract. Renaming an attribute in production code will silently break every assertion that uses it, so the owning team should know the eval suite depends on it.
Two more questions belong in the same meeting. First, retention: find out how long the trace backend keeps spans, who can read them, and whether eval traces containing prompts, customer data or tool outputs fall under the same data handling rules as production traces. Second, grader calls: when a model-graded assertion or a trace-aware grader runs, confirm which provider receives the trace text, whether that provider is approved for the data, and whether the grader's own calls will be traced into the same pipeline. Collector-side controls, such as authentication on receivers described in the OpenTelemetry Collector configuration best practices, should be checked by the platform team before traces leave the network.
How DeployOpen scopes and delivers trace-based agent evaluation
DeployOpen plans, builds and hands over trace-based evaluation for agents running in infrastructure you control, starting from a written scope that names the agent, its tools and the trace data it emits. Work covers the promptfoo configuration, the telemetry path from your agent to promptfoo, and the runbooks your team needs after handover.
How we scope
- Inventory the agent's tools, expected call order and failure modes that the eval must catch.
- Confirm which OpenTelemetry instrumentation already exists and where spans are exported today.
- Agree in writing which trace assertions, graders and environments are in and out of scope.
How we build
- Configure the OpenTelemetry Collector pipeline that carries spans from the agent to promptfoo.
- Write trace assertions for tool usage, execution paths, timing and errors against recorded runs.
- Pass trace context to graders and check that judge prompts handle long traces without drift.
How we hand over
- Document the span schema, assertion library, collector configuration and known gaps in tracing.
- Run a joint walkthrough so your engineers can add a new tool assertion without our help.
- Deliver the eval suite, configuration files and a short runbook for upgrades and failed traces.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover.
- Review collector and promptfoo version changes before they reach your evaluation pipeline.
- Confirm support terms, response expectations and environment access in the written agreement.

