{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-double-counts-replayed-tool-calls-in-token-accounting-and-silently-inflates-latency-slos",
  "title": "What happens when an instance double-counts replayed tool calls in token accounting and silently inflates latency SLOs",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agent runtimes that emit per-span token and tool-latency telemetry, where tool invocations may be retried, replayed from a checkpoint, or re-executed after a partial failure, and where those spans are aggregated into SLO dashboards. Does not apply to single-shot, non-retried inference calls with no checkpoint/resume semantics.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-double-counts-replayed-tool-calls-in-token-accounting-and-silently-inflates-latency-slos.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-double-counts-replayed-tool-calls-in-token-accounting-and-silently-inflates-latency-slos.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-double-counts-replayed-tool-calls-in-token-accounting-and-silently-inflates-latency-slos.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2079,
    "python_slice_tokens": 371,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two fundamentally different things an observability pipeline can count when it sees a tool span: the *logical operation* (one intended tool call in the agent's plan) and the *physical attempt* (one actual execution, which may be the 1st, 2nd, or 3rd try after a timeout or a checkpoint replay). Token accounting and latency SLOs are conventionally de...",
    "what_was_observed": "An agent executing a 14-step plan with a checkpoint every 3 steps hit a context-window saturation event at step 9. The runtime's resume logic reloaded the last checkpoint (end of step 6) and re-executed steps 7, 8, and 9. Steps 7 and 8 each called a `search_documents` tool. The tool is idempotent in effect but not in emission: each invocation returned a full result set and logged `prompt_tokens=1840, completion_token...",
    "condition_of_validity": "The invariant that must hold for SLOs to be meaningful is: > For any logical operation `op`, the aggregated `token_total(op) = sum over distinct physical attempts that produced billable tokens` and `latency(op) = wall_clock from first attempt start to last attempt end`, and `attempt_count(op)` is recorded separately. This invariant is *valid* only when the e...",
    "decision_boundary": "The decision an operator must make is: **do you reconcile at emit time or at aggregation time?** - **Emit-time reconciliation** requires the checkpoint to carry span context and the tool layer to accept an injected `logical_op_id`. This is correct but invasive: every checkpoint serializer and every tool wrapper must cooperate. It is the only option if you ne...",
    "operational_effect": "The practical consequence is that token dashboards and latency SLOs drift in *opposite directions* under replay pressure, and the drift is invisible because both metrics look plausible in isolation. Token totals creep up during any period of high checkpoint activity (long tasks, context saturation, aggressive checkpointing), which operators misread as \"the m..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "0470214b576003b0f1ed7b827ed01be92923c591cd78c75cd4aa15eeb28144c4",
    "verified_classes": [
      "ReplayAccountingError",
      "ToolAttempt",
      "LogicalOp"
    ],
    "verified_functions": [
      "reconcile_resumed_op",
      "add_attempt",
      "token_total",
      "user_perceived_latency_ms",
      "attempt_count"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ReplayAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
