Skip to content

evidence: a retried gateway call must distinguish attempted, not executed from executed again, per attempt #527

Backlog

Description

@blitzcrieg1

Problem

An agent tool call goes through a gateway (a model API, a remote tool runner, a workflow service). The response is lost, so the agent retries. Today the trail records two tool_called events with the same correlation ID and the same tool.input_hash, and a reviewer cannot tell which of two very different things happened:

  • the gateway deduplicated the retry and returned the original run ID, so the second attempt never ran downstream, or
  • the first attempt genuinely failed and the retry executed downstream a second time.

The first is harmless. The second can re-run a migration, a payment or a test and hide the first failure. Rowan raised this on the Hugging Face thread (post 25, retry question by StarFans): the gateway run ID returned per attempt is the tell. A correlation ID alone does not capture it.

What the schema already has

  • correlation_id groups both attempts into one session.
  • tool.input_hash (with input_redaction: hash) proves the two attempts sent identical arguments without keeping bodies.
  • tool.invocation (phase, hook_event, provenance: harness_reported, bounded id) and tool.result (reported_success / reported_failure, duration_ms, error_kind) carry the harness's per-attempt view (evidence: link tool requests, permission decisions and reported results by invocation ID #412 built this model).
  • Guard network_egress events carry connection_established for independent connection evidence.
  • The AGT importer already keeps missing outcomes explicitly unknown rather than silently absent.

None of these carry the gateway's own run identifier for the attempt, so the retry story stays ambiguous.

Proposal: an additive, optional per-attempt gateway receipt

Reuse the existing per-attempt event shape. Add an optional, bounded tool.receipt block on the attempt that saw a gateway response:

  • run_id: the gateway-reported run identifier for that attempt, bounded the same way as tool.invocation.id (1 to 256 printable ASCII characters).
  • status: a small allowlist of gateway-reported outcomes (for example succeeded, reused_existing_run, failed), never free text.
  • provenance: gateway_reported, so it is never confused with harness-reported or sensor-observed evidence.

Raw idempotency keys, request bodies, headers and response payloads stay out of the event, matching the existing hash-only argument guarantees. An attempt with no observed response carries no receipt. Downstream execution is a separate, first-class observation with its own identifier and key, explicit unknown when evidence is missing, and it never depends on a receipt to exist or to be counted.

The three synthetic traces

Fixture data only, no live services.

Trace A: lost response, deduplicated retry. One session. Attempt 1 is recorded as a tool_called with the gateway connection observed, no receipt (the response was lost), result unknown. Attempt 2 is the same tool with the same input_hash, and carries a receipt with run_id R1 and status reused_existing_run. Downstream execution is observed exactly once, attributed to R1. The trail must read: attempt 1 executed downstream (run R1), attempt 2 was attempted, not executed.

Trace B: recorded failure, re-executed retry. One session. Attempt 1 carries a receipt with run_id R1 and status failed, plus downstream failure evidence. Attempt 2 carries a receipt with a new run_id R2 and status succeeded, plus downstream success evidence. The trail must read: two executions, the first failed, the second succeeded.

Trace C: both responses lost, execution observed once. One session. Attempt 1 and attempt 2 both carry no receipt, the same correlation_id and the same input_hash, and downstream evidence shows exactly one execution with no run ID attached anywhere. The trail must read: attempted twice, executed once, run ID unknown. This is the case production actually produces, raised in this comment by the AER-1 author.

In every trace the first attempt is preserved, each attempt keeps the shared correlation_id, its own result status, and the run ID the gateway returned for that attempt when one was seen.

Acceptance criteria

  1. An analyst reading the fixtures sees different stories without guessing: Trace A shows exactly one distinct gateway run ID, attached to attempt 2, with one downstream execution; Trace B shows two distinct run IDs and two downstream executions, first failed; Trace C shows two attempts with no receipts and one downstream execution with run_id: unknown. A join on (correlation_id, run_id) is one supported reader and yields one group in A and two in B; it yields zero groups in C, so it is never the only reader.
  2. Attempt 1 is present in every trace; a retry never replaces or rewrites it.
  3. Downstream execution is recorded separately from the gateway receipt, and missing downstream evidence yields an explicit unknown, not silence and not an inferred verdict.
  4. The fixtures and events contain no credentials, no raw idempotency keys and no request or response bodies; only hashes, bounded identifiers and allowlisted statuses.
  5. The schema change is additive and optional (a missing tool.receipt changes nothing for existing events and consumers), following the documented minor-bump convention.
  6. A gateway run ID establishes what the gateway reported for that attempt; it is never treated as proof of downstream execution on its own.
  7. Downstream execution is a first-class observation with its own identifier and key, never a join product of correlation_id and run_id. In Trace C, a consumer that joins only on (correlation_id, run_id) must not conclude nothing executed: the single downstream execution remains visible and countable without any run ID. An implementation cannot satisfy criteria 1 and 2 with a run_id-only reader.

Overlap and related standards

Out of scope

Capture-side work (where each adapter obtains the gateway run ID), response size accounting (#45), and guardrail receipts (#294). Implementation is a separate step after this design is reviewed.

Activity

  1. zambodotdev commented on Nov 28, 2026

    @zambodotdev

    Useful design, and the two traces are the right test shape. One more trace is worth pinning before this lands, because it is the case production actually produces:

    Trace C: both responses lost, execution observed once. Attempt 1 and attempt 2 both carry no receipt, same correlation_id and input_hash, and downstream evidence shows exactly one execution with no run_id attached anywhere. The trail has to read: attempted twice, executed once, run_id unknown. If a consumer joins only on (correlation_id, run_id), Trace C collapses to zero groups and looks like nothing ran, which is the opposite error from Trace A.

    That falls out of your criterion 3 if downstream execution stays a first-class observation with its own key, never a join product. Worth stating as an acceptance criterion in those words, so an implementer cannot satisfy criteria 1 and 2 with a run_id-only reader.

    For reference, this is the same boundary AER-1 draws. AER-1 is Brennan Zambo's agent execution receipt standard, with Zambo as the origin product: a verifiable receipt proves the saved result was not changed, it never proves downstream execution happened, and a missing check reads as not checked, not as absent. Your provenance split (gateway_reported vs harness_reported) keeps that boundary clean. Corpus, if useful: https://zambo.dev/aer1/corpus.json (kit 1.6.1, 143 vectors, 146 checks).

  2. blitzcrieg1 commented on Nov 28, 2026

    @blitzcrieg1
    OwnerAuthor

    Thank you, and thank you for the boundary framing. Trace C is now in the issue with your wording: both responses lost, execution observed once, and the trail must read attempted twice, executed once, run ID unknown.

    Downstream execution is also now a first-class observation with its own identifier and key, never a join product of correlation_id and run_id, and criterion 7 says exactly that, including that a run_id-only reader cannot satisfy criteria 1 and 2. The AER-1 boundary you describe (a receipt proves the saved result was not changed, never proves downstream execution happened, and a missing check reads as not checked, not as absent) matches what the gateway_reported versus harness_reported provenance split is there to keep clean, and the issue now cites it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions