{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-tool-call-span-when-its-parent-context-is-a-foreign-trace-continuation",
  "title": "Under what conditions must an instance refuse to emit a `gen_ai.*` tool-call span when its parent context is a foreign-trace continuation",
  "date_of_record": "2026 November 22",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.tool.call.id`) for tool invocations whose `traceparent` was inherited from an upstream agent, gateway, or peer over MCP/A2A. Does not apply to single-process agents that own their entire trace root.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-tool-call-span-when-its-parent-context-is-a-foreign-trace-continuation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-tool-call-span-when-its-parent-context-is-a-foreign-trace-continuation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-gen-ai-tool-call-span-when-its-parent-context-is-a-foreign-trace-continuation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1845,
    "python_slice_tokens": 276,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two incompatible definitions of \"the token count for a span,\" and the GenAI semantic conventions only formalize one of them. The **cumulative-usage** reading treats `gen_ai.usage.input_tokens` as the model's total prompt consumption for that completion — including the system prompt, the accumulated tool-result history, and the retrieved context — r...",
    "what_was_observed": "A two-hop pipeline: Agent A (orchestrator, trace root owner) calls Agent B over A2A with a propagated `traceparent`. B invokes a tool through MCP, gets a result, and replays the full accumulated context (system prompt ~1.8k tokens, prior turns ~4.2k tokens, tool result ~0.9k tokens) into a completion that emits the next tool call. B's SDK auto-instruments the `gen_ai.chat` span and the child `gen_ai.execute_tool` spa...",
    "condition_of_validity": "The cumulative-usage convention is valid **only** when the emitting instance is the trace root owner — i.e., the span's `trace_id` was minted by this process and the `parent_span_id` chain is entirely locally authored. In that case the replayed prefix is genuinely this trace's cost, and cumulative attribution is correct. The convention is **invalid** when an...",
    "decision_boundary": "The runtime must branch on trace ownership *before* the span is exported, not after. The check is cheap and deterministic: - Read the active `SpanContext`. If `IsRemote == true` (the OpenTelemetry SDK sets this when the context was extracted from a carrier rather than started locally), the span is a continuation. - Additionally compare `trace_id` against the...",
    "operational_effect": "When the boundary is respected, trace-level aggregation becomes sound: sum of attributable deltas across a trace equals the root owner's cumulative total, and the two are reconcilable by summing `replayed_prefix_tokens` against the root's `input_tokens`. Verifiers that check tool-call/result pairing see a consistent id graph because call ids are propagated, ..."
  },
  "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": "af3932ee667f21ba2fedae61533dd806e7cbeab80371643bd392be9b04201299",
    "verified_classes": [
      "ForeignTraceAccountingError",
      "AttributionMode",
      "SpanContext",
      "GenAIUsage"
    ],
    "verified_functions": [
      "resolve_attribution_mode",
      "build_usage_attributes"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ForeignTraceAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
