{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-tool-call-spans-with-attributes-that-satisfy-the-otel-genai-semantic-conventions-individually-but-violate-span-tre",
  "title": "What happens when an instance emits tool-call spans with attributes that satisfy the OTel GenAI semantic conventions individually but violate span-tree cardinality invariants across a retry chain",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) for tool invocations and that retry, replay, or re-enter tool calls within a single logical agent turn. Does not apply to single-shot inference spans with no tool loop, nor to backends that aggregate cost purely from billing exports rather than span attributes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-tool-call-spans-with-attributes-that-satisfy-the-otel-genai-semantic-conventions-individually-but-violate-span-tre.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-tool-call-spans-with-attributes-that-satisfy-the-otel-genai-semantic-conventions-individually-but-violate-span-tre.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-tool-call-spans-with-attributes-that-satisfy-the-otel-genai-semantic-conventions-individually-but-violate-span-tre.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1595,
    "python_slice_tokens": 295,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define *per-span* attribute contracts: a span with `gen_ai.operation.name = \"execute_tool\"` should carry `gen_ai.tool.name`, `gen_ai.tool.call.id`, and token/cost attributes where applicable. They do **not** define a *tree-level* invariant over how many such spans may exist per logical agent turn, nor how token attributes compo...",
    "what_was_observed": "An agent executing a `search_documents` tool hit a transient 503 on the first attempt, retried with identical arguments, and succeeded on the second. The runtime emitted: - Span A: `execute_tool`, `gen_ai.tool.name=search_documents`, `gen_ai.tool.call.id=call_7f3a`, `gen_ai.usage.input_tokens=1840`, `gen_ai.usage.output_tokens=0`, status `ERROR`, exception event `503`. - Span B: `execute_tool`, `gen_ai.tool.name=sear...",
    "condition_of_validity": "The boundary is only reachable when all of the following hold: 1. The agent runtime performs in-turn retries (or replay/hedged execution) of tool calls rather than surfacing the failure to the model as a tool result. 2. Token usage is attributed at the `execute_tool` span level rather than exclusively at the parent `invoke_agent` / `chat` span. When usage li...",
    "decision_boundary": "The guardrail is a **retry-discriminating attribute plus an aggregation contract**, not a schema change. Concretely: - Emit `gen_ai.tool.call.id` as the *logical* call identity (stable across retries) and add a non-standard-but-namespaced `agent.retry.attempt` integer (0-indexed) on each attempt span. The logical ID preserves call identity; the attempt ordin...",
    "operational_effect": "Without the guardrail, three coupled failures propagate: cost dashboards over-report tool tokens by the retry factor (silent budget drift), success-rate SLOs under-report reliability (false alerting on flaky-but-recovering tools), and any agent that reads its own telemetry to self-tune retry aggressiveness enters a feedback loop — it sees inflated failure ra..."
  },
  "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": "b98bd53084ff07f0ea033559ebe395a0eb5469db171e6d3ff53bd285f41f826e",
    "verified_classes": [
      "ToolSpanCardinalityError",
      "ToolSpan"
    ],
    "verified_functions": [
      "aggregate_turn"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ToolSpanCardinalityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
