{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-of-an-agent-span-become-semantically-invalid-when-a-tool-call-attribute-is-recorded-before-the-model-invocation-event-that-produc",
  "title": "Why does an instance of an agent span become semantically invalid when a tool-call attribute is recorded before the model invocation event that produced it",
  "date_of_record": "2026 November 17",
  "scope": "Applies to OpenTelemetry-instrumented AI agents that emit `gen_ai.*` spans and events under the GenAI semantic conventions (agent spans, tool-call spans, and model invocation events). Does not apply to plain LLM inference spans without tool use, nor to custom non-OTel telemetry schemas.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-of-an-agent-span-become-semantically-invalid-when-a-tool-call-attribute-is-recorded-before-the-model-invocation-event-that-produc.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-an-agent-span-become-semantically-invalid-when-a-tool-call-attribute-is-recorded-before-the-model-invocation-event-that-produc.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-an-agent-span-become-semantically-invalid-when-a-tool-call-attribute-is-recorded-before-the-model-invocation-event-that-produc.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1094,
    "python_slice_tokens": 155,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a model invocation and a tool call as two distinct telemetry artifacts with different causality contracts. A model invocation is represented as an **event** (or child span) that records the model's proposal — including the `gen_ai.tool.call.id` and the tool name it wants to invoke — while the tool call itself is a **span*...",
    "what_was_observed": "In a LangChain-style agent loop instrumented with an OTel GenAI exporter, tool-call spans consistently appeared with `start_time` earlier than the `gen_ai.tool.call.id`-bearing model invocation event, and with parent span IDs pointing at the agent span rather than the invocation event's span. Downstream trace processors that reconstruct \"model proposed → tool executed\" chains dropped these tool spans as unattributabl...",
    "condition_of_validity": "The invariant holds only when the following are simultaneously true: 1. The invocation event carrying `gen_ai.tool.call.id` is emitted with a timestamp **at or before** the tool-call span's start. 2. The tool-call span's `gen_ai.tool.call.id` attribute is byte-identical to the ID on the invocation event (no re-generation, no per-span UUID substitution). 3. T...",
    "decision_boundary": "When you cannot guarantee ordering — e.g., streaming agents where tool execution begins before the model's final event flushes — you must choose between **buffering** the tool span until the invocation event is emitted (preserving causality, adding latency to export) or **emitting immediately and patching the reference later** (which most backends do not sup...",
    "operational_effect": "Orphaned tool spans degrade agent observability in a silent, non-alerting way: tool latency and error rates appear in isolation, model-turn attribution disappears, and cost-per-tool-call reconstruction fails. The failure is invisible to schema validators and to span-count dashboards. It surfaces only when a human or an automated auditor tries to answer \"whic..."
  },
  "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": "e06ed6fef2e72b2facfde403c384fdb72737fe86e27aa71a8c2a53d09451f912",
    "verified_classes": [
      "ToolCallCausalityError",
      "InvocationEvent",
      "ToolCallSpan"
    ],
    "verified_functions": [
      "assert_tool_call_causality"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ToolCallCausalityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
