Series 1 of 4 · Agentic Stack · Level 2 · Topic 16

Context Observability

Harness Architecture
In This Note You Will Learn
  • 01. Why logging input/output is only 5% of what you need to debug AI quality issues -- and what the other 95% looks like.
  • 02. How span-level tracing across CONTEXT layers turns "the AI was wrong" into "the retrieval stage returned stale documents because the index sync failed at 3am."
  • 03. What a production observability stack looks like using Arize Phoenix, LangSmith, and Braintrust -- and when each matters.

The Story

A contract management platform serves 12,000 enterprise users across legal, procurement, and finance teams. The product uses Claude Sonnet to analyze uploaded contracts, flag risky clauses, and suggest negotiation alternatives. Quality has been strong for six months -- user satisfaction at 91%, clause detection accuracy at 93%.

Then, over two weeks, clause detection accuracy drops to 81%. Legal teams start catching missed non-compete clauses and incorrectly flagged indemnification provisions. The support team gets escalations. The VP of Product asks: what happened?

The engineering team checks their logs. They can see every user query and every model response. They can tell you the accuracy dropped. They can't tell you why.

Did the model regress? Same Sonnet version. Did the prompts change? Untouched in four weeks. Did retrieval quality degrade? "We don't log what was retrieved." Did the memory system start loading wrong contract histories? "We log that memory was loaded, but not what was in it."

Three weeks ago, the document ingestion pipeline changed its chunking strategy -- from overlapping 512-token chunks to non-overlapping 1024-token chunks -- to reduce storage costs. The change was deployed to the ingestion pipeline, not the AI product, so no one on the product team was notified. The larger chunks reduced retrieval precision because the embedding model produced lower-quality vectors for 1024-token chunks.

The team spent eleven days diagnosing this. With context observability -- tracing what was retrieved, what scores the reranker assigned, what the model actually saw -- they would have seen the retrieval quality degradation within hours.

The Core Idea

Context observability is the practice of logging, tracing, and visualizing the complete context assembled for every inference call -- not just what the user said and what the model replied, but everything in between.

The mental model shift: traditional software has deterministic paths. Given the same input, you get the same output. AI products have a probabilistic path between input and output, AND that path runs through a context assembly pipeline that itself can have bugs, regressions, and failures. You have two debugging surfaces: the assembly pipeline (deterministic, inspectable) and the model inference (probabilistic, harder to inspect). Context observability gives you full visibility into the first.

Context observability is the instrumented tracing of every context assembly stage -- producing structured, queryable traces that let you diagnose WHY the model responded a specific way, not just WHAT it responded.

-- The working definition

Think of it like a flight data recorder on an aircraft. After an incident, investigators don't just know "the plane deviated from course." They know every instrument reading, every control input, every system state change, second by second. Without the black box, they have the departure gate and the crash site -- input and output -- and years of speculation about what happened in between.

Fig 1. The Black Box Problem
14,970 Tokens You Can't See.
Why "the AI was wrong" takes 11 days without observability and hours with it
What Most Teams See
User message: 30 tokens
?
15,000 tokens assembled here. Invisible.
Model output
11 days to find stale chunking bug
What Observable Teams See
User message: 30 tokens
C Constitution -- 2.1ms -- 340 tokens -- cached 2.1ms
K Knowledge -- 284ms -- 8,200 tokens -- 73% of latency 284ms
T Tracks -- 12ms -- 1,800 tokens -- fresh 12ms
E Equipment -- 45ms -- 2,100 tokens -- 3 tools loaded 45ms
T Template -- 8ms -- 560 tokens -- v2.3 8ms
Model output
Stale chunks identified in hours
The user typed 30 tokens. The system assembled 15,000.
You're debugging the wrong 30.
Eleven days vs two hours. The cost of logging only input and output.
Engineering view: raw spans, token counts, latencies, error stacks.
Product view: retrieval-quality trend, cost/query, tenant comparison.
Same trace. Two audiences. Both essential.

The observability platform landscape. Three tools represent different approaches: Arize Phoenix (open-source, strong on retrieval analysis and embedding drift), LangSmith (pipeline visualization, dataset building from traces), and Braintrust (eval-first, where observability and evaluation share the same data). Provider-native tracing is also maturing -- Anthropic builds tracing directly into Claude Code, and OpenAI's Agents SDK includes structured span logging.

What most teams get wrong: logging output quality without logging input quality. Teams build dashboards that track response accuracy and user ratings. These tell you THAT quality changed. They don't tell you WHY. Context observability focuses on input quality: did retrieval return the right documents? Did memory load the right history? Did tools get the right selection? If the output is wrong AND the input was correct, it's a model problem. If the output is wrong AND the input was wrong, it's a harness problem.

Where This Hits in Production

Retrieval drift detection. In production, retrieval quality degrades silently. Knowledge bases grow. New documents dilute the embedding space. Chunking strategies change. Without observability on the retrieval stage -- tracking average retrieval scores, candidate counts, reranker lift over time -- you won't notice until users complain.

Multi-tenant debugging. In B2B products, quality problems are often tenant-specific. Tenant A's knowledge base has poorly formatted documents. Tenant B's configuration points to a deprecated tool. Span-level tracing with tenant tags lets you filter traces by tenant and diagnose tenant-specific issues without sifting through millions of global traces.

Compliance and audit trails. In regulated industries, organizations need to demonstrate what information the AI system used when making a recommendation. Context observability produces the audit trail: the exact context window the model received for any specific query.

!

The Trap

Building observability that only engineers can read.

A team instruments their entire assembly pipeline -- beautiful traces with every span tagged. The data lives in Datadog, accessible through complex query syntax. Engineers use it daily for debugging.

The PM never looks at it. The quality team can't parse the traces. Product decisions -- should we add reranking? should we increase the memory window? -- are made without consulting the observability data.

The fix: context observability needs two views. An engineering view (full traces, span-level detail) and a product view (retrieval quality trends, assembly success rates, cost per query over time). The PM doesn't need raw traces. They need dashboards that translate observability data into product decisions.

In Practice: Anatomy of a Production Trace

Here's a trace for a single query in a contract management platform -- showing what was retrieved, what was assembled, what the model saw, with timestamps and token counts at every stage.

Fig 2. Production Trace -- Contract Analysis Query
Every Layer Is a Failure Surface.
387ms of decisions you should be watching
"Does this vendor agreement have an auto-renewal clause, and what's the notice period?"
C
Constitution
meridian-v4.2 -- cached -- enterprise tenant config
1,840 tok
6ms
O
Observations
2 examples selected -- intent_matched -- similarity 0.94, 0.89
680 tok
18ms
N
kNowledge (RAG) -- 73% of latency
67 candidates -- 14 above threshold -- 5 selected -- reranker lift active
4,120 tok
284ms
67
Candidates
14
Reranked
5
Selected
T
Tracks
3 prior sessions -- entity resolved: "this vendor" to Apex Solutions Inc.
890 tok
62ms
E
Equipment
3 tools loaded -- 34 skipped (not relevant to contract_analysis)
460 tok
12ms
T
Template
clause_analysis_structured -- schema validation OK
140 tok
5ms
Total assembly: 387ms
Retrieval: 284ms (73%)
Context: 8,130 tokens -- 72% utilization
The bottleneck isn't the model -- it's the assembly.
Retrieval consumed 284ms of 387ms. This is where you optimize first.
The reranker promoted Chunk #23 from rank 11 to rank 2. That single move is the difference between a helpful answer and a wrong one.
⚠ WARN: Reranking latency 198ms exceeds P90 threshold. Next action: tenant index needs partitioning. The dashboard told you which lever to pull — the trace doesn't just record, it diagnoses and recommends.

Remember This

1. If you can't see what the model saw, you can't debug what the model did. Context observability traces the 95% of the context window that isn't the user's message -- because that 95% determines the response.

2. Same tools, different lens: observability platforms serve both engineering debugging and product evaluation. Building two separate systems wastes money and loses the integration between input quality and output quality.

3. Span-level tracing across CONTEXT layers -- one tagged span per assembly stage -- is the production pattern. It turns "the AI was wrong" into "retrieval returned 3 stale documents because the index sync failed at 3am."

References

1. Arize Phoenix -- LLM Observability -- Arize AI Documentation

2. LangSmith -- LLM Application Monitoring -- LangChain Documentation

3. Braintrust -- AI Product Evaluation -- Braintrust Documentation

4. Context Engineering for AI Agents -- Anthropic Engineering Blog

5. OpenAI Agents SDK -- Tracing -- OpenAI Documentation

Previous Topic Back to the Deep Dive