Skip to main content

    Context Hygiene

    Keep an AI agent's working memory clean using four moves: Write, Select, Compress, Isolate.

    Every AI model has a finite context window — the working memory it uses to reason. Fill it with rejected drafts, verbatim tool dumps, or paste-storms and the model starts drifting: repeating itself, forgetting exact numbers, or re-asking questions you already answered. The Hygiene panel in the Prompt Composer helps you spot and fix that.

    ℹ️Where to find it

    The Hygiene panel sits next to the Token Counter in the Prompt Composer and Practice Lab. Click it any time to see budget, pollution sources, and suggested moves.

    The four moves

    1. Write

    Save stable, reusable knowledge outside the window — into the Palace and Context Cards. If you'd re-explain it tomorrow, it belongs in a Card, not the prompt.

    2. Select

    Pull in only what the next step needs. 3–5 highly relevant cards beat 30 vaguely related ones. Cards are ranked by their Palace role: rules, glossary, decisions, source, style.

    3. Compress

    Turn old turns into decision-preserving summaries. Keep IDs, paths, URLs, exact numbers. Drop verbatim tool payloads and rejected paths. Every compression is logged for EU AI Act Art. 50 disclosure.

    4. Isolate

    One agent doing everything drags every phase into every other phase. Split into a Workflow with per-step input/output contracts — each step sees only what it declared.

    How the panel helps

    1

    Read the budget

    Green under 40%, amber to 70%, red beyond. Target under 40% — leaves room for the model's reasoning.

    2

    Fix pollution sources

    The panel flags oversized blocks, duplication, rejected-draft markers, and verbatim tool output. Each flag names the suggested move.

    3

    Apply the suggested move

    Compress heavy blocks, detach duplicate Cards, move stable material into the Palace, or split into a workflow with contracts.

    4

    Re-check

    The panel updates live as you edit. Ship the prompt when you're back to green.

    💡Compression preserves what matters

    One-click Compress produces a structured note: decisions, open questions, artifacts and refs, rejected paths, next step. IDs, paths, and URLs survive verbatim — the model never loses a reference it will need later.

    Isolate with Workflows

    Workflows now accept per-step input and output contracts. A step declares which prior outputs and Cards it may see; anything else is filtered out before the model call. This is the Isolate move as a hard product rule, not a suggestion.