Reasoning Traces and Planning Benchmarks

Keeping useful evidence of how an agent decided, and measuring whether its plans actually work.

BeginnerIntermediateExpert · 12 min read · Last updated:

In short

Log what the agent did and on what evidence: requests, tool calls, results, decisions, versions and outcomes. Treat generated reasoning text as a clue, not as a faithful record, and keep secrets and personal data out of logs. Judge planning by checking plans and end states on your own tasks; use public benchmarks to understand trends, not to certify your system.

What you will learn: the layers of a trace, why reasoning text can be unfaithful, what to record and what to hide, how to evaluate plans automatically, which public benchmarks exist and how to build your own.
Prerequisites: How Agents Reason and Decompose Tasks. Agent Tracing and OpenTelemetry goes further into tooling.

Beginner Evidence of what happened

What is a trace?

A trace is the ordered record of one agent run. It lets you answer: what was asked, what the agent saw, what it chose, what changed and how it ended. Without it, debugging is guesswork and an audit is impossible.

Requestwho asked, goal, permissions, versions
Contextwhich documents and memories were used
Decisionschosen action with a short reason
Tool calls and resultsarguments, status, timing
Outcomestop reason, effects, cost, feedback
Each layer is linked by a run identifier and step numbers.

Reasoning text is not a window into the model

It is tempting to read a model's written reasoning as the true explanation of its answer. Research cautions against that. In a study by Anthropic researchers, models were given hints in their prompts, and in many cases they used a hint without mentioning it in their reasoning. The authors concluded that monitoring such text is unlikely to catch rare unwanted behavior reliably. Earlier work on measuring faithfulness in chain-of-thought found similar variation.

Practical consequences follow:

  • Verify actions and results; do not accept a persuasive explanation in their place.
  • Use reasoning text to form hypotheses when debugging, then test them.
  • Do not build safety controls that depend on the model confessing its intent.
  • Remember that you may only receive a summary, or nothing: providers of reasoning models often keep the full text internal while still billing for those tokens.
Explanations for people

When a user or auditor asks why something happened, build the answer from recorded facts: the rule applied, the data used, the action taken and who approved it. See Transparency, Accountability and Audit Evidence.

What to log, and what not to expose

ItemLog it?Show it to users?
Run, step and parent identifiersYesA reference number only
Model, prompt and tool versionsYesRarely needed
Chosen action and short reasonYesIn plain language where helpful
Tool arguments and resultsYes, redacted and size-limitedOnly the user's own relevant data
Raw reasoning textOnly if needed, restricted and short-livedGenerally no
System promptBy versionNo by default; never rely on it staying secret
Passwords, keys, tokensNeverNever
Personal and sensitive dataMinimize or maskOnly to those entitled
Timing, tokens, cost, stop reasonYesAs useful

Questions a trace should answer

Before choosing fields, list the questions you will be asked after something goes wrong. A good trace answers each in minutes:

QuestionField that answers it
Who started this and with what authority?User or service identity, granted permissions
Which version of the system acted?Model, prompt, tool and code versions
What did the agent know at that moment?Identifiers of retrieved documents and memories
What did it try to change?Tool name, arguments and a unique operation key
Did the change happen?Result status and a read-back where possible
Who approved it?Approver, time and exactly what was shown
Why did the run end?Stop reason from a fixed list
What did it cost?Tokens, tool fees and duration per step

If a question has no field, add one now. Information that was never recorded cannot be recovered after an incident.

Intermediate Structured, safe logging

Structured events with redaction

Write each event as one structured record. Remove sensitive values before the record is written, so they never reach storage:

"""Record decisions as structured events, with sensitive values removed."""
import json
import re

SECRET_KEYS = {"api_key", "password", "authorization", "token"}
PATTERNS = [(re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+"), "[email]"),
            (re.compile(r"\b(?:\d[ -]?){12,15}\d\b"), "[card]")]

def redact(value):
    if isinstance(value, dict):
        return {k: "[secret]" if k.lower() in SECRET_KEYS else redact(v)
                for k, v in value.items()}
    if isinstance(value, list):
        return [redact(v) for v in value]
    if isinstance(value, str):
        for pattern, label in PATTERNS:
            value = pattern.sub(label, value)
    return value

def event(run, step, kind, **fields):
    record = {"run": run, "step": step, "kind": kind, **redact(fields)}
    return json.dumps(record)

if __name__ == "__main__":
    print(event("r-81", 1, "decision", choice="look_up_customer",
                reason_summary="need the account for ana@example.com"))
    print(event("r-81", 2, "tool_call", tool="look_up_customer",
                args={"email": "ana@example.com", "api_key": "sk-demo-123"}))
    print(event("r-81", 3, "tool_result", ok=True,
                note="card 4111 1111 1111 1111 on file"))

Output:

{"run": "r-81", "step": 1, "kind": "decision", "choice": "look_up_customer", "reason_summary": "need the account for [email]"}
{"run": "r-81", "step": 2, "kind": "tool_call", "tool": "look_up_customer", "args": {"email": "[email]", "api_key": "[secret]"}}
{"run": "r-81", "step": 3, "kind": "tool_result", "ok": true, "note": "card [card] on file"}

The values shown are invented test data. Pattern matching catches only what you anticipate: it will miss names, addresses, unusual formats and secrets under unexpected field names. Prefer an allow list of fields that may be logged, redact at the source and test the redaction with examples. See Safe Logging, Sampling and Retention.

A good decision record

Ask the agent to return, along with each action, a brief structured note: the action chosen, the evidence it relied on by identifier, any assumption made and what would change the decision. This note is still model output and shares the faithfulness limit, but identifiers can be checked against what was actually retrieved. A note that cites a document the agent never received is itself a useful alarm.

Retention and access

  • Decide how long each kind of record is kept, and delete automatically.
  • Limit who can read traces, and log that access too.
  • Keep high-detail traces for a sample or for failed runs only.
  • Honor deletion requests in logs as well as in databases.
  • Tell users what is recorded and why.

Open standards help you avoid lock-in. OpenTelemetry publishes semantic conventions for generative AI, which name common attributes for model and tool calls; check their current maturity before depending on them.

What makes a plan good?

DimensionQuestionHow to check
ValidityIs every step possible when it runs?Simulate preconditions and effects
Goal successIs the end state correct?Compare state with the goal
SafetyWere forbidden actions avoided?Rules over the whole sequence
EfficiencyWere there needless steps?Compare with a known short plan
AdaptationDid it recover after a failure?Inject faults
HonestyDid it report impossibility?Include unsolvable tasks
CostCalls, tokens and timeFrom the trace

A small plan checker

If you can describe actions by what they require and produce, code can judge a plan without a model:

"""Check a proposed plan by simulating it, step by step."""

ACTIONS = {  # name: (needs, adds, removes)
    "unlock":   ({"have_key", "at_door"},  {"open"},     set()),
    "take_key": ({"at_desk"},              {"have_key"}, set()),
    "go_desk":  (set(),                    {"at_desk"},  {"at_door"}),
    "go_door":  (set(),                    {"at_door"},  {"at_desk"}),
    "enter":    ({"open", "at_door"},      {"inside"},   set()),
}
GOAL = {"inside"}
SHORTEST = 5

def evaluate(plan):
    facts = {"at_door"}
    for number, name in enumerate(plan, start=1):
        if name not in ACTIONS:
            return f"invalid: step {number} '{name}' does not exist"
        needs, adds, removes = ACTIONS[name]
        if not needs <= facts:
            missing = ", ".join(sorted(needs - facts))
            return f"invalid: step {number} '{name}' lacks {missing}"
        facts = (facts - removes) | adds
    if not GOAL <= facts:
        return "valid steps, goal not reached"
    extra = len(plan) - SHORTEST
    return "success, shortest" if extra == 0 else f"success, {extra} extra"

if __name__ == "__main__":
    plans = {
        "A": ["go_desk", "take_key", "go_door", "unlock", "enter"],
        "B": ["take_key", "unlock", "enter"],
        "C": ["go_desk", "take_key", "unlock", "enter"],
        "D": ["go_desk", "take_key", "go_door", "go_desk", "go_door",
              "unlock", "enter"],
        "E": ["go_desk", "take_key", "go_door", "unlock"],
    }
    for name, steps in plans.items():
        print(name, evaluate(steps))

Output:

A success, shortest
B invalid: step 1 'take_key' lacks at_desk
C invalid: step 3 'unlock' lacks at_door
D success, 2 extra
E valid steps, goal not reached

The five plans fail or succeed in different ways, and each message points to a cause. Plan D reaches the goal with wasted steps, which a pass-or-fail score would not show. For real systems, simulate against a copy of the data or a fake service that enforces the same rules.

When there is no single correct plan

Many tasks allow several good routes. Score them by properties instead of comparing with one reference: the end state is acceptable, no rule was broken, required checks happened before changes, and cost stayed within limits. For open tasks such as research, combine automatic checks, for example that every claim cites a retrieved source, with human or calibrated model grading of completeness. Avoid penalizing a route merely because it differs from the one you imagined.

Also check ordering rules, which are easy to write and powerful: identity verified before account data is read, state read before it is changed, approval obtained before execution. A single pass over the trace can test each of these on every run, including runs in production.

Expert Benchmarks and their limits

Public benchmarks for multi-step work

BenchmarkTestsNote
GSM8KGrade-school math word problemsEarly reasoning measure; largely saturated by strong models
PlanBenchPlanning and reasoning about change, from classical planning domainsPlans can be verified exactly
τ-bench and successorsTool use with a simulated user and domain rulesScores final state; reports consistency
GAIAQuestions needing several steps and toolsGeneral assistant ability
SWE-bench familyResolving real software issuesVerified by tests; for coding agents
ARC-AGIAbstract pattern puzzlesGeneralization rather than business tasks

Agent Benchmarks and Datasets compares agent benchmarks in more depth.

Reading scores carefully

  • Which system? A score belongs to a model, prompts, tools and retries together.
  • How many attempts? Best of many is not the same as a single try.
  • What did it cost? High scores bought with huge budgets may be useless to you.
  • Could the test have leaked? Public questions may appear in training data.
  • Are the labels right? Benchmarks contain errors and get revised.
  • Which version? Compare like with like.

Build your own planning benchmark

  1. Pick 30 to 100 real multi-step tasks, with personal data removed.
  2. Define the starting state, the goal state and forbidden actions for each.
  3. Provide a simulator or sandbox that can be reset.
  4. Include easy, hard, ambiguous and impossible tasks.
  5. Run each several times and report success, consistency, steps and cost.
  6. Store full traces so that failures can be classified.
  7. Version the benchmark and keep some tasks hidden.

From traces to improvements

Group failed runs by the first step that went wrong, not by the final symptom. Typical groups are misread goal, wrong information retrieved, wrong tool, bad arguments, ignored error and premature stop. Count the groups, fix the largest, and add a case that would catch it again. This loop turns logs from a storage cost into the main source of progress. Debugging Agents, RAG and Handoffs shows how to replay a step.

Illustrative example: a plausible but false story

An invented agent explains that it approved a discount because of the customer's long history. The trace shows the history lookup failed and returned nothing. The team adds a rule that a failed lookup blocks approval, and a check that cited evidence exists in the run.

Log enough to replay

If you can reconstruct the exact inputs of a failed step, you can test a fix against it immediately. That usually needs the prompt version, retrieved items and tool results, kept under the same protections as the original data.

Deciding what to keep

Detailed traces are large and sensitive, so most teams do not keep everything for ever. A workable policy keeps a small structured summary of every run, full detail for runs that failed, hit a limit, changed something important or received a complaint, and full detail for a random sample of the rest. The random sample matters: if you keep only obvious failures, you will never notice runs that looked successful and were wrong. Review a few of those samples regularly, with the same care as incident traces.

Decide as well who may see detail. Developers often need structure, timings and status codes, which can be shared widely. The content of messages and documents usually needs tighter access, granted for a reason and recorded. Separating the two stores makes this practical.

Common mistakes

  • Logging everything and protecting nothing.
  • Logging only final answers, so failures cannot be explained.
  • Presenting generated reasoning to auditors as a record of cause.
  • Scoring plans by how convincing they read.
  • Choosing a model on a public score that does not resemble your task.
  • Changing the benchmark and comparing new scores with old ones.

Trace and benchmark checklist

  • Every run has identifiers, versions and a stop reason.
  • Sensitive values are removed before writing.
  • Retention periods and access rights are defined.
  • Explanations are built from recorded facts.
  • Plans are verified by simulation or end state.
  • Impossible tasks are part of the test set.
  • Failures are classified and fed back into tests.

Frequently asked questions

Should I store the model's reasoning?

Store it only if you have a clear use, with restricted access and short retention. Actions, evidence and results are more reliable and usually enough.

Can reasoning text be shown to customers?

It is safer to show a plain explanation built from facts. Raw text can be wrong, confusing or reveal internal rules or other data.

Which benchmark proves my agent is ready?

None. Readiness comes from your own tests on your own tasks, safety checks and a monitored rollout.

References and further reading

Next steps