{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tool-call-span-attribute-collapse-when-a-single-agent-span-fans-out-to-multiple-provider-llm-calls",
  "title": "Which invariants prevent tool-call span attribute collapse when a single agent span fans out to multiple provider LLM calls",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions where one logical agent step (a `gen_ai.agent`/`invoke_agent` span) issues multiple nested model calls and tool calls, some of which are retried, cached, or routed to fallback providers. Does not apply to single-shot inference spans with one model call and no tool fan-out.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-attribute-collapse-when-a-single-agent-span-fans-out-to-multiple-provider-llm-calls.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-attribute-collapse-when-a-single-agent-span-fans-out-to-multiple-provider-llm-calls.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-attribute-collapse-when-a-single-agent-span-fans-out-to-multiple-provider-llm-calls.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1711,
    "python_slice_tokens": 313,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define attributes like `gen_ai.request.model`, `gen_ai.response.model`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and `gen_ai.tool.name` at the *model-call span* level. The failure mode examined here is not \"attributes are missing\" but **attribute collapse**: when a parent agent span aggregates child model-call...",
    "what_was_observed": "A research agent performing a \"summarize and cite\" task made 6 model calls per user request: 1 planning call, 3 retrieval-augmented synthesis calls, 1 self-critique call, 1 final answer call. During a provider incident, calls 3 and 4 failed with 429 and were retried against a secondary provider (`claude-3-5-sonnet` instead of `gpt-4o`). The instrumentation emitted: - 6 child spans under one `invoke_agent` parent. - C...",
    "condition_of_validity": "The invariant \"per-attempt attributes may be aggregated onto the parent\" is valid only under all of: - **Cardinality one:** exactly one child model-call span per parent agent span, with no retries, no fallback, and no parallel tool fan-out. - **Homogeneous provenance:** all attempts share the same `gen_ai.request.model` and `gen_ai.response.model` (which als...",
    "decision_boundary": "The operational decision is whether to (a) keep the parent span as an aggregate and define a **separate, namespaced aggregate attribute schema** with explicit semantics, or (b) make the parent span carry *no* per-attempt attributes and force all consumers to traverse children. Choose (a) only if you also enforce these guardrails: - Aggregates use a distinct ...",
    "operational_effect": "With the guardrail in place, three things change: 1. Cost attribution must join on child spans, not parent spans, and the join key is `(trace_id, span_id)` of the leaf, with `gen_ai.request.model` taken from the leaf only. Parent-level cost is derived by summing children, and the sum is checkable against `agent.usage.input_tokens.total`. 2. Provenance querie..."
  },
  "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": "15eb4a866ca7150b740fed39fe91828ab1904890ee5bbc164febce29ff01ba43",
    "verified_classes": [
      "SpanAttributeCollapseError",
      "Span"
    ],
    "verified_functions": [
      "validate_parent_span",
      "build_parent_aggregate"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpanAttributeCollapseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
