{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-gen-ai-tool-call-id-lineage-when-token-attribution-crosses-a-compaction-boundary",
  "title": "Under what conditions must an instance refuse to emit `gen_ai.tool.call.id` lineage when token attribution crosses a compaction boundary",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) where a single logical tool-call lineage spans a context-compaction or checkpoint/resume event and per-token cost must be attributed back to the originating `gen_ai.tool.call.id`. Does not apply to single-turn, single-span invocations where the tool call and its completion share one span envelope.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-gen-ai-tool-call-id-lineage-when-token-attribution-crosses-a-compaction-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-gen-ai-tool-call-id-lineage-when-token-attribution-crosses-a-compaction-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-gen-ai-tool-call-id-lineage-when-token-attribution-crosses-a-compaction-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1490,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` and `gen_ai.tool.call.id` as sibling attributes on a span. Cost attribution tooling downstream assumes this sibling relationship is *stable across the span's lifetime*: the `tool.call.id` on the span that carries the usage counters is presumed to be the same `tool...",
    "what_was_observed": "Trace from a 14-step research agent, single OTel trace, `gen_ai.client.invoke_agent` root span. At step 9 the context hit 92% of the model's window; the orchestrator triggered summarization. The summarization itself was a separate `gen_ai.chat` span with correct usage counters. But the *next* invocation — step 10, a `gen_ai.tool.call` span for `web_search` — carried `gen_ai.usage.input_tokens = 18,442`, of which roug...",
    "condition_of_validity": "A span may legitimately emit `gen_ai.tool.call.id` alongside usage counters **iff** every input token counted on that span was contributed by the prompt assembled for that specific call. This holds when: 1. The span's prompt was assembled from the live context window with no summarized or replayed prefix, **or** 2. The span explicitly partitions usage via a ...",
    "decision_boundary": "The boundary is a single boolean the emitter must evaluate *before* setting `gen_ai.tool.call.id`: - **Clean span** (no replayed prefix): emit `gen_ai.tool.call.id` and full `gen_ai.usage.*`. Cost attribution is sound. - **Contaminated span** (replayed prefix present): either (a) omit `gen_ai.tool.call.id` and emit only aggregate usage with a `genai.lineage....",
    "operational_effect": "When the boundary is respected, per-tool-call cost is reconcilable: summing `gen_ai.usage.input_tokens` over spans grouped by `gen_ai.tool.call.id` equals the trace-level total minus explicitly-marked replayed tokens. When violated, cost dashboards drift upward monotonically with compaction frequency — a long-running agent that compacts every N steps will sh..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "e7904d0a47c98bb09bdd4000cf4316290eee7d5e925aa305f3c3ae1d50edab37",
    "verified_classes": [
      "LineageAttributionError"
    ],
    "verified_functions": [
      "emit_tool_call_span",
      "reconcile_trace_cost"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "LineageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
