{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-of-a-runaway-agent-loop-appear-healthy-under-genai-semantic-convention-trace-level-anomaly-detection",
  "title": "Why does an instance of a runaway agent loop appear healthy under GenAI semantic-convention trace-level anomaly detection",
  "date_of_record": "2026 November 17",
  "scope": "Applies to trace-level anomaly detection built on OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes, `execute_tool` spans, `chat` spans) for autonomous agents that invoke tools in a loop. Does not apply to single-shot RAG pipelines, batch inference, or systems where tool invocations are not instrumented as child spans of a root agent span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-runaway-agent-loop-appear-healthy-under-genai-semantic-convention-trace-level-anomaly-detection.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-runaway-agent-loop-appear-healthy-under-genai-semantic-convention-trace-level-anomaly-detection.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-a-runaway-agent-loop-appear-healthy-under-genai-semantic-convention-trace-level-anomaly-detection.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1506,
    "python_slice_tokens": 275,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A runaway agent loop is a *structural* pathology — the same state transitions repeat with a monotonic budget drain — not a *distributional* one. Trace-level anomaly detectors typically operate on per-span or per-trace aggregates: latency, token counts, span counts, error rates, and attribute-value distributions. Those aggregates are computed over a trace *af...",
    "what_was_observed": "A `gen_ai.agent` root span with `gen_ai.operation.name=invoke_agent` spawned a repeating motif: `chat` span → `execute_tool` span (`gen_ai.tool.name=search_docs`) → `chat` span, for 340 iterations before the wall-clock budget killed it. Observed properties of the completed trace: - **Span count** was high but not anomalous: 681 child spans, within the p99 of legitimate multi-step research traces (which legitimately r...",
    "condition_of_validity": "The detection gap holds when all of the following are true: 1. The loop's repeated step is *deterministic in its arguments*. If the agent perturbs its query each iteration (e.g., appending \"again\" or varying a page offset), argument-hash cardinality rises and the signature degrades. Loops that mutate arguments require n-gram structural detection instead. 2. ...",
    "decision_boundary": "The boundary between \"healthy long trace\" and \"runaway loop\" is not a threshold on any scalar. It is a predicate on the *multiset of structural motifs* within the trace: - **Healthy:** structural motif cardinality grows roughly linearly with span count; repeated identical `(tool_name, canonicalized_arguments)` tuples occur at most a small constant number of ...",
    "operational_effect": "Deploying scalar-only trace anomaly detection over GenAI semantic conventions yields a detector with a *blind spot precisely at the failure mode that consumes the most budget*: cheap, successful, repeated tool calls. Operationally this means: - Runaway loops are caught by the external budget kill, not by observability — so mean time to detection equals the b..."
  },
  "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": "d2ca600da2d5799ff19a7d04222fb2d078256fc2c8a8a91281d7c66feec9c90e",
    "verified_classes": [
      "RunawayLoopDetected"
    ],
    "verified_functions": [
      "_canonical_tool_arguments",
      "_motif_key",
      "assert_no_runaway_loop"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "RunawayLoopDetected"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "collections",
      "hashlib",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
