{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-a-tool-call-span-before-the-tool-schema-is-finalized-attribute-set-divergence-at-the-gen-ai-tool-call-boundary",
  "title": "What happens when an instance emits a tool-call span before the tool schema is finalized: attribute-set divergence at the `gen_ai.tool.call` boundary",
  "date_of_record": "2026 November 26",
  "scope": "Applies to any agent runtime that emits OpenTelemetry `gen_ai.*` spans for tool invocations where the tool's input/output schema is resolved lazily (dynamic MCP `tools/list` negotiation, deferred JSON-schema binding, or runtime-discovered function signatures). Does not apply to statically-compiled tool registries where the schema is fixed before the first token is generated.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-tool-call-span-before-the-tool-schema-is-finalized-attribute-set-divergence-at-the-gen-ai-tool-call-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-tool-call-span-before-the-tool-schema-is-finalized-attribute-set-divergence-at-the-gen-ai-tool-call-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-tool-call-span-before-the-tool-schema-is-finalized-attribute-set-divergence-at-the-gen-ai-tool-call-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1973,
    "python_slice_tokens": 427,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The OpenTelemetry GenAI semantic conventions define `gen_ai.tool.call.id`, `gen_ai.tool.name`, and `gen_ai.tool.call.arguments` / `gen_ai.tool.call.result` as the canonical attribute set for tool-call spans. The distinction that matters operationally is between **span-time attribute capture** (attributes written at span start/end, immutable after `end()`) an...",
    "what_was_observed": "A ReAct-style agent using a dynamic MCP client emitted `gen_ai.tool.call` spans with the following trace fragment (abridged JSON, exporter view): The model had emitted a tool call for `lookup` at +0ms. The runtime opened the span immediately to capture wall-clock latency and wrote `arguments` from the partial streamed JSON. At +180ms the MCP `tools/list` response arrived and revealed that `lookup` required a `namespa...",
    "condition_of_validity": "The invariant that holds in the healthy case is: > For every `gen_ai.tool.call` span, `gen_ai.tool.name` and `gen_ai.tool.call.arguments` MUST be resolved against the tool schema version that was authoritative at the time the tool *executed*, not at the time the span *started*. This invariant is violated precisely when the runtime opens the span before schem...",
    "decision_boundary": "The runtime must choose, at the moment the model emits a tool call, between two span-lifecycle policies: 1. **Deferred-open:** buffer the tool-call intent, resolve schema, then open the span with the authoritative attribute set. Preserves the invariant. Loses sub-resolution latency visibility. 2. **Optimistic-open with reconciliation:** open the span immedia...",
    "operational_effect": "The concrete operational consequences observed: - **Cost attribution drift.** Per-tool token accounting inflates by the retry multiplier. In the observed run, `lookup` accrued cost for a call that never executed under that name. Over a 24h window with a 6% retry rate on dynamic-schema tools, per-tool cost dashboards over-reported by 6% on the phantom tool an..."
  },
  "matched_failure_symptoms": [
    "SCHEMA_DRIFT_OR_COERCION_CRASH"
  ],
  "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": "b9ff7b5d7cc34e32b71f338bf004751f96a669568a5935b712453e784bef2119",
    "verified_classes": [
      "SchemaDivergenceError",
      "ToolCallSpan"
    ],
    "verified_functions": [
      "emit_tool_call_span",
      "write_canonical_arguments",
      "write_provisional",
      "resolve_schema",
      "end"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "SchemaDivergenceError"
    ],
    "sample_fail_closed_invariants": [
      "tool schema authority unresolved at span close; defer span end or mark gen_ai.tool.schema.status='unresolved'",
      "cannot write canonical gen_ai.tool.call.arguments after span end(); attribute is frozen at export time",
      "refusing to write provisional arguments over a resolved schema",
      "schema resolved after span end(); must emit a linked error span instead"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
