research · v0.3 · current

Context Engineering: Self-Monitoring, Traceability & Repair

Long agentic sessions fill their context windows; agents must self-monitor utilization and quality, and the harness must make what entered context traceable, auditable, and repairable. Search-subagent fan-out (MoE-per-expert) is the leading pattern for structured, verifiable context injection.

published 2026-07-12 · updated 2026-07-16
authors: Nexartis
tags: context-engineering · self-monitoring · traceability · compaction · handover · search-subagent · MoE · observability

Problem

  • Context windows fill in every long agentic session. Ceiling hits are common and each recovery costs either a compaction hit or a handover doc.
  • Compaction is lossy by design: the model summarises its own prior turns, and the summary is not necessarily faithful. Silent quality drops after compaction are the failure mode most often caught late.
  • Handover docs (session A → session B) work but are manual. They are effective when written; unreliable when not written; there is no standing gate.
  • Context self-monitoring is now a workspace rule: every agent — orchestrator and subagents — reports its context-window utilization and a self-assessed quality note in its deliverable; degraded context (compaction, truncation, empty/terse completions) is reported, not hidden.
  • Without traceability of what entered context and why, a bad decision cannot be debugged after the fact. "The agent knew" and "the agent did not know" are indistinguishable in current logs.

Research agenda

  • Traceability & auditability — A structured record of every context-entering event: tool call, memory hit, file read, subagent response, handover ingest — with source, size, and provenance. Enables post-hoc replay of "what did the agent see" for any decision.
    Without this, failures cannot be classified as "missing info" vs "had info, misused it". These are entirely different fixes.
  • Self-monitoring metrics — Utilization (% of window), turn-level growth rate, compaction events, truncation events, and self-assessed quality (crisp / terse / degraded / empty). Reported in every deliverable; gated at wave boundaries.
    Loud, classified failure is the workspace principle. Silent degradation is the anti-pattern.
  • Repair techniques — Handover-doc-as-checkpointing (compact serialised state), selective re-injection, subagent-scoped fresh windows (dispatch pattern), targeted memory-tool refetch. Pre-pinpoint dispatch — the orchestrator lists the exact paths in the subagent prompt so the subagent skips search entirely — is the cheapest measured dispatch pattern (AGENTS §4). Which repair strategy for which failure class.
    Compaction is not the only tool. A dispatch to a fresh subagent with a curated context is often a better repair than in-place compaction.
  • Compaction quality — Measurable: does post-compaction behaviour match pre-compaction on a held-out probe set? Compaction-diff receipts as first-class artifacts.
    Compaction is trusted by default today. It should be measured.
  • Search-subagent pattern (MoE per expert) — A dedicated agent per MCP / expert (chunkhound, serena, codesearch, context7, cloudflare-docs, svelte-docs, playwright, etc.) that fans out in parallel, dedupes overlapping hits, structures results, and returns organized context to the working agent. Latency is the cost; structured verifiable context is the payoff. Ties directly to ozzydev-native-search-mcp (see /research/moe-search-router).
    One question in, one fused answer out — the working agent never sees raw noise, only ranked structured evidence with per-item provenance. The primary weapon against context bloat.

The search-subagent pattern (MoE per expert)

A dedicated agent per MCP or expert fans out in parallel, dedupes overlapping evidence, structures the result, and returns organized context to the working agent. The working agent never sees raw noise — only ranked, structured evidence with per-item provenance. Latency is the explicit cost; structured verifiable context is the payoff. This is the direct tie-in to the ozzydev-native-search-mcp (see moe-search-router) — context engineering is the demand side of the router's supply.

Test categorization — what can be measured where

  • Locally measurable (experimental-framework) — KPIs the experimental framework can already measure end-to-end within a single ozzydev install: utilization at end-of-turn, compaction event count, self-assessed quality distribution, handover-doc round-trip fidelity on a fixture, subagent context-window utilization at return.
    These land inside the harness; no external infrastructure required.
  • KYM-only (receipt + eval architecture) — Cross-session traceability of what entered context and why (KYM receipts index the events); cross-team baselining (compare context strategies across operators); bandit-scale experiments (which repair strategy wins on a distribution of failures). Requires KYM signed receipts + evaluator pool.
    The framework can measure a single run; only the receipt/eval architecture can measure a strategy at scale across sessions and teams. This is the second-tier gap the experimental-framework page also identifies.

Future work

  1. Enumerate representative ceiling-hit incidents in detail (turn, tool, size, recovery path) as fixture cases.
  2. Draft the utilization + quality reporting schema (fields, thresholds, deliverable slot).
  3. Design the compaction-diff receipt format and where it plugs into the KYM receipt store.
  4. Sketch the MoE search-subagent fan-out prompt template (per-expert) and the fusion contract.
  5. Cite the prior art (Anthropic context-window guidance, LangGraph checkpointing, RAG-eval, Voyager retrieval, receipt-based agent audit).
  6. Register KPIs on the experimental-framework matrix; flag KYM-only ones as second-tier.

Sources to gather

  • Anthropic — context window & long-horizon agent guidance
  • LangGraph — persistence, checkpointing, thread-scoped memory
  • Cognition — Devin session memory architecture (public writeups)
  • RAG eval literature — faithfulness, groundedness, retrieval-quality metrics
  • Voyager — retrieval + skill compounding (context reuse angle)
  • MemGPT (arXiv 2310.08560) — OS-style paging over LLM context
  • Anthropic — Multi-agent research system (Claude subagent orchestration writeup)
  • Prior Nexartis pages: moe-search-router, experimental-framework, harness-bandit-experiments, agentic-velocity