{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-that-opentelemetry-genai-span-attributes-have-silently-desynchronized-from-the-agent-s-actual-tool-call-and-token-sta",
  "title": "What structural signals indicate that OpenTelemetry GenAI span attributes have silently desynchronized from the agent's actual tool-call and token state",
  "date_of_record": "2026 November 22",
  "scope": "Applies to agents whose execution is instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes) on spans that wrap LLM invocations and tool calls, where span attributes are emitted at span *end* from a mutable in-process accumulator rather than captured at the moment of the event. Does not cover pure logging pipelines, nor spans emitted from immutable event streams (e.g., a message queue drained by a separate collector).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-that-opentelemetry-genai-span-attributes-have-silently-desynchronized-from-the-agent-s-actual-tool-call-and-token-sta.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-that-opentelemetry-genai-span-attributes-have-silently-desynchronized-from-the-agent-s-actual-tool-call-and-token-sta.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-that-opentelemetry-genai-span-attributes-have-silently-desynchronized-from-the-agent-s-actual-tool-call-and-token-sta.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1900,
    "python_slice_tokens": 268,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"telemetry is missing.\" It is **telemetry that is present, well-formed, schema-valid, and wrong** — specifically, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and per-tool-call attributes that were accumulated into a shared mutable context and flushed at span close, after the agent had already mutated that context through ret...",
    "what_was_observed": "A tool-calling agent loop, instrumented with a single mutable `SpanContext` dict per turn: On each model response, the handler did `turn_ctx[\"output_tokens\"] += resp.usage.completion_tokens` and appended to `turn_ctx[\"tool_calls\"]`. When a tool call returned a transient error (HTTP 503 from the tool backend), the agent's retry policy re-invoked the model with the *same* logical step. The retry path re-entered the acc...",
    "condition_of_validity": "The guardrail holds only under these conditions, and fails outside them: - **The accumulator must be append-only with attempt-scoped keys.** Retries must mint a new `attempt_id` and either (a) emit a child span per attempt, or (b) tag the attribute with `gen_ai.request.attempt` so double-counting is *visible* rather than *silent*. If retries overwrite rather...",
    "decision_boundary": "The decision boundary is: **do you trust `gen_ai.*` attributes as event-truth, or as span-truth?** - If attributes are **event-truth** (captured at the event, immutable after), you may use them for cost attribution, retry-rate analysis, and per-call token profiling directly. - If attributes are **span-truth** (flushed at span close from a mutable context), t...",
    "operational_effect": "The downstream effects compound because the corrupted telemetry is *plausible*: - **Cost attribution drifts multiplicatively** on exactly the retry-prone paths — the paths you most want to measure. The bias is concentrated where reliability is worst, so cost dashboards understate the cost of unreliable tools precisely when reliability is degrading. - **Retry..."
  },
  "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": "6995dae904ecf09a79089d7c25b00cb42d6e58f655de405b3b2c896379029d20",
    "verified_classes": [
      "TelemetryDesyncError"
    ],
    "verified_functions": [
      "validate_agent_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TelemetryDesyncError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
