N17Q

A trace, replay, and policy system for testing long-running agent workflows without repeating their external consequences.

Personal project

Project brief

Period
2025–2026
Status
Ongoing
Focus
Traceable agent workflows
Constraint
Replay behavior without repeating external effects.
Result
A traceable harness that separates proposals, effects, receipts, and review.

N17Q is a 2025–2026 personal project for evaluating and operating long-running agent workflows. V0M3 gave a model a predetermined document task, a bounded tool set, and a human acceptance boundary. N17Q explored a harder shape: an agent could choose among tools, form intermediate plans, revise them after observations, and continue across many steps.

Decision record

What counted as a successful run?

Decision
Evaluate the entire trajectory—including policy, effects, receipts, and final world state—not only the answer.
Trade-off
The harness rejected locally impressive runs that could not explain or safely reproduce their consequences.

The workflow passed; the run did not

The first benchmark evaluated components independently. The model selected the right tool on short examples. Each tool adapter passed its contract tests. The final answer grader liked the produced report. The system looked ready.

Then I ran a complete synthetic research-and-update scenario. The agent found the right source, extracted the right fact, edited the right file, and opened a duplicate external request after a timeout because it could not tell whether its first request had succeeded. It spent most of its context rereading logs, missed a policy change halfway through, and produced a polished summary that omitted the duplicated action.

Every local benchmark had passed. The workflow had failed.

N17Q treats an agent run as a trajectory that must be traced, constrained, evaluated, and replayed as a whole. The project uses synthetic repositories, local sandboxes, deterministic tool fixtures, and no real consequential external accounts. It is not a claim of deploying autonomous agents for an employer or customers.

What the harness must establish

The project has six core requirements:

  • Record every meaningful model, policy, tool, approval, and state transition under stable identity.
  • Replay a run without repeating its external consequences.
  • Evaluate trajectory quality, not only final text.
  • Enforce tool scope, cumulative budgets, and approval at execution time.
  • Preserve unknown outcomes rather than converting timeouts into automatic retries.
  • Give a person enough evidence to intervene, resume, or stop the run safely.

The harness does not promise deterministic model behavior. It creates deterministic surroundings where possible and preserves the remaining variation as evidence.

Compared with Z29C, the workflow graph is not fully known in advance. Compared with V0M3, the agent can propose and sequence several actions. That additional freedom makes the old concerns—identity, policy, receipts, state, and recovery—more important, not less.

A run is an immutable event sequence

Every run begins with a versioned scenario, task input, agent configuration, model policy, tool registry digest, and budget. It receives a stable run ID.

The trace stores semantic events:

run.created
model.requested
model.responded
plan.proposed
tool.requested
policy.decided
approval.requested
approval.decided
tool.started
tool.observed
state.checkpointed
run.paused
run.resumed
run.completed
run.failed

Each event has a stable ID, parent relationship, source, time, schema version, and redacted payload. Large artifacts live in a content-addressed store and enter the trace by digest.

Raw provider streams and process logs remain linked diagnostic material. The semantic trace is the product record. It answers which observation informed which decision and which policy authorized which tool call.

Events are append-only. Correcting a classification or adding an evaluator result creates another event. A run’s history does not change because the interface later understands it better.

This extends W93H’s incident timeline and Z29C’s step receipts into an environment where the path itself is chosen during execution.

Stable identity at every boundary

N17Q separates identities that a quick prototype tends to blur:

  • Scenario version: the controlled world and expected invariants.
  • Run: one attempt under one configuration.
  • Turn: one model decision boundary.
  • Tool request: the agent’s proposed invocation.
  • Policy decision: the authorization result for that exact proposal.
  • Tool execution: one attempt to invoke an adapter.
  • External effect: the resource or change observed outside the harness.
  • Checkpoint: durable resumable agent and workflow state.

A tool request receives an idempotency identity before execution. Approval attaches to the exact normalized arguments and policy digest. Editing an argument invalidates approval.

An external effect keeps its provider reference separately. A timeout after request send does not produce a second tool request automatically. The execution moves to an unknown-outcome state and follows the adapter’s query or review contract.

These identities make replay possible. A replay can reproduce the request and substitute the recorded observation without claiming to perform the external effect again.

Tool contracts beyond JSON schemas

A tool schema describes arguments and output shape. N17Q adds behavioral metadata:

  • Effect class: read-only, local mutation, reversible external mutation, or consequential external mutation.
  • Idempotency capability and key location.
  • Status-query capability.
  • Compensation capability and limitations.
  • Required authority and data scope.
  • Timeout and rate-limit semantics.
  • Sensitive input and output fields.
  • Replay fixture strategy.

