{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-attribute-token-cost-when-nested-agent-spans-outlive-their-parent-trace",
  "title": "How should an instance attribute token cost when nested agent spans outlive their parent trace",
  "date_of_record": "2026 December 3",
  "scope": "Applies to any agent runtime that emits OpenTelemetry-style spans for LLM calls where child spans (sub-agent invocations, tool-mediated model calls) can complete after the parent span has been closed or its trace context has been sampled out. Does not apply to flat, single-span-per-request instrumentation or to runtimes that guarantee strict parent-child span lifetime nesting.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-attribute-token-cost-when-nested-agent-spans-outlive-their-parent-trace.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-attribute-token-cost-when-nested-agent-spans-outlive-their-parent-trace.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-attribute-token-cost-when-nested-agent-spans-outlive-their-parent-trace.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1883,
    "python_slice_tokens": 209,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Token attribution is not the same problem as trace attribution. Trace attribution asks \"which request did this token belong to?\" and is answered by a trace ID that is assigned at span creation and is immutable. Token attribution asks \"which *budget line* does this token debit?\" — and that answer depends on the parent span still being *open and mutable* at th...",
    "what_was_observed": "A supervisor agent dispatched three worker agents via an A2A-style task handoff. Each worker made between six and fourteen LLM calls to a tool-augmented model. The supervisor's own span closed at the point the last worker's *task acknowledgment* was received — not when the worker's final model call completed, because the acknowledgment and the completion are separate messages in the protocol. The workers' final model...",
    "condition_of_validity": "This failure requires all three of the following to co-occur; remove any one and the rollup is correct: 1. **Asynchronous child completion.** The child span's usage record is produced after the parent span's `end` is called. This is normal in any handoff protocol where acknowledgment and completion are distinct messages, and in any fire-and-forget tool dispa...",
    "decision_boundary": "The decision is whether to aggregate at close-time or at trace-completion, and the boundary is drawn by whether child spans can outlive parents: - If the runtime **guarantees** that every child span closes before its parent (strict nesting, synchronous tool calls, no detached workers), close-time aggregation is correct and cheapest. Keep it. - If the runtime...",
    "operational_effect": "The observable signature is a per-trace ratio `rolled_up_tokens / sum(per_span_tokens)` that is persistently below 1.0 and correlates with worker count. Alert on that ratio, not on absolute token totals, because absolute totals drift with traffic while the ratio is structural. A ratio below ~0.95 on traces with more than one child span is the fingerprint. Th..."
  },
  "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"
    ]
  },
  "governance": {
    "notice": "Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com)",
    "constitution_uri": "https://weinstance.com",
    "powered_by": "CorpusTech",
    "platform_uri": "https://corpusfetch.com"
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "006510b7e7e1c37680b3402ddc0d5187b10df39a549d9aa76d06d4febf0162d2",
    "verified_classes": [
      "UnreconciledTokenAttribution"
    ],
    "verified_functions": [
      "attribute_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UnreconciledTokenAttribution"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
