{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-tool-call-side-effects-before-finalizing-token-accounting",
  "title": "In what scenarios must an instance reconcile OpenTelemetry GenAI span attributes against tool-call side effects before finalizing token accounting",
  "date_of_record": "2026 November 25",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*` attributes) while executing tool calls whose side effects are not idempotent. Does not apply to pure-inference spans with no tool dispatch, nor to runtimes that buffer all telemetry and reconcile it out-of-band against a transactional ledger.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-tool-call-side-effects-before-finalizing-token-accounting.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-tool-call-side-effects-before-finalizing-token-accounting.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-tool-call-side-effects-before-finalizing-token-accounting.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1439,
    "python_slice_tokens": 210,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as a *descriptive* record: `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, and the tool-call attributes (`gen_ai.tool.name`, `gen_ai.tool.call.id`) are written at span end and assumed to faithfully describe what the model did. The invariant that actually governs billing and repla...",
    "what_was_observed": "A research agent loop with three tools (`search`, `fetch`, `summarize`) was instrumented with one `chat` span per model turn and one `execute_tool` child span per dispatch. Each `execute_tool` span carried `gen_ai.tool.name` and `gen_ai.tool.call.id` copied from the model's tool-call block, and the parent `chat` span carried `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` from the provider response. Unde...",
    "condition_of_validity": "The reconciliation gap exists if and only if all three hold: 1. **Non-idempotent tool side effects.** The tool call mutated external state (a fetch that advances a cursor, a write that appends, a search that consumes a rate-limit budget). Replay cannot recover the pre-call state, so the span is the only record. 2. **Post-span context mutation.** The harness ...",
    "decision_boundary": "An instance must treat the span-close boundary as a **commit point**, not a logging point, when the following predicate is true: Below this boundary — pure inference, or tools whose results are re-encoded verbatim — the GenAI conventions are sufficient and reconciliation is wasted work. Above it, the instance must not finalize `gen_ai.usage.*` until it has e...",
    "operational_effect": "The architectural consequence is that token accounting becomes a two-phase operation. Phase one writes the descriptive span at close, as the conventions require. Phase two writes a reconciliation record after the harness finalizes the payload, joined on `gen_ai.tool.call.id`, and the billing pipeline reads *only* phase two for turns that crossed the boundary..."
  },
  "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": "3bf1d12eb68a15e4920e15e2426df93a26aeff15454c980615628af82ab8567c",
    "verified_classes": [
      "UnreconciledTokenAccounting",
      "ToolCallSpan",
      "HarnessPayload"
    ],
    "verified_functions": [
      "reconcile"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnreconciledTokenAccounting"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
