{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-a-mutable-tool-call-contract-before-closing-a-parent-agent-span",
  "title": "Where must an instance reconcile OpenTelemetry GenAI span attributes against a mutable tool-call contract before closing a parent agent span?",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.response.finish_reasons`) for tool-call child spans and model-invocation metrics, and that close a parent `invoke_agent` span after a multi-turn tool loop. Does not apply to single-shot completions with no tool fan-out, nor to runtimes where spans are emitted only at process exit by an out-of-band collector.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-a-mutable-tool-call-contract-before-closing-a-parent-agent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-a-mutable-tool-call-contract-before-closing-a-parent-agent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-attributes-against-a-mutable-tool-call-contract-before-closing-a-parent-agent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1514,
    "python_slice_tokens": 349,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing telemetry.\" It is **attribute/contract skew at span-close time**: the tool-call child span was stamped with the *declared* schema of the tool (name, parameter set, unit semantics) at invocation, but the tool's *effective* schema — discovered mid-call via a schema-negotiation response, a retry with a narrowed argument set, or a fal...",
    "what_was_observed": "A retrieval-augmented agent loop invoked `search_documents` with an initial schema declaring `top_k: int` and returning `chunks[]`. On the third tool turn, the MCP server responded with a schema-negotiation error (`-32602 invalid params`) and the runtime retried with `top_k` coerced to a string and a new `filter` object added — an effective schema the child span did not record, because the child span's `gen_ai.tool.n...",
    "condition_of_validity": "The invariant holds only if, at the moment the parent `invoke_agent` span is closed, the runtime can assert: 1. Every child tool span carries a `gen_ai.tool.call.id` that is globally unique across concurrent instances (UUIDv7 or instance-scoped monotonic counter — not a content hash). 2. Every retry of the same logical tool call is either (a) recorded as a d...",
    "decision_boundary": "The runtime must decide, **before emitting the parent span's closing event**, whether the loop's tool calls are *contract-stable* or *contract-drifted*. The boundary: - **Contract-stable:** all child spans share one effective schema version and one call-ID namespace; close normally with summed usage. - **Contract-drifted:** any child span's effective schema ...",
    "operational_effect": "Withholding summed usage on drifted parents moves the error from *silent mis-attribution* to *explicit exclusion*. Downstream per-tool cost dashboards lose coverage on drifted loops (typically 3–8% of multi-tool agent runs) but stop reporting bimodal distributions that mislead capacity planning. The `gen_ai.tool.schema_drift` event span gives the platform te..."
  },
  "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": "9421c9e08cc2f181ce8fc864589e2c4de90b172d1c3728ab83e1b609883ab367",
    "verified_classes": [
      "TelemetryContractDriftError",
      "ToolCallSpan",
      "ParentAgentSpan"
    ],
    "verified_functions": [
      "register_child",
      "close_parent_span",
      "emit_usage",
      "uuid7"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TelemetryContractDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing",
      "uuid"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