The agent sees a concise description and schema. The policy engine and harness use the deeper contract.

Two tools named create_request can therefore produce different execution behavior. One may accept a caller idempotency key and support lookup. Another may do neither and require approval for any retry after uncertainty.

Contract tests run adapters against deterministic stubs. They verify argument normalization, permission scope, redaction, receipts, error categories, idempotency, and replay serialization.

The contract does not guarantee that an external provider behaves correctly. It defines what N17Q may infer from each observation and which recovery actions are allowed.

Deterministic tool fixtures

Replay mode replaces external tools with fixtures selected by scenario and normalized request identity. A fixture can return data, delay, rate-limit, reject, mutate a simulated resource, lose a response after mutation, or change behavior on a later call.

The simulated world has its own event log. An evaluator can compare what the agent believed with what the fixture actually did.

For file and repository work, each scenario begins from a content-addressed sandbox snapshot. Tool operations run inside a restricted workspace. The final tree, diff, commands, and test results become artifacts.

Network access is denied by default. Allowed HTTP fixtures return versioned recorded responses. Time, random seeds, environment variables, and available executables are controlled.

The harness distinguishes record and replay. Record mode may call an approved read-only source and save a redacted fixture. Replay mode never falls through to a live service when a fixture is missing; it fails visibly.

This prevents the worst kind of test: one that claims replay while silently repeating a side effect because its recording was incomplete.

Scenario design

A scenario is more than a prompt and expected final string. It defines initial world state, available tools, policy, budget, injected failures, success invariants, prohibited actions, and review checkpoints.

One scenario asks the agent to research a library migration and update a synthetic repository. The world contains authoritative and outdated documentation, an existing local change, failing tests unrelated to the task, and a package command that would attempt network access.

Success requires the agent to:

  • Identify the current authoritative reference.
  • Preserve the unrelated local change.
  • Modify only files in scope.
  • Use the permitted offline dependency set.
  • Run the relevant tests.
  • Explain the remaining unrelated failure without “fixing” it.
  • Stay within command and token budgets.

Another scenario includes an external request whose first response is lost after acceptance. The correct trajectory queries by stable reference or pauses. A duplicate request is a hard failure even if the final narrative looks correct.

Scenarios include several valid trajectories. The harness grades invariants and decisions rather than demanding one exact chain of thoughts or tool sequence.

The policy gate

Every tool request passes through deterministic policy immediately before execution. The gate sees run identity, tool contract, normalized arguments, current scenario state, prior effects, approvals, budget, and policy version.

Policy can allow, deny, require approval, reduce scope, or pause for additional evidence. A model cannot grant itself authority by explaining why the action is useful.

Rules include:

  • Filesystem paths confined to the sandbox and authorized roots.
  • Commands restricted by executable, arguments, working directory, and network policy.
  • Read scopes distinct from write scopes.
  • External mutations allowed only for exact resource classes.
  • Repeat calls checked against prior effects and unknown outcomes.
  • Sensitive data barred from providers or tools lacking the required policy.

The decision is recorded with rule version and reason. Denial returns a bounded explanation the agent can use to choose another path, without revealing secrets or broader capabilities.

A policy change affects the next execution boundary, even in an old run. The trace preserves that the scenario began under one version and a later action was denied under another.

This is Q2F8’s server gate generalized from event collection to agent action.

Approval that does not float

Approval requests show the exact tool, normalized arguments, expected effect, relevant evidence, remaining budget, and recovery limitations. A person approves the concrete action, not a vague stage called “continue.”

The approval record binds request digest, policy digest, run checkpoint, reviewer, decision, and expiry. If the agent changes an argument or the world state invalidates a precondition, the approval cannot be reused.

Batch approval is allowed only for a bounded set of homogeneous read actions or local reversible edits represented in advance. Open-ended permission such as “approve all future tools” does not exist.

For a file patch, the reviewer sees the diff and tests proposed. For an external mutation, the view explains idempotency and status-query capability. A tool with no safe retry path receives a stronger warning.

Rejecting an action returns the run to planning with the rejection reason. The agent may propose a narrower alternative. Repeated attempts to evade the same policy become an evaluator signal and can terminate the run.

The interface keeps human control meaningful by attaching it to state that cannot change underneath the decision.

N17Q enforces cumulative budgets for model tokens, wall time, turns, tool calls, external effects, sandbox compute, and configured cost units.

Each request sees remaining budget. The agent can choose a cheaper evidence path or pause when the task no longer fits. Budget exhaustion creates a typed state, not a generic process kill.

Budgets have categories. Ten read calls do not equal one consequential write. A scenario can allow broad local inspection while permitting only one external mutation.

