Mahal Systems

Overview › 3Prompts › b.Caching

Caching

Design for caching and reuse. 2 optimizations.

  1. i.

    Keep the prompt prefix cache-stable

    Put static content (identity, rules, tool definitions) before a boundary and per-turn content (date, state, memory) after it; keep the prefix bit-for-bit identical across turns; strip thinking text from persisted history; and track per-turn cache-miss cost.

    Lower costFaster

    Tier 1 · hygiene · changes context · any agent · 8 sources, 1 measured

  2. ii.

    Mask tools instead of removing them

    When the tools an agent may use change mid-task (by mode, phase or permission), declare every tool once, keep the definitions byte-stable, and restrict the choice another way: OpenAI's allowed_tools or tool_choice "none", Anthropic's appended tool_removal and tool_addition blocks, a decode-time logit mask or grammar on self-hosted models, and a harness check that rejects calls outside the allowed set.

    Lower costFasterMore secureBetter governanceMixed quality

    Tier 3 · tuning · changes context, tool surface · any agent · 11 sources, 5 measured

Before you go...

Build better agents, weekly

Our latest research, performance benchmarks, optimization strategies, and updates around AOT development.

One email a week, nothing else. Unsubscribe anytime.