Vault / wiki/301/cca-domain-5-context-reliability.md
updated 2026-05-28Domain 5 — Context Management & Reliability (15%)
Smallest weight, but heavily mixed with the scenarios — appears in nearly every question.
Topics
5.1 The CALM framework
- Cache stable prefixes (system, tools, reference docs).
- Align prefix structure across requests — don't reshuffle.
- Limit history (sliding window, summarization, retrieval).
- Monitor cache hits and token budgets.
5.2 Prompt caching mechanics
cache_control: {type: "ephemeral"}markers.- 5-min TTL default (1h tier where available).
- Up to 4 cache breakpoints per request.
- Cache write ≈ 125% input cost; cache read ≈ 10%.
- Pays off after ~2 reuses.
- Any change to cached prefix invalidates it.
5.3 Conversation compaction strategies
| Strategy | Best for |
|---|---|
| Progressive summarization | Long chat assistants |
| State object | Transactional / workflow agents |
| Sliding window | Recency-dominant assistants |
| Retrieval-on-demand | Very long-lived assistants |
| Subagent delegation | Multi-task agents |
5.4 Token estimation & budgets
- ~4 chars / token, ~0.75 words / token.
- Use
count_tokensfor precision. - Budget categories: stable prefix, history, working memory, current turn.
5.5 Stale data hazards
- Tool results expire (balance, status, etc.).
- Mark facts with capture timestamps.
- Refresh-on-need beats remember-forever for volatile facts.
5.6 Long-conversation context preservation
- Keep
thinkingblocks (with signatures) for tool-use threads. - Keep matching
tool_use+tool_resultpairs together. - Summarize old turns into a single assistant message rather than dropping.
5.7 Reliability primitives
- Capped iteration counts in agent loops.
- Structured error responses (
is_error: true+ type + message). - Defensive reads after uncertain state.
- Confirmation gates before destructive ops.
- Graceful degradation messages when tools are unavailable.
5.8 Escalation
- "I don't know" / "I can't" are valid agent states.
- Route to human when:
- Confidence is low.
- Required tool is unavailable.
- Iteration cap hit.
- Policy rule (refund > threshold, etc.) triggers.
5.9 Observability
- Log: request_id, conversation_id, tool call name + args + result, cache hits, token usage.
- Tag every fact in extractions with provenance.
- Audit-friendly: a regulator should be able to trace any decision back to source data.
Common question shapes
- "Conversation costs ballooned in week 3. Likely cause?" → Cached prefix changed; cache misses; or no compaction.
- "Agent retried a payment after timeout and double-charged. Fix?" → Uncertain-state pattern: read-before-retry on non-idempotent ops.
- "Pick the compaction strategy for [long support flow, research project, transactional checkout]." → Match strategy to flow type.
- "Where to put a 50KB reference doc?" → System prompt content block with
cache_control.
Cheatsheet
- CALM: Cache, Align, Limit, Monitor.
- Stable prefix; volatile suffix.
- Idempotent retries; defensive reads otherwise.
- Escalate > hallucinate.