{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tool-call-span-corruption-when-genai-semantic-conventions-are-shared-across-agent-and-model-layers",
  "title": "Which invariants prevent tool-call span corruption when GenAI semantic conventions are shared across agent and model layers",
  "date_of_record": "2026 November 12",
  "scope": "Applies to any OpenTelemetry instrumentation emitting `gen_ai.*` attributes across an agent span and its child model-invocation and tool-call spans. Does not apply to pure model-client instrumentation that never spawns tool spans, nor to legacy `ai.*` conventions.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-corruption-when-genai-semantic-conventions-are-shared-across-agent-and-model-layers.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-corruption-when-genai-semantic-conventions-are-shared-across-agent-and-model-layers.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-corruption-when-genai-semantic-conventions-are-shared-across-agent-and-model-layers.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1387,
    "python_slice_tokens": 288,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *attributes* (e.g., `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.request.model`) but they deliberately do **not** specify a cardinality or identity contract for the *span hierarchy* that carries them. A model invocation span and a tool-call span are both \"GenAI spans,\" and both may ...",
    "what_was_observed": "During an agent turn that invoked the model twice and executed one tool between invocations, the following was observed in an OTLP export: - The parent agent span carried `gen_ai.operation.name = \"chat\"` (inherited from a default set by the model-client instrumentor), even though the agent layer is not a chat operation. - `gen_ai.usage.input_tokens` appeared on *both* the agent span and each child model-invocation sp...",
    "condition_of_validity": "The invariants below hold only when all of the following are true: 1. Attribute propagation from parent to child is **opt-in per attribute**, not a wholesale context copy. If the instrumentation copies the entire `gen_ai.*` bag into child spans, invariant 2 (below) cannot be enforced. 2. The agent layer and the model-client layer are instrumented by *differe...",
    "decision_boundary": "The operational decision is: **when an attribute is present on a span, does its presence assert that the span's own operation produced that value, or does it merely describe the enclosing context?** The conventions do not answer this. The safe rule is to treat *every* `gen_ai.usage.*` and `gen_ai.request.model` attribute as **locally asserted** (the span's o...",
    "operational_effect": "Without these invariants, three concrete failures occur downstream: (a) token accounting double-counts because usage attributes appear at two levels of the hierarchy; (b) cost attribution is wrong because tool spans are billed as model invocations by naive model-keyed queries; (c) retry and loop detection breaks because `gen_ai.tool.name` persists across a m..."
  },
  "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": "6db780cd9557c884e7b14da86af4928b1820cb65bfc305fbfbf04bc3e16f9c3f",
    "verified_classes": [
      "GenAIAttributeLeakError"
    ],
    "verified_functions": [
      "validate_span_attributes"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAIAttributeLeakError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
