{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-bound-the-parent-child-span-cardinality-of-a-single-tool-call-before-genai-semantic-convention-export-or-the-whole-trace-collap",
  "title": "Where must an instance bound the parent-child span cardinality of a single tool call before GenAI semantic convention export, or the whole trace collapses into an un-attributable fan-out",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*` attributes) for an `execute_tool` child span under an `invoke_agent` parent, where a single logical tool call is retried, fanned out, or streamed. Does not apply to single-shot, non-retried tool invocations with one span per call, nor to pure model-inference spans without tool children.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-the-parent-child-span-cardinality-of-a-single-tool-call-before-genai-semantic-convention-export-or-the-whole-trace-collap.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-the-parent-child-span-cardinality-of-a-single-tool-call-before-genai-semantic-convention-export-or-the-whole-trace-collap.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-the-parent-child-span-cardinality-of-a-single-tool-call-before-genai-semantic-convention-export-or-the-whole-trace-collap.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1989,
    "python_slice_tokens": 319,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a tool call as a *logical operation* with a stable identity (`gen_ai.tool.name`, `gen_ai.tool.call.id`) and an associated token/usage attribution. The OTel trace model treats every emitted span as an independent node keyed by `span_id` with a `parent_span_id`. These two models disagree at exactly one point: **when one log...",
    "what_was_observed": "A research agent (`invoke_agent` span, `gen_ai.agent.name=planner`) issued a tool call to `web.search` with `gen_ai.tool.call.id=call_7f3a`. The tool adapter's HTTP client had a 4-second deadline; the upstream search API returned a `503` at 3.9s on the first attempt. The adapter's retry policy re-issued the request with the *same* `call.id` (correctly — it is the same logical call), and the second attempt succeeded a...",
    "condition_of_validity": "The invariant that must hold for a GenAI trace to be replayable and attributable is: > For any `gen_ai.tool.call.id`, exactly one *terminal* child span under a given `invoke_agent` parent may carry `gen_ai.usage.*` and `gen_ai.tool.result`, and every non-terminal attempt must be marked so that a consumer can exclude it from attribution without heuristics. Th...",
    "decision_boundary": "The runtime must make a hard choice at the moment a retry is scheduled, and the choice determines whether the trace stays coherent: - **Collapse (single-span retry):** reuse the same `span_id`, extend `end_time`, accumulate an `attempt` counter as a span attribute, emit usage once at terminal. Pro: trivially satisfies the invariant; consumers see one child. ...",
    "operational_effect": "When the invariant is violated, the observable symptoms are indirect and misattributed: - Cost dashboards drift upward on retry-heavy traffic and *downward* on traces where the failed attempt exported after the successful one and a \"last-write-wins\" aggregator overwrote the terminal usage with the failed attempt's (often zero) usage. - Auditor replay produce..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "aee5df94bd11853c2bc68589c17d9487a7487a2c5d2e1722209b17908efc079a",
    "verified_classes": [
      "GenAIAttributionError",
      "Span"
    ],
    "verified_functions": [
      "validate_tool_attribution",
      "export_batch"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "GenAIAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
