CCA-FChapters11

Chapter 11

Context Management

Facts blocks that survive compaction, trimming at the boundary, and delegation as a context strategy.

D5guide part i

11.1

Lift the facts out of the history

History degrades when it is summarised. A facts block is resent verbatim, so it cannot.

Structured facts block
=== CASE FACTS (updated when a new fact appears) ===
Customer ID: CUST-12345
Order ID: ORD-67890
Order Date: 2025-01-15
Order Amount: $89.99
Issue: Damaged item on delivery
Customer Request: Full refund
Status: Pending manager approval
===

Ids, dates and amounts — precisely the values summarisation turns into "roughly" and "a few".

Included in every prompt, regardless of what happened to the conversation behind it.

11.2

Trim at the boundary

A tool that returns 40 fields when 5 matter spends the window on noise — on every later call this turn.

raw lookup_order · 40+ fields
system
tool defs
tool results
free
trimmed · 5 fields the task needs
system
tool defs
results
free
A PostToolUse hook rewrites the result before it ever enters the transcript.

Keep order_id, status, total,items, return_eligible — drop the rest. Less context spent, and less noise for the model to wade through.

11.3

Position-aware input

Same content, different order, different recall. Put load-bearing text where retrieval is strong.

KEY FINDINGS3 critical vulnerabilities…DETAILED RESULTS=== auth.ts ====== database.ts ===ACTION ITEMSfix auth.ts before mergestrong recallweakest herestrong recallbulk detail is finein the middle
Findings at the top, bulk in the middle, the instruction that must land at the very end.

11.4

Write findings to a file

A long investigation outlives its own context window. A file does not.

investigation-scratchpad.md
# investigation-scratchpad.md
## Key findings
- PaymentProcessor in src/payments/processor.ts extends BaseProcessor
- refund() is called from 3 places: OrderController, AdminPanel, CronJob
- PaymentGateway API rate limit: 100 req/min
- Migration #47 added refund_reason (NOT NULL) — 2024-12-01

Conclusions, not transcripts. Each line is something it would cost tool calls to rediscover.

Consulted instead of re-running discovery — after degradation, after a compact, or in a fresh session.

11.5

Delegation is a context strategy

A subagent spends its own window and hands back a sentence. That asymmetry is the point.

main agentholds one linetaskExplore subagentits own window · limited allowedTools15 files read · imports tracednone of it reaches the main window"payments depends on AuthService…"
Fifteen files read, one line kept. The coordinator is a separate context layer, not a bigger one.

11.6

State on disk survives the crash

Each agent exports its own state; the coordinator reads a manifest to know where to pick up.

agent-state/
// agent-state/web-search-agent.json
{ "status": "completed",
  "queries_executed": ["AI music 2024", "AI music composition"],
  "results_count": 12,
  "coverage": ["music composition", "music production"],
  "gaps": ["music distribution", "music licensing"] }

// agent-state/manifest.json
{ "web-search": "completed",
  "doc-analysis": "in_progress",
  "synthesis": "not_started" }
Resumption reads files, not history — gaps is what tells the coordinator there is work left.
per-agent filestatus, what it did, findings, coverage and gaps
manifest.jsonone status per agent — the coordinator's resume point
on resumeload the manifest, restart only what is not completed

Recall in 60 seconds

  1. Extract ids, dates and amounts into a facts block resent every prompt — summarisation destroys them.
  2. Trim tool results at the boundary (PostToolUse) — 40 fields when 5 matter is pure waste.
  3. Tool results accumulate for the whole turn, so noise compounds with every call.
  4. Put key findings first and action items last; bulk detail belongs in the middle.
  5. Scratchpad files hold conclusions that would otherwise cost tool calls to rediscover.
  6. Delegate wide reading to a subagent — it spends its window, you keep the summary.
  7. Constrain subagents: minimal context in, structured result out, allowedTools trimmed.
  8. Per-agent state files plus a manifest.json make a crashed run resumable.