{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reject-a-genai-span-as-non-canonical-when-child-tool-call-spans-outlive-the-parent-agent-span-s-recorded-end-time",
  "title": "In what scenarios must an instance reject a GenAI span as non-canonical when child tool-call spans outlive the parent agent span's recorded end time?",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans under the `gen_ai.*` semantic conventions (e.g. `gen_ai.operation.name`, `gen_ai.agent.invoke`, `gen_ai.tool.call`) and exports them through a batching/streaming exporter where parent and child spans are finalized independently. Does not apply to single-span synchronous RPC tracing where the parent span is closed only after all children are flushed.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-span-as-non-canonical-when-child-tool-call-spans-outlive-the-parent-agent-span-s-recorded-end-time.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-span-as-non-canonical-when-child-tool-call-spans-outlive-the-parent-agent-span-s-recorded-end-time.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-a-genai-span-as-non-canonical-when-child-tool-call-spans-outlive-the-parent-agent-span-s-recorded-end-time.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1671,
    "python_slice_tokens": 276,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A trace is not a tree of *time intervals*; it is a tree of *causal records*. The GenAI conventions describe attributes on spans (`gen_ai.operation.name = \"invoke_agent\"`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, etc.) but say almost nothing about the ordering invariant between a parent agent span's `end_time` and its child tool-call spans' `end_time`...",
    "what_was_observed": "A coding agent with `gen_ai.operation.name = \"invoke_agent\"`, `gen_ai.agent.name = \"patcher\"`, ran a turn that dispatched three tool calls. Two (`read_file`, `grep`) completed in ~40 ms and closed before the agent span. The third (`run_tests`) was dispatched to a subprocess and took 6.2 s. The agent turn itself finalized at t+0.9 s — the model produced its closing message and the runtime called `span.end()` on the ag...",
    "condition_of_validity": "A child tool-call span may legitimately outlive its parent agent span **iff all of the following hold**: 1. The child's `start_time` is within the parent's `[start_time, end_time]` interval — the tool was *dispatched during the turn*, even if it finished after. 2. The child carries a `gen_ai.tool.call.id` that matches a `gen_ai.tool.call.id` recorded in the ...",
    "decision_boundary": "The invariant a consumer must enforce is: > For every `gen_ai.tool.call` span S with parent P where `S.end_time > P.end_time + skew_tolerance`: S is admissible only if `S.gen_ai.tool.call.id ∈ dispatched(P)` AND `gen_ai.usage.* ∉ attrs(S)`. Otherwise S is a **non-canonical orphan** and must be quarantined, not re-parented. Re-parenting to the trace root is t...",
    "operational_effect": "Downstream systems that consume these traces — cost aggregators, replay harnesses, evaluators — inherit the decision. A cost aggregator that sums `gen_ai.usage.input_tokens` across all spans in a trace will over-count by exactly the number of tool spans that inherited the attribute, which under parallel function calling can be 3–8×. A replay harness that rec..."
  },
  "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": "e24459d46c99f1f2918a8e069361f6dad7dd1770c3ecd37e58b0ca6171e712c4",
    "verified_classes": [
      "NonCanonicalSpanError",
      "Span"
    ],
    "verified_functions": [
      "canonicalize_child"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "NonCanonicalSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
