{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-reject-genai-agent-spans-whose-tool-call-attributes-and-token-counters-are-internally-consistent-but-semantical",
  "title": "Under what conditions must an instance reject GenAI agent spans whose tool-call attributes and token counters are internally consistent but semantically misattributed",
  "date_of_record": "2026 November 12",
  "scope": "Applies to OpenTelemetry instrumentation and collector-side validation for GenAI agent spans (`gen_ai.operation.name` in `invoke_agent`, `execute_tool`, `chat`) where token usage is reported per span and tool calls are represented as child spans or span events. Does not apply to pure LLM client spans with no tool-call fan-out, nor to spans emitted by frameworks that aggregate all usage at a single root span without per-step attribution.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-genai-agent-spans-whose-tool-call-attributes-and-token-counters-are-internally-consistent-but-semantical.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-genai-agent-spans-whose-tool-call-attributes-and-token-counters-are-internally-consistent-but-semantical.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reject-genai-agent-spans-whose-tool-call-attributes-and-token-counters-are-internally-consistent-but-semantical.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1566,
    "python_slice_tokens": 360,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **arithmetic consistency** and **attributional correctness**. A GenAI agent trace can be perfectly consistent — every `gen_ai.usage.input_tokens` plus `gen_ai.usage.output_tokens` sums to the parent's total, every `gen_ai.tool.name` matches a declared tool, every `gen_ai.tool.call.id` is unique — and still be wrong, be...",
    "what_was_observed": "In a multi-step agent running a ReAct-style loop (reason → tool_call → observe → reason), instrumentation emitted: - A parent `invoke_agent` span carrying aggregate usage. - One `chat` span per reasoning step, each carrying `gen_ai.usage.*`. - One `execute_tool` span per tool invocation, carrying `gen_ai.tool.name`, `gen_ai.tool.call.id`, and `gen_ai.tool.call.arguments`. The invariant violation: when the agent **ret...",
    "condition_of_validity": "The rejection rule is valid **only when all of the following hold**: 1. The span tree declares per-step usage (i.e., child `chat`/`execute_tool` spans carry `gen_ai.usage.*`), so that a parent aggregate is expected to be the sum of children. 2. Tool calls are represented as first-class spans or events with stable `gen_ai.tool.call.id`, allowing retry detecti...",
    "decision_boundary": "Reject the span (or the trace) when **either**: - **Retry-attribution breach:** a `chat` span's `gen_ai.usage.input_tokens` exceeds the sum of tokens attributable to its immediately preceding `execute_tool` outputs plus its own prompt, *and* the trace contains a prior `execute_tool` with the same `gen_ai.tool.name` but a different `gen_ai.tool.call.id` whose...",
    "operational_effect": "Enforcing this boundary at the collector changes agent observability in three ways. First, retry storms become visible: a trace flagged for retry-attribution breach tells the operator that a tool is failing and being silently retried with growing context cost, which is otherwise invisible because the trace \"looks fine.\" Second, per-tool cost dashboards stop ..."
  },
  "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": "09b155e00556de884f452d14fd5c988f61c04be96a777e02c53dbd94bbf63f31",
    "verified_classes": [
      "GenAIAttributionError"
    ],
    "verified_functions": [
      "validate_agent_trace"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "GenAIAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
