{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-genai-span-parent-span-attribute-inheritance-across-a-mid-trace-model-swap",
  "title": "When must an instance refuse to emit a GenAI span: parent-span attribute inheritance across a mid-trace model swap",
  "date_of_record": "2026 November 19",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*`) and that can change the model, provider, or tool schema *within* a single trace or a single logical agent turn. Does not apply to single-model, single-turn request/response instrumentation where one span maps to one immutable completion.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-parent-span-attribute-inheritance-across-a-mid-trace-model-swap.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-parent-span-attribute-inheritance-across-a-mid-trace-model-swap.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-span-parent-span-attribute-inheritance-across-a-mid-trace-model-swap.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2008,
    "python_slice_tokens": 286,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as a *record of a single inference or tool invocation*, but agent runtimes treat a trace as a *continuity object*: a unit of work that may span a model swap, a fallback, a retry against a different provider, or a tool-call whose schema is renegotiated mid-flight. The failure lives in the gap between these two model...",
    "what_was_observed": "An agent orchestration layer ran a single logical turn as one parent span (`agent.turn`) with child spans for each inference call. The parent span was created once and stamped with `gen_ai.request.model = \"model-a\"` and `gen_ai.provider.name = \"provider-a\"` at turn start. The runtime supported mid-turn fallback: if the primary provider returned a 429 or a schema-invalid tool call, the next inference call was routed t...",
    "condition_of_validity": "The parent-span-as-continuity-object pattern is only valid under a strict condition: **the model identity is invariant across the entire span's lifetime.** Concretely, a span may carry `gen_ai.request.model`, `gen_ai.provider.name`, and aggregate `gen_ai.usage.*` together only if: 1. Every token counted in `gen_ai.usage.*` on that span was produced by the mo...",
    "decision_boundary": "The runtime must make a decision at the moment of fallback, before the second inference call is emitted: - **If the fallback model equals the original model** (same provider, same model string, retry only): the parent span may retain model identity and aggregate usage. No fragmentation needed. - **If the fallback model differs** in `gen_ai.request.model`, `g...",
    "operational_effect": "When the invariant is enforced, three downstream properties hold that otherwise fail silently: - **Cost attribution is exact.** Reading the parent span for aggregate cost is safe only if the parent names one model. When it does not, aggregation layers must be forced to sum children, and the runtime must not present a misleading parent aggregate. - **Replay i..."
  },
  "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": "083e40fb600037b204a0003937460dee5c6042ac7976e3e947897850ac6be18c",
    "verified_classes": [
      "GenAISpanContinuityError",
      "SpanRecord"
    ],
    "verified_functions": [
      "assert_model_identity_invariant",
      "emit_turn_span",
      "model_identity",
      "response_model",
      "output_tokens",
      "descendants"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "GenAISpanContinuityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
