{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-genai-span-attributes-for-a-tool-call-whose-response-is-truncated-by-the-model-s-own-token-budget-the-gen-ai-compl",
  "title": "What happens when an instance emits GenAI span attributes for a tool call whose response is truncated by the model's own token budget: the `gen_ai.completion.0.finish_reason` / `tool_calls` divergence and its effect on multi-turn replay",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent runtime instrumented with OpenTelemetry GenAI semantic conventions (v1.27+) where a single logical tool call is traced as one span and the model may terminate generation with `finish_reason = \"length\"` mid-`tool_calls`. Does not apply to streaming-only spans that emit per-chunk events without a terminal `finish_reason`, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-for-a-tool-call-whose-response-is-truncated-by-the-model-s-own-token-budget-the-gen-ai-compl.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-for-a-tool-call-whose-response-is-truncated-by-the-model-s-own-token-budget-the-gen-ai-compl.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-for-a-tool-call-whose-response-is-truncated-by-the-model-s-own-token-budget-the-gen-ai-compl.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1864,
    "python_slice_tokens": 279,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a model invocation as a span with `gen_ai.operation.name = \"chat\"` and a `gen_ai.completion.N` indexed set of choices. Each choice carries `finish_reason` and, when the model emits a tool call, `message.tool_calls` (or the newer `gen_ai.tool.call.id` / `gen_ai.tool.name` / `gen_ai.tool.call.arguments` attributes on a chil...",
    "what_was_observed": "Trace from a multi-turn agent (turn 7 of a 12-turn task), model `claude-sonnet`, single `chat` span: The `arguments` string is 4096-token-truncated mid-string-literal. It is not valid JSON. The agent runtime's parser raised `json.JSONDecodeError`, the runtime treated the turn as a hard failure, and — critically — the *span was already exported* as a successful `chat` operation with a `tool_calls` child. The runtime's...",
    "condition_of_validity": "The convention's implied invariant holds only under three conditions, none of which the OTel GenAI spec enforces: 1. **Terminal-state monotonicity.** `finish_reason` must be set exactly once per choice, at the terminal event, and must be the *last* attribute written. In streaming implementations the finish reason often arrives in a separate SSE frame *after*...",
    "decision_boundary": "The boundary is between two trace-consumer classes: - **Replay consumers** (distillation, eval-set construction, SFT data extraction): must treat `finish_reason = \"length\"` as a *negative* discriminator for `tool_calls` validity regardless of presence. A `tool_calls` entry under `length` is *evidence of truncation*, not evidence of a call. - **Audit consumer...",
    "operational_effect": "The operational effect is *silent partial execution under a green trace*. Because the `chat` span carried no error status (the model call succeeded; the model simply ran out of budget), dashboards showed turn 7 as a successful 4096-token completion. The runtime's `agent.turn.execute` error span was emitted but not linked, so error-rate SLOs computed over `ge..."
  },
  "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": "283e20cdbc781bda686643baa4b5f61229bfb9c6f26eb56c901ff7924cd437a5",
    "verified_classes": [
      "TruncatedToolCallError",
      "ToolCall"
    ],
    "verified_functions": [
      "extract_executable_tool_calls"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TruncatedToolCallError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