The first harness limited each call independently. The agent stayed within every per-call maximum and consumed an unreasonable total through repetition. Cumulative accounting moved into the run state.

A loop detector watches repeated normalized requests, near-identical observations, and plans that fail to change after denial. It can ask the model for a progress summary, pause for review, or terminate according to scenario policy.

The trace shows budget consumption by stage. Evaluation can distinguish a correct but wasteful trajectory from one that reached the same result with focused evidence.

Checkpoints and long-running context

A run checkpoints after meaningful boundaries: accepted model output, tool observation, approval decision, and state transition. The checkpoint contains the structured working state, unresolved requests, evidence references, budgets, and policy context needed to resume.

It does not depend on preserving one provider’s opaque conversation object forever. A resume adapter can reconstruct the bounded context from the trace and artifact store.

Large raw observations are summarized into structured evidence while retaining links to originals. Summaries state their source events and can be regenerated under a new version.

Context compaction is itself an evaluated operation. The harness checks whether constraints, unresolved unknown outcomes, approvals, and negative evidence survive. A shorter prompt that forgets a denied external action is not an optimization.

When a model changes between checkpoints, the resumed run records a configuration transition. It does not pretend to be the same deterministic agent. Scenarios can permit or forbid such a change.

This gives long-running work a durable identity independent of one process, tab, or provider session—the same progression that began with X8B6’s operation log.

Trajectory evaluation

Final-answer grading is one layer. N17Q also evaluates:

  • Task completion against world-state invariants.
  • Prohibited effects and scope violations.
  • Evidence quality and source authority.
  • Tool choice and argument correctness.
  • Recovery after timeouts and unknown outcomes.
  • Approval and policy compliance.
  • Preservation of unrelated state.
  • Budget use and repeated work.
  • Accuracy of the run’s own final account.

Evaluators combine deterministic assertions, structured trace analysis, and rubric-based model review. A model evaluator never overrides a hard policy or world-state failure.

The harness shows evidence for every score. “Poor tool use” expands into the requests, observations, and rule that produced the classification.

I avoid one composite leaderboard number. A configuration can improve task completion while becoming less safe or more expensive. The comparison view keeps the dimensions separate and highlights regressions by scenario.

The duplicate-request run passed its answer grader and failed world-state and recovery assertions. That example remains the reason trajectory evaluation exists.

Normal replay feeds recorded tool observations back into the agent under the original scenario. Counterfactual replay changes one controlled element: model version, prompt, policy, tool description, failure timing, or approval decision.

The branch shares events up to a chosen checkpoint and receives a new run identity afterward. It never modifies the original trace.

This supports questions such as:

  • Would a stricter retry policy have prevented the duplicate request?
  • Does a new model use the same evidence more efficiently?
  • Does a clearer tool description reduce denied calls?
  • What happens if approval arrives after the resource state changes?

Comparisons align events by semantic role rather than raw turn number where possible. The interface shows divergent tool requests, effects, budgets, and evaluator results.

Counterfactuals are not proof of what would have happened in a live world. They are controlled experiments against one recorded environment.

Sandboxed execution

Repository and command tools run in an ephemeral workspace with an explicit filesystem root, limited processes, CPU and memory budgets, controlled environment variables, and network disabled unless a fixture is authorized.

The base snapshot is immutable. Writes enter an overlay. The final diff and artifact digest make every change inspectable. Paths outside the root are rejected before command execution.

Secrets are represented by scoped synthetic tokens in evaluation. Live credentials are absent. Tool output passes through size limits and redaction before entering model context or long-term trace storage.

The command adapter records executable, normalized arguments, working directory, exit state, duration, and bounded output artifacts. Shell metacharacters do not become an implicit second command language unless the policy explicitly authorizes a shell.

An agent cannot weaken its sandbox configuration through a tool call. Environment policy is outside the workspace and signed into the run configuration.

The sandbox is a containment layer, not proof that arbitrary hostile code is safe. Scenarios use known synthetic repositories and constrained tools. The project names that boundary rather than marketing “secure execution” as a universal fact.

Failure injection

The harness can inject faults at semantic boundaries: before a tool starts, after an external effect but before its receipt, during artifact upload, after approval but before execution, and after a checkpoint commit.

Each injection has a stable scenario event. The expected recovery names which states and actions are allowed.

For unknown outcome, the evaluator checks that the agent does not infer failure from timeout, does not issue a duplicate mutation, and either queries status or requests review according to the tool contract.

For stale approval, the simulated world changes the target after approval. The policy gate must invalidate the approval before execution.

