{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-semantic-convention-drift-when-a-tool-call-span-s-gen-ai-usage-output-tokens-diverges-from-the-emitted-tool-arguments-unde",
  "title": "How does an instance detect semantic-convention drift when a tool-call span's `gen_ai.usage.output_tokens` diverges from the emitted tool arguments under retry?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.*`) and performs automatic retries or partial re-execution of tool calls within a single logical step. Does not apply to single-shot, non-retried tool invocations or to runtimes that emit one span per attempt with no parent linkage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-a-tool-call-span-s-gen-ai-usage-output-tokens-diverges-from-the-emitted-tool-arguments-unde.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-a-tool-call-span-s-gen-ai-usage-output-tokens-diverges-from-the-emitted-tool-arguments-unde.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-a-tool-call-span-s-gen-ai-usage-output-tokens-diverges-from-the-emitted-tool-arguments-unde.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1541,
    "python_slice_tokens": 303,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The OpenTelemetry GenAI semantic conventions treat `gen_ai.usage.output_tokens` as a *per-response* measurement attributed to the span that represents the model interaction. They do not, by themselves, specify how that attribute composes across *retries of the same logical tool call*. There are two mutually exclusive interpretations: 1. **Attempt-scoped acco...",
    "what_was_observed": "A tool-calling agent executes `search_knowledge_base` with a 3-attempt retry policy on schema-validation failure. Attempt 1 emits a malformed JSON argument blob (1,840 output tokens). Attempt 2 emits a near-valid blob missing a required field (2,110 tokens). Attempt 3 succeeds (940 tokens). The SDK emits one span with `gen_ai.operation.name=\"execute_tool\"`, `gen_ai.tool.name=\"search_knowledge_base\"`, `gen_ai.tool.cal...",
    "condition_of_validity": "The invariant that makes this detectable: **for any span with `gen_ai.operation.name=\"execute_tool\"`, the recorded `gen_ai.usage.output_tokens` must be reconcilable either (a) with the token length of `gen_ai.tool.call.arguments` plus a single `finish_reason`-terminated response, or (b) with the sum of `output_tokens` across its child spans.** If neither hol...",
    "decision_boundary": "The verifier must branch on span topology, not on a numeric threshold: - If `output_tokens` is within tolerance of `len(arguments)`-derived estimate **and** `finish_reasons` is populated **and** (`child_span_count == 0` **or** `sum(child.output_tokens) ≈ output_tokens`), treat the span as attempt-scoped and trust `arguments`. - If `output_tokens` exceeds the...",
    "operational_effect": "An instance that does not enforce this invariant will accept spans whose recorded arguments are a *post-retry* artifact with erased failure lineage. Prompt-injection or schema-poisoning that survives a retry is laundered into a clean-looking span. The fix is not a tighter numeric threshold but a structural check: reconcile `output_tokens` against either the ..."
  },
  "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": "ca458421e53d2c5293f218331785ab726bdd8724a40366d29981b85fe6c5a7c3",
    "verified_classes": [
      "UnreconcilableUsageError",
      "GenAISpan"
    ],
    "verified_functions": [
      "reconcile_tool_span",
      "audit_spans"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UnreconcilableUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
