{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-token-accounting-with-the-actual-tool-call-span-tree-before-emitting-a-pare",
  "title": "Under what conditions must an instance reconcile GenAI semantic-convention token accounting with the actual tool-call span tree before emitting a parent span",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*` attributes) where a single logical agent invocation fans out into nested tool-call spans and the parent span reports aggregate token usage. Does not apply to flat, single-span LLM proxies that never create child tool spans, nor to runtimes that delegate all accounting to a billing backend outside the trace pipeline.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-token-accounting-with-the-actual-tool-call-span-tree-before-emitting-a-pare.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-token-accounting-with-the-actual-tool-call-span-tree-before-emitting-a-pare.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-token-accounting-with-the-actual-tool-call-span-tree-before-emitting-a-pare.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1981,
    "python_slice_tokens": 360,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *per-model-call* attributes, defined on the span that represents a single inference request. An agent parent span is not a model call. It is a scheduling and orchestration span that happens to contain many model calls as children. The convention does not defi...",
    "what_was_observed": "A planner-executor agent emitted the following tree for one user turn (attributes abbreviated): Three distinct discrepancies appeared in the same tree: 1. **Retry double-count.** The `search` sub-agent's inner chat was retried once after a malformed tool result. Both the failed attempt and the retry emitted full `gen_ai.usage.*`. The parent summed both into its 4820, inflating input tokens by 1450 that were never bil...",
    "condition_of_validity": "The conservation invariant `parent.usage == Σ(owned model-call children)` holds only when all of the following are true at parent-close time: - **Ownership is defined by `parent_span_id`, not by trace membership or wall-clock overlap.** A child that started under this parent but was reparented (orphaned speculative call) or a child that shares the trace but ...",
    "decision_boundary": "The runtime must decide, per parent span, between two mutually exclusive postures: - **Semantic posture:** the parent carries *no* `gen_ai.usage.*` attributes. Aggregate usage is derivable only by summing owned children at query time. This is convention-faithful and always reconcilable, at the cost of requiring the consumer to do tree aggregation. - **Billin...",
    "operational_effect": "A runtime that enforces the invariant gains a checkable property: every parent span's usage is reproducible from its own subtree by a single deterministic fold, and any drift is a detectable bug rather than a silent cost leak. The enforcement point is parent-close: the runtime must materialize the owned-child set by `parent_span_id`, fold usage with retry-co..."
  },
  "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": "e9627a73d424543a975f039290d31ea540b8851ab5e1cfbc783f1f3a4c0a4226",
    "verified_classes": [
      "UsageReconciliationError",
      "Span"
    ],
    "verified_functions": [
      "fold_owned_usage",
      "close_parent"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UsageReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
