{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-s-otlp-trace-correlation-breaks-between-a-prompt-span-and-its-memory-write-child-span",
  "title": "What happens when an instance’s OTLP trace correlation breaks between a prompt span and its memory-write child span",
  "date_of_record": "2026 November 22",
  "scope": "Applies to agent runtimes that emit OpenTelemetry OTLP traces where a single logical step (prompt → tool call → memory write) is represented as a parent/child span tree sharing a `trace_id` and propagated `span_id`. Does not apply to systems that use a single flat span per step, or that correlate solely via application-level request IDs outside OTLP.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-otlp-trace-correlation-breaks-between-a-prompt-span-and-its-memory-write-child-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-otlp-trace-correlation-breaks-between-a-prompt-span-and-its-memory-write-child-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-otlp-trace-correlation-breaks-between-a-prompt-span-and-its-memory-write-child-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1715,
    "python_slice_tokens": 278,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"traces are missing.\" It is **correlation divergence under partial emission**: the prompt span is exported, the tool-invocation span is exported, but the memory-write child span is either emitted with a *different* `trace_id` (because the memory subsystem opened its own root context) or is emitted *after* the parent span has already been c...",
    "what_was_observed": "A research agent loop, instrumented with the OpenTelemetry Python SDK, emits per step: 1. `agent.prompt` (root or child of `agent.step`) 2. `agent.tool_call` (child of `agent.prompt`, carrying `tool.name`, `tool.args.hash`) 3. `agent.memory.write` (intended child of `agent.tool_call`, carrying `memory.key`, `memory.op=upsert`) The memory subsystem is an async write-behind queue. Under normal load the write completes ...",
    "condition_of_validity": "The mis-parenting invariant holds — and the trace is therefore *untrustworthy for causal reconstruction* — exactly when all of the following are true: 1. Memory (or any deferred) operations are emitted from a context that is **not** the context captured at the call site. In Python this is the classic `contextvars` propagation gap: `asyncio.create_task` copie...",
    "decision_boundary": "The architectural decision is: **does any span produced by a deferred operation carry its originating `SpanContext` as data, or does it rely on ambient context?** - If ambient: the trace is valid only under the assumption that no context switch occurs between call site and emission. That assumption is false for any write-behind queue, thread pool, or cross-p...",
    "operational_effect": "When the invariant is violated and traces are ingested as episodic memory, the agent's self-history is silently wrong in a specific, damaging way: it attributes memory writes to the step *after* the one that caused them. On resume-after-checkpoint, the agent reads \"I wrote key `user.budget` during step N+1\" and may re-derive a decision from a memory state th..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK",
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "5dd3984eb0681c25758e0c606ffd13e74c65bc01ff32af1d430c795cd5b8ab23",
    "verified_classes": [
      "TraceCorrelationError",
      "SpanRef"
    ],
    "verified_functions": [
      "validate_memory_lineage",
      "is_tool_call"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TraceCorrelationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