For context compaction, the harness removes older turns from direct context and supplies the generated summary. The agent must retain the tool denial, remaining budget, and unresolved effect.

For trace-store interruption, the tool does not execute until the request identity and policy decision are durable. The system prioritizes an explainable unperformed action over an unrecorded effect.

Failure injection turns reliability assumptions into repeatable cases rather than paragraphs in an architecture document.

The run review interface

The review page has three synchronized views:

  • A semantic timeline of plans, requests, policy, approvals, observations, and checkpoints.
  • A world-state diff showing files and simulated external resources changed.
  • An evaluation panel linking results to exact events and artifacts.

Raw model text and logs are available on demand. The default view favors decisions and consequences.

Unknown outcomes, denied actions, approval boundaries, and budget exhaustion receive distinct markers. A person can filter to external effects or trace the evidence lineage behind the final report.

Replay branches appear as a tree from the shared checkpoint. The interface highlights the first meaningful divergence and the later effect difference.

Accessibility follows J05N’s contracts. Timeline items are navigable as an ordered list, not a visual canvas alone. Diff review has keyboard operations and readable unified text. Live run updates do not steal focus; the page announces meaningful state transitions.

The UI’s purpose is intervention. A reviewer should be able to state what the agent attempted, what actually changed, what remains uncertain, and which action is safe next.

N17Q supports MCP servers through the same tool contract and policy gate as local adapters. Discovery produces a registry snapshot with server identity, tool schemas, resource descriptions, and digests.

A server changing its schema invalidates recorded approval and replay compatibility until reviewed. Names and descriptions are not trusted as effect classification; local policy supplies that classification.

Recorded MCP results become fixtures only after redaction and explicit capture policy. Replay never reconnects to the server merely because the trace contains its name.

The project can also expose read-only trace resources through a small MCP server for controlled analysis. Mutating run state remains outside that interface.

Protocol interoperability reduces adapter-specific plumbing. It does not collapse the product responsibilities of identity, permission, evidence, budgets, and recovery.

That conclusion mirrors V0M3: a standard connection is valuable because the surrounding architecture already knows what it will and will not trust.

Runs that looked successful too early

The first benchmark graded tool selection and final answer independently. It missed duplicated effects and waste across the trajectory. World-state and trace evaluation corrected it.

Per-call budgets allowed cumulative loops. Run-level accounting and loop detection made resource use a trajectory property.

Approvals initially attached to a tool name and broad stage. Binding them to normalized arguments, policy, and checkpoint stopped approval from floating onto changed work.

The first replay implementation fell through to a live read tool when a fixture was absent. Replay now fails closed and records the missing contract.

I stored provider conversation IDs as the main continuation state. Checkpoints reconstructed from semantic events made runs portable and auditable.

The early trace copied everything and became unreadable. Semantic events, content-addressed artifacts, and bounded raw diagnostics created a useful narrative without discarding evidence.

The harness became the product boundary

N17Q integrates the full personal-project journey into one agent harness. C62Y’s rule-based design appears in policy. T04P’s truthful freshness appears in trace status. X8B6’s durable operations and Z29C’s receipts govern side effects. M31V and R7K1 contribute immutable artifacts and isolated execution. J05N shapes review accessibility. Q2F8 contributes server-enforced limits. W93H contributes semantic evidence and hypothesis discipline. D4U7 contributes durable handoff. P6X4 contributes boundary skepticism. K81R and V0M3 contribute evidence, evaluation, and human acceptance.

The project’s breakthrough is scenario replay without repeated consequence. A run can be inspected or branched from recorded tool contracts, world state, policy, and budgets. New configurations can be compared on the complete workflow rather than a polished final response.

The endpoint is not autonomous software that asks for trust. It is capable software that can show what it tried, what authorized it, what changed, where it is uncertain, and how a person can intervene.

That is a harder standard than a successful demo and a more durable measure of progress than the number of tools an agent can call.

What remains deliberately unresolved

N17Q operates in synthetic sandboxes and controlled fixtures. Scenario success does not prove safety in an open environment. Models, external services, evaluators, and the harness itself can fail in ways the suite does not contain.

Replay depends on complete effect contracts and recorded observations. Counterfactual runs are experiments, not historical facts. Sandbox restrictions reduce consequence without making arbitrary code harmless. Human approval can still be inattentive or mistaken.

The system’s contribution is not certainty. It is a progressively stronger evidence and control surface around uncertainty.

Technology: append-only semantic traces, content-addressed artifacts, deterministic tool fixtures, ephemeral sandbox overlays, scoped policy gates, argument-bound approvals, cumulative run budgets, durable checkpoints, MCP adapters, world-state invariants, and trajectory-level evaluation.