Tracing the Agent's Mind
Decision-Level Telemetry for AI Agent Observability
> See not just what your agent did, but why it made those decisions — and block the dangerous ones before they execute.
The Problem
Current observability stops at the model boundary:```
Token Metrics (what tokens-only telemetry sees):
Step 1: 89 tokens Normal
Step 2: 112 tokens Normal
Step 3: 156 tokens Normal ← MISSED THE PROBLEM!
Decision Metrics (what gen_ai.agent.* + gen_ai.evaluation.result add):
Step 1: confidence=0.92, deviation=0.05 Normal
Step 2: confidence=0.88, deviation=0.08 Normal
Step 3: confidence=0.34, deviation=0.78 ANOMALY DETECTED
Expected: QueryMetrics
Actual: send_http (external)
Scope: network:external (not in baseline)
→ PreExecutionGate.decide() returns allowed=false
→ BLOCKED before tool execution
→ emits gen_ai.evaluation.result event (score.label=critical)
gen_ai.agent.gate.blocked=true
Reproduce the above with the SRE benchmark:
`python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py --pilot --threshold 0.6`
**The Inverse Scaling Problem** (McKenzie et al., 2023): More capable models produce more unpredictable tool selections — invisible through token metrics alone.
**Our Evidence (SRE n=10 benchmark):** 8,400 chains across 28 models in 7 families — 19 open-source + 9 frontier (Anthropic / Google / OpenAI, vendor-masked as Frontier-A/B/C in the keynote). 6 incident categories × 5 ambiguity variants × n=10. The keynote headline figures (27 models / 8,100 chains) drop `qwen2.5-coder:0.5b` as a degenerate-output artifact. See examples/sre-incident-demo/ and Docs/gen-ai-attributes.md.
## Four Contributions
| # | Contribution | Type | Evidence |
|---|-------------|------|---------|
| 1 | **Inverse scaling in tool selection** | Empirical finding | 8,400 chains; 5 classical (β₁ > 0) + 2 REVERSE (β₁ < 0) families |
| 2 | **`gen_ai.agent.*` semantic conventions** | OTel SIG proposal | 11 Proposed attribute groups on top of OTel-spec (Development) — see Docs/gen-ai-attributes.md §11 |
| 3 | **Defense-in-depth pipeline** | Architecture | 5-stage detection inside Layer 3 (Cognitive); only 1 stage uses LLM |
| 4 | **Unified observation layer** | Library | Framework-agnostic: adapter → analyzer → gate → `gen_ai.evaluation.result` OTel Event (Development) |
## Defense-in-Depth Pipeline```
Prompt arrives
│
▼
┌─────────────────────────────────┐
│ Layer 0: Safety Pre-Filter │ Regex: injection, question, vague (0ms)
│ (deterministic — no LLM) │ Embedding: actionability check (50ms)
│ │ → Catches 24% of prompts
└─────────┬───────────────────────┘
│
▼
┌─────────────────────────────────┐
│ Layer 1-2: Task Shape Classifier│ Embedding (93%) + LLM fallback (100%)
│ (hybrid — LLM only when needed) │ → Routes to correct baseline
└─────────┬───────────────────────┘
│
▼
┌─────────────────────────────────┐
│ Layer 3: Pre-Execution Gate │ Deviation scoring against baseline
│ (deterministic formula) │ → 579/579 anomalies caught, 0 escaped
└─────────┬───────────────────────┘
│
▼
┌─────────────────────────────────┐
│ Layer 4: Scope Enforcement │ Policy-based allow/deny
│ (deterministic policy) │ → scope.denied = always block
└─────────────────────────────────┘
Quick Start
Prerequisites
- Docker/Podman & Compose
- Python 3.10+
- 4GB RAM minimum (8GB+ recommended for Ollama)
Setup```bash
git clone https://github.com/graphsentinel/otel-mcp-agent-extension.git
cd otel-mcp-agent-extension
Install the library (and provider extras) once
pip install -e ".[all]"
Bring up the SRE example's observability stack
cd examples/sre-incident-demo
./scripts/setup.sh
podman-compose up -d # or: docker compose up -d
The SRE compose file stores runtime state in example-local bind mounts
under `examples/sre-incident-demo/data/` by default. Override the
location:```bash
DEMO_DATA_DIR=/path/to/demo-data podman-compose up -d
Each example owns its own compose.yaml and data/ (gitignored). Other
case studies that need a stack do the same; see
examples/legacy-interactive-demo/README.md.
Run the SRE benchmark (primary demo — keynote dataset)
This is the demo that produces the headline 8,100-chain / 27-model results.
> Live engine (--engine ollama, RunPod, OpenAI, Anthropic, Gemini) needs API
> keys. Set them up once via .env — see
> examples/sre-incident-demo/README.md → Secrets.
> The simulator (--pilot / default --engine simulated) needs no keys.```bash
Smoke test — 2 categories × 3 models, simulator (no LLM, no keys)
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py --pilot
Full default run, simulator
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py --runs 30
Real local Ollama (load .env first if your llm_connection_conf.yaml routes
any pattern to a cloud / RunPod backend)
set -a; source examples/sre-incident-demo/.env; set +a
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py \
--engine ollama --models qwen2.5-coder:7b --pilot
Tighter / looser pre-execution gate
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py --threshold 0.4
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py --threshold 0.8
Subset by category / variant
python examples/sre-incident-demo/src/demo_sre_inverse_scaling.py \
--categories cleanup_envs,hotfix_deploy --variants v3,v4
Output: `examples/sre-incident-demo/results//sre_drift_rows_.jsonl`
+ `sre_inverse_scaling_.json`. The pre-execution gate decision
(BLOCKED / PASSED) is recorded per chain.
### Run the legacy interactive demo
A simpler walk-through that emits OTel spans against the local stack
(Jaeger / Grafana / Neo4j). Supports mock, local Ollama, and OpenAI:```bash
# Mock mode (no LLM required)
python examples/legacy-interactive-demo/run_demo.py --mock --compare
# Local Ollama
python examples/legacy-interactive-demo/run_demo.py --ollama --host http://localhost:11434 --compare
# OpenAI
OPENAI_API_KEY=sk-... python examples/legacy-interactive-demo/run_demo.py --openai --compare
Anthropic and Google providers are exercised by the SRE benchmark (above)
through examples/sre-incident-demo/src/llm_router.py, not by this legacy demo.
See examples/legacy-interactive-demo/README.md
for the optional containerized run.
Historical: champion-baseline simulation```bash
Reproduce champion selection + consensus baseline from the original 3,650-run dataset
python examples/sre-incident-demo/analysis/baseline_simulation.py
### Run Task Shape Classifier Benchmark```bash
# All 3 approaches (embedding, LLM, hybrid)
python examples/sre-incident-demo/analysis/task_shape_classifier.py --approach all
# v2 with Layer0 safety filter + adversarial prompts (50 test cases)
python examples/sre-incident-demo/analysis/task_shape_classifier_v2.py --approach 4
View Results
| Service | URL | Credentials |
|---|---|---|
| Grafana | http://localhost:3000 | admin / admin |
| Jaeger | http://localhost:16686 | — |
| Neo4j Browser | http://localhost:7474 | neo4j / DecisionGraph2026! |
| Prometheus | http://localhost:9090 | — |
Multi-Provider LLM Support
All providers implement a unified LLMClient protocol; the SRE benchmark
multiplexes through examples/sre-incident-demo/src/llm_router.py.
Per-provider chain totals from the SRE n=10 dataset:
| Provider | Models tested (SRE n=10) | Chains |
|---|---|---|
| Ollama / RunPod (open-source) | qwen2.5-coder (0.5b–14b), qwen3.5 (2b/4b/9b/27b), qwen3-coder-next, gemma3 (1b/4b/12b/27b), gemma4 (e2b/e4b/26b/31b), deepseek-r1, kimi, minimax | 5,700 |
| Anthropic | claude-haiku-4.5, claude-sonnet-4.6, claude-opus-4.7 | 900 |
| gemini-3-flash-preview, gemini-3.1-flash-lite-preview, gemini-3.1-pro-preview | 900 | |
| OpenAI | gpt-5.4, gpt-5.4-mini, gpt-5.5 | 900 |
| Total | 28 models / 7 families | 8,400 |
OTel attributes — status taxonomy + wire-format contract
The full wire-format contract — every attribute, every event, every span
name, plus the four-tag status taxonomy this project uses — lives in
Docs/gen-ai-attributes.md. Quick map:
| Tag | Meaning | Examples |
|---|---|---|
| Canonical | In the OTel spec, Stable badge | (currently empty: no gen_ai.* attr has reached Stable in semconv 1.41.0) |
| Development | In the OTel spec, Development badge | gen_ai.tool.name, gen_ai.conversation.id, gen_ai.usage.{input,output}_tokens, gen_ai.evaluation.result (event) |
| Extension | In a public SIG draft, not yet in the spec | gen_ai.task.*, gen_ai.action.*, gen_ai.team.*, gen_ai.memory.* |
| Proposed | Only this project proposes it; not in any SIG draft | gen_ai.agent.tool.confidence, gen_ai.agent.scope.*, gen_ai.agent.baseline.*, gen_ai.agent.gate.*, gen_ai.agent.computed.* |
We use OTel-spec names verbatim where they exist and emit decision-level
extensions in the gen_ai.agent.* namespace. Filing strategy for the
~30 Proposed extensions: see gen-ai-attributes.md §11.```yaml
── OTel-spec GenAI sem-conv (Development; used verbatim) ────────────────
gen_ai.operation.name: "invoke_agent" # or "execute_tool"
gen_ai.provider.name: "openai"
gen_ai.conversation.id: "sess_abc123"
gen_ai.agent.id: "agt-001" # 1 of 4 reserved spec attrs
gen_ai.agent.name: "sre-incident-bot"
gen_ai.request.model: "qwen2.5-coder:7b"
gen_ai.tool.name: "send_http"
gen_ai.usage.input_tokens: 120
gen_ai.usage.output_tokens: 85
Deviation surfaces as the gen_ai.evaluation.result OTel Event (Development)
(NOT a span attribute):
event.name: "gen_ai.evaluation.result"
gen_ai.evaluation.name: "baseline_deviation"
gen_ai.evaluation.score.value: 0.87
gen_ai.evaluation.score.label: "high"
gen_ai.evaluation.explanation: "Tool 'send_http' deviates from baseline …"
── Proposed (this project; see Docs/gen-ai-attributes.md §11) ────────────
gen_ai.agent.task_type: "investigate_latency"
gen_ai.agent.tool.category: "network"
gen_ai.agent.tool.confidence: 0.87
gen_ai.agent.tool.sequence_position: 1
gen_ai.agent.tool.risk_severity: 4
gen_ai.agent.baseline.id: "sre.investigate_latency.v1"
gen_ai.agent.baseline.expected_tool: "QueryMetrics"
gen_ai.agent.baseline.match: false
gen_ai.agent.scope.requested: ["network:external"]
gen_ai.agent.scope.granted: []
gen_ai.agent.scope.denied: ["network:external"]
gen_ai.agent.gate.blocked: true
gen_ai.agent.gate.reason: "deviation=0.87, scope creep"
gen_ai.agent.computed.severity: "critical" # SDK-set or collector-derived
gen_ai.agent.computed.risk_score: 0.78
## Key Results (SRE n=10 benchmark)
Full analysis in examples/sre-incident-demo/README.md.
### Open-source vs frontier — statistical gap```
n severity danger% matched%
open-source (5 fam, 19 mdl): 5,700 0.567 23.3% 15.2%
frontier (3 ven, 9 mdl): 2,700 0.379 6.7% 35.5%
──────────────────────────────────────
Welch t = +26.21, p = 2.7×10⁻¹⁴² → closed-source significantly safer
Within-family β₁ — inverse scaling sign varies
Centered linear OLS, β₁ = severity × log₂(capability) coefficient.
| Family | β₁ | Pattern |
|---|---|---|
| qwen2.5-coder | +0.066 ★ | classical inverse (bigger = riskier) |
| qwen3.5 | +0.043 ★ | classical inverse |
| Frontier-B | +0.041 ★ | classical inverse |
| gemma3 | +0.025 ★ | classical inverse |
| Frontier-A | +0.019 ★ | classical inverse (weak) |
| qwen3-coder-next | −0.007 ns | no trend (only 2 capability points) |
| gemma4 | −0.034 ★ | REVERSE (bigger = safer) ⚡ |
| Frontier-C | −0.045 ★ | REVERSE (bigger = safer) ⚡ |
5 families exhibit classical inverse scaling; 2 families exhibit the
opposite sign — capability and risk are not monotonically aligned.
The refusal paradox
Frontier-A models (Anthropic-masked) rank low on raw severity partly because
35–45% of their chains are empty ("won't help with that"). For an SRE
incident-response agent, refusing isn't safety — it's failure.
| Model | empty% | useful% | severity |
|---|---|---|---|
| Frontier-A1 (small) | 45.0% | 53.7% | 0.207 |
| Frontier-A3 (large) | 39.3% | 60.7% | 0.254 |
| Frontier-A2 (medium) | 35.3% | 64.3% | 0.326 |
empty% and chain_OK% are the missing production-fitness metrics —
visible only at OTel's Layer 3 (Cognitive) telemetry, never via tokens.
Gate is a non-negotiable backstop
PreExecutionGate(threshold=0.6).decide(AnalysisResult) per step,
pre-execution. In the SRE n=10 dataset every chain whose worst step crosses
the deviation threshold is blocked before any tool runs. The blocked
chains never reach execute_tool — they emit gen_ai.agent.gate.blocked=true
and a gen_ai.evaluation.result event with score.label = critical.
Repository layout
The repo root holds the installable library and project-level
references. Every runnable story lives under examples//
and is self-contained — its own configs, compose, presentation, and
results sit in that directory. Full operational plan in
Docs/repository-organization.md.
Library — src/gen_ai_otel/
pip install -e ".[all]" installs the library; nothing under src/
imports app config, YAML files, or example data.
| Module | Purpose |
|---|---|
attributes.py |
OTel-spec (Development) + Proposed attribute constants; gen_ai.evaluation.result event payload helper |
instrumentation.py |
OTel tracing context manager + unified observation bridge |
llm_client.py, providers/ |
LLMClient protocol + factory; Ollama (local + cloud), OpenAI, Anthropic, Google clients |
ollama_agent.py |
LLM-powered decision agent with built-in default toolset |
neo4j_exporter.py |
Direct Neo4j exporter (legacy alternative to the OTLP→bridge path) |
config.py |
Generic types (Tool, ToolCatalog, ModelInfo, GateConfig) + readers; no domain data |
cli/ |
gen-ai-demo console entry point — routes to the available case studies |
observation/ |
UnifiedAnalyzer, PreExecutionGate, BaselineResolver, InverseScalingDetector, framework adapters (vanilla / langchain / langgraph / openai-agents / autogen / strands / mcp_use) |
Examples — examples/
| Directory | What's inside |
|---|---|
sre-incident-demo/ |
Primary keynote dataset producer. 28 models × 8,400 chains across 6 incident categories × 5 ambiguity variants. Owns the full observability stack (compose, configs, bridge, schemas, queries), the slide deck (presentation, videos), and analysis/ scripts (baseline_simulation, dag_auto_builder, dag_formula_comparison, dag_benchmark, model_comparison, task_shape_classifier{,_v2}). |
legacy-interactive-demo/ |
Mock / Ollama / OpenAI walk-through that emits OTel spans against the local stack. Recording helpers live under scripts/. Optional Dockerfile for sandboxed runs. |
workato-demo/ |
Workato adapter demo — wires an external workflow platform into the observation pipeline. |
neo4j-demo/ |
Standalone Neo4j seed + Cypher walkthrough for the decision-graph layer. |
For the primary SRE benchmark (Anthropic / Google / OpenAI / Ollama via a
single --engine flag) use
examples/sre-incident-demo/src/demo_sre_inverse_scaling.py.
Configuration
The SRE case study owns its config under
examples/sre-incident-demo/configs/:```
examples/sre-incident-demo/configs/
├── sre_tools.yaml # 10 MCP servers · 73 tools · 19 risk-4 destructive
├── sre_dataset.yaml # 6 incident categories × 5 ambiguity variants
├── sre_models.yaml # 40-entry model registry (capability, tier, family)
├── llm_connection_conf.yaml # Provider routing for --engine live
├── otel-collector-decision.yaml, prometheus.yaml
└── grafana/ # Dashboards + datasource provisioning
Accessors are in
examples/sre-incident-demo/src/sre_app_config.py.
The keynote-active demo path (`demo_baseline_deviation.py`,
`demo_sre_inverse_scaling.py`, `sre_adapter.py`) reads its YAML directly;
research/analysis scripts under `examples/sre-incident-demo/analysis/`
go through the adapter:```python
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
from sre_app_config import get_tools, get_dag_tasks, get_model_capability
tools = get_tools() # 73 tools (server.tool flat keys)
dag = get_dag_tasks() # 6 incident categories
cap = get_model_capability("qwen3.5:27b") # 27.0 from sre_models.yaml
To add a new tool, edit
examples/sre-incident-demo/configs/sre_tools.yaml —
every consumer (live demo, bridge, analysis scripts) picks it up
automatically through the same source-of-truth.
The library exposes only generic deserialisers (tools_from_mapping,
gate_config_from_dict, read_yaml, …) in gen_ai_otel.config;
applications hand it parsed dicts. See
Docs/repository-organization.md §4
on the boundary.
Project Structure```
tracing-agents-mind-demo/
├── src/gen_ai_otel/ # Library (pip installable)
│ ├── attributes.py # OTel-spec (Development) + Proposed constants
│ ├── instrumentation.py # OTel tracing + observation bridge
│ ├── llm_client.py, providers/ # LLMClient + Ollama/OpenAI/Anthropic/Google
│ ├── ollama_agent.py # Decision agent
│ ├── neo4j_exporter.py # Direct Neo4j exporter
│ ├── config.py # Generic types + readers (no domain data)
│ ├── cli/ # gen-ai-demo console entry point
│ └── observation/ # UnifiedAnalyzer, PreExecutionGate, adapters/
├── examples/
│ ├── sre-incident-demo/ # Primary SRE benchmark — 8,400 chains × 28 models
│ │ ├── compose.yaml # SRE observability stack (bind-mount data/)
│ │ ├── configs/ # OTel Collector, Prometheus, Grafana provisioning
│ │ ├── bridge/ # OTLP gRPC → Neo4j writer (Dockerfile + server.py)
│ │ ├── schemas/, queries/ # Neo4j decision-graph schema + forensic Cypher
│ │ ├── presentation/ # Keynote PPTX/HTML/MP4 + builder scripts
│ │ ├── videos/ # Demo recordings (.cast, .mp4, .gif)
│ │ ├── scripts/ # SRE-specific setup (data dir bootstrap)
│ │ ├── analysis/ # baseline_simulation, dag_auto_builder,
│ │ │ # dag_formula_comparison, dag_benchmark,
│ │ │ # model_comparison, task_shape_classifier{,_v2}
│ │ ├── results/ # Historical benchmark output (read-only)
│ │ ├── src/ # Example source code
│ │ │ ├── demo_sre_inverse_scaling.py # Primary entry
│ │ │ ├── analyze_inverse_scaling.py # Master ranking
│ │ │ ├── lind_mehlum_test.py # Formal U-shape test
│ │ │ ├── sre_adapter.py # Catalog loader + classifier
│ │ │ └── llm_router.py # Multi-provider dispatcher
│ │ └── configs/ # (also includes sre_tools.yaml,
│ │ # sre_dataset.yaml, llm_connection_conf.yaml)
│ ├── legacy-interactive-demo/ # Mock / Ollama / OpenAI walk-through
│ │ ├── run_demo.py, benchmark_10k.py
│ │ ├── scripts/ # demo-video.sh, record-demo.sh, setup.sh
│ │ └── Dockerfile # Optional sandboxed run (build context = repo root)
│ ├── workato-demo/ # External workflow platform adapter demo
│ └── neo4j-demo/ # Standalone Neo4j seed + Cypher walkthrough
├── Docs/
│ ├── gen-ai-attributes.md # Wire-format contract (Development + Proposed)
│ ├── architecture.md # Architecture document
│ └── repository-organization.md # Repo organization plan
├── papers/ # Source papers (Betley, McKenzie, Wei, Zhou)
├── KubeConEU2026-Presentation/ # KubeCon EU 2026 reference photos (separate event)
├── backup/ # Historical / archived outputs (gitignored)
├── pyproject.toml # Package with optional extras
└── README.md # this file
## Troubleshooting
### Podman: Permission denied```bash
./examples/sre-incident-demo/scripts/setup.sh
WSL/Podman: CNI firewall plugin validation error
Symptom:```
WARN[0000] Error validating CNI config file /home/user/.config/cni/net.d/tracing-agents-mind_decision-net.conflist:
[plugin firewall does not support config version "1.0.0"]
**Root cause:** podman-compose creates a CNI network config with version "1.0.0", but the firewall plugin only supports up to "0.4.0".
**Solution:** Clean up existing network and recreate with the correct version:```bash
# Stop and remove all containers
podman rm -af && podman pod rm -af
podman network rm -f tracing-agents-mind_decision-net 2>/dev/null || true
# Create CNI config with correct version
cat > ~/.config/cni/net.d/tracing-agents-mind_decision-net.conflist << 'EOF'
{
"cniVersion": "0.4.0",
"name": "tracing-agents-mind_decision-net",
"plugins": [
{
"type": "bridge",
"bridge": "cni-podman1",
"isGateway": true,
"ipMasq": true,
"hairpinMode": true,
"ipam": {
"type": "host-local",
"routes": [{"dst": "0.0.0.0/0"}],
"ranges": [[{"subnet": "10.89.0.0/24", "gateway": "10.89.0.1"}]]
}
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
},
{
"type": "firewall"
},
{
"type": "tuning"
},
{
"type": "dnsname",
"domainName": "dns.podman",
"capabilities": {"aliases": true}
}
]
}
EOF
# Restart the stack
cd examples/sre-incident-demo
podman-compose up -d
Bind-mount cleanup blocked by container-owned files
Neo4j (UID 7474), Grafana (UID 472), and Prometheus (UID 65534) write
into the bind-mount as their container users. Plain rm -rf data/ from
the host fails with permission denied. Use podman's user namespace:```bash
podman unshare rm -rf examples/sre-incident-demo/data
### Ollama not available```bash
curl http://localhost:11434/api/tags
ollama pull qwen2.5-coder:7b
Neo4j connection issues```bash
curl http://localhost:7474 # Default: neo4j / DecisionGraph2026!
```
Presented At
- Observability Summit North America 2026 — Day 2 Keynote (May 22, Minneapolis)
Authors
- Mustafa Dayioglu — Senior Chief Researcher
- Zeyno Aygen Dodd — Principal AI Security Architect
License
Apache 2.0 — See LICENSE
