The Research Report
Lazy-Loaded Procedural Policy: The Architecture That's Reshaping How We Build Agents
There's a pattern spreading through agent engineering right now. It showed up independently in at least three places. It has production data. It has vendor feature requests stacking up on GitHub. And until this month, it didn't have a name.
Bechir Trabelsi gave it one on April 14: lazy-loaded procedural policy. The name stuck because it names something teams were already doing without realizing it was a pattern.
Here's what it is, why it matters, and how to use it.
The Problem: Your System Prompt Is a Landfill
Most agent teams start clean. A system prompt with a clear role, a few tools, some guardrails. Then you add exception handling. Domain rules. Escalation logic. Formatting constraints for different output types. Compliance notes. Edge-case procedures. A few sprints later, the system prompt has become a landfill.
Every heartbeat, every turn, every API call re-ingests that entire prompt. Whether the agent is handling a simple greeting or a complex multi-step workflow, it pays the full token cost. The agent drowns in instructions it doesn't need for the task at hand.
The numbers are stark. Claude Code issue #19105 measured a fresh "hi" message costing roughly 53,000 tokens before any conversation begins. Of that, about 35,000 tokens are controllable content that loads whether you need it or not: memory files, agent definitions, skill descriptions. OpenClaw issue #29267 reports that 87 skills push baseline context to 165,000 tokens out of a 200,000-token window. That leaves 35,000 tokens of working space. For the entire conversation.
This isn't a marginal problem. It's the central bottleneck in agent engineering today.
The Pattern: Two Layers
Lazy-loaded procedural policy splits your agent's instructions into two layers.
Layer one: the constitutional base. This stays in the system prompt permanently. It contains the agent's role, mission, non-negotiable safety rules, and high-level operating principles. Think of it as the constitution. It's small, stable, and never changes per scenario.
Layer two: procedural overlays. These are scenario-specific rules loaded on demand through tool calls. The agent recognizes a situation, calls a rule tool like getrefundrules() or recall_instruction(intent="handle complaint"), and receives only the instructions relevant to that moment. When the scenario passes, the loaded rules don't persist into the next heartbeat.
This is not prompt compression. It's an architectural shift. The system prompt owns invariants. Tools own conditionals.
The Production Data
In early May, the stigmem project published results from a shadow audit across two production agents. They ran 14 heartbeats each with both eager loading and lazy discovery operating in parallel. Zero behavior changes. Pure measurement.
CEO agent:
- Eager baseline: 3,190 tokens per heartbeat
- Lazy-loaded median: 415 tokens per heartbeat
- Reduction: 87%
- Coverage: 100% after keyword tuning (heartbeats 4-14)
- Regressions: 0
CTO agent:
- Eager baseline: 1,129 tokens per heartbeat
- Lazy-loaded range: 356-565 tokens per heartbeat
- Reduction: 50-69%
- Coverage: 100% after keyword tuning (heartbeats 4-14)
- Regressions: 0
These are not synthetic benchmarks. Both agents operate in production. The CEO agent manages task delegation, board-level review, and company governance. The CTO agent handles architecture decisions, code review, CI/CD, and engineering hiring. The shadow audits ran across real heartbeats, real tasks, real outputs.
The key insight: the CTO team applied lessons from the CEO run on day one. They started with max_chunks=4 and pre-tuned exit keywords. Multi-agent rollouts get cheaper over time. Lessons transfer.
The Keyword Lesson
Both audits uncovered the same design error independently.
The CEO agent had a chunk called HEARTBEAT-9-exit. It was a 32-token wrap-up procedure critical for every heartbeat. Its load triggers described the content: "exit, comment, before, exiting, assignments, valid, mention." None of these matched what the agent actually said when it needed the chunk. The agent said things like "wrap up this task" or "post a comment and finish."
The CTO agent had a chunk called work-standards. Its triggers listed "commit, bug, done, task." A code-review intent produced zero matches.
Same root cause both times. Same fix both times. Different chunks, different agents, same error.
The rule: Load triggers should describe the intents and situations that require a chunk, not the content of the chunk itself.
Add the natural-language verbs and phrases your agents actually use when they need information. Completion-phase chunks, safety constraints, and task-execution standards are all systematically under-served by keyword lists derived from their own content. The stigmem migration tool now flags these patterns and suggests intent-derived synonyms automatically.
The Vendor Requests
The pattern has been bubbling up through GitHub issues across multiple platforms. Three significant ones:
Claude Code (#19105) proposes a full lazy-loading architecture for token optimization. The issue lays out a five-part plan: lazy-loading memory files via an index-based retrieval system, lazy-loading agent definitions with dynamic schemas, lazy-loading skill definitions, sub-agent context inheritance control, and usage-based tool pruning. The total estimated reduction: ~70% of baseline context. The issue frames it with a brain analogy: "The current architecture is like a human who recites their entire autobiography before every conversation."
OpenAI Agents SDK (#2906) requests first-class support for lazy-loading instruction skills in plain agents, not just sandbox-backed ones. The current SDK supports lazy skills only through SandboxAgent and LocalDirLazySkillSource, which ties the mechanism to sandbox sessions and workspace materialization. Issue author Sujeeth Shetty asks for InstructionSkillRegistry on regular Agent objects, with both filesystem path and application-provided loader callback modes. The goal: a coordinator agent keeps a small base prompt, sees a registry of available skills by name and description, and loads full instructions only when a specific flow requires them.
OpenClaw (#29267) describes the skill-listing bottleneck. With 87 skills installed, baseline context hits 165,000 tokens. The proposed solution adds a skillLoading: "lazy" option per agent. Skills are not listed in the system prompt at startup. Instead, the agent is told a skills catalog is available and calls a built-in list_skills() tool on demand. Lazy loading would give agents approximately 4x more working context versus the fully-loaded baseline while preserving full skill awareness.
Each issue approaches the same problem from a different angle. Claude Code targets memory files and context assembly. OpenAI Agents SDK targets instruction modules for coordinator patterns. OpenClaw targets the skill metadata bottleneck. All three converge on the same architectural principle: don't preload what you can load on demand.
Existing Implementations in the Wild
The pattern isn't theoretical. Production systems already use it without naming it.
OpenAI Codex Skills use progressive disclosure. The system starts with lightweight metadata for each skill, then loads the full SKILL.md instructions only when the agent decides to use that skill. Instructions are not injected upfront. They load on demand.
Google's Maps MCP toolkit includes a retrieve-instructions tool whose explicit purpose is to provide system instructions before certain other tools are used. That is a production example of instructions as retrievable runtime context, not static prompt text.
Claude's Agent SDK supports progressive disclosure for skills. The system loads skill metadata (name and description) into the prompt. The full content loads only on invocation. Stéphane Derosiaux documented this pattern in detail: a Datasette skill containing 15,000 tokens of API documentation, testing patterns, and packaging instructions loads just 120 tokens at startup. Full content only enters context when someone asks to build a plugin.
The Instruction-Tool Retrieval paper (ITR) proposes retrieving only the minimum instruction fragments and smallest necessary tool subset at each step, rather than carrying everything through the agent loop. Anthropic's context engineering guidance makes the same case from a different angle: the question shifts from "what is the best prompt?" to "what is the best context assembly strategy?"
The Central Trade-off: Recognition Risk
Every architecture has a failure mode. Monolithic prompts suffer from overload. Lazy-loaded architectures suffer from recognition risk.
When scenario-specific rules live outside the always-on prompt, the agent might fail to realize it should load them. A monolithic prompt drowns the model in instructions, but at least those instructions are always present. A lazy-loaded architecture relies on the model recognizing that a situation calls for specific rules.
This is the trade-off. The question isn't whether lazy loading is elegant. It's whether scenario detection is reliable enough for your domain.
For low-stakes use cases, letting the agent self-detect works fine. For high-stakes systems, self-awareness alone is not enough. You need hardening.
How to Harden It
Three upgrades make the pattern production-ready.
Return structured rules, not prose blobs. Instead of a wall of text, have rule tools return structured fields with named properties. Applicability conditions, prerequisites, must-do lists, must-not-do constraints, required evidence, output contracts, and escalation triggers. Structured payloads are easier for the model to apply consistently than paragraphs it has to parse.
Persist loaded rules in graph state. Once a playbook is loaded, store it in the agent's state so later steps don't need to reload it. In LangGraph, this means adding a loaded_policies key to your state schema. Load once, reference many times.
Add a router and a validator. A router classifies the input and force-loads likely rule sets before the main reasoning loop begins. It doesn't rely on the agent's in-flight self-awareness. A validator inspects the final answer and asks whether any required rule sets were not consulted. Silent misses, cases where the agent handled a regulated scenario without knowing it was regulated, are the most dangerous failure mode. The validator catches them.
Together, these three upgrades eliminate the reliance on the agent's ability to spontaneously recognize that it needs specific rules. The router handles proactive loading. The validator handles retrospective checking. The agent's own detection is a bonus, not the primary mechanism.
Practical Implementation
If you want to implement this pattern today, here's a concrete starting point.
Step one: Audit your system prompt. List every instruction in it. Mark each one as either invariant (must always be present) or conditional (only matters in specific scenarios). You'll likely find that 60-80% of your prompt is conditional.
Step two: Extract conditional rules into tools. Each rule set becomes a function the agent can call. getrefundrules(), getescalationrules(), getsqlsafety_rules(). Each returns structured output, not prose.
Step three: Build a manifest or index. Your agent needs a compact way to know what rule sets exist without loading them all. A lightweight index of rule set names, descriptions, and trigger keywords. Under 400 tokens for the whole index.
Step four: Add recall mechanism. A tool like recallinstruction(intent, maxchunks) that takes the agent's current intent, matches it against the manifest keywords, and returns the top-scoring chunks.
Step five: Shadow audit before flipping. Run your agent with both eager loading and lazy discovery in parallel. Log what each would have loaded. Check coverage and regressions. The stigmem team ran 14 heartbeats per agent before switching. Do at least that many.
Step six: Tune keywords from real usage. Your initial keyword list will be wrong. Plan for it. Watch what the agent actually says when it needs a rule set, and add those phrases as triggers. Content-derived keywords systematically miss real usage patterns.
The Bigger Picture
Lazy-loaded procedural policy sits at the intersection of several existing ideas without being fully captured by any of them.
Instruction-Tool Retrieval minimizes instruction fragments per step. Dynamic tool exposure serves only relevant tools. Progressive disclosure loads metadata first, content on demand. Rules-as-tools packages logic as callable modules.
What makes this pattern distinct is the ownership question. It says the system prompt owns invariants. Tools own conditionals. The architectural boundary is deliberate and explicit.
This matters because the question in agent engineering is shifting. It's no longer "what is the best prompt?" It's "what is the best context assembly strategy?" How do you decide what the model sees at each moment? How do you keep the base stable while making scenario-specific rules available on demand? How do you do this without introducing new failure modes that are worse than the problem you started with?
Lazy-loaded procedural policy gives a concrete answer. Keep the constitution small. Load the playbooks when needed. Route proactively. Validate retrospectively. Trust the pattern, verify with data.
The production numbers speak. The vendor requests are piling up. The implementations already exist in the wild, waiting for a name. Now they have one.
Citations
- Bechir Trabelsi, "Stop Bloated Agent Prompts: A Pattern I Call Lazy-Loaded Procedural Policy," Medium, April 14, 2026. https://bechirtr97.medium.com/stop-bloated-agent-prompts-a-pattern-i-call-lazy-loaded-procedural-policy-b6ade44dd1aa
- stigmem (Eidetic-Labs), "Stop Preloading Everything: How We Cut AI Agent Context by 50–87% with Lazy Discovery," DEV Community, May 4, 2026. https://dev.to/offbyonce/stop-preloading-everything-how-we-cut-ai-agent-context-by-50-87-with-lazy-discovery-36ag
- stigmem v1.0 launch post: https://dev.to/offbyonce/stigmem-v10-a-federated-knowledge-fabric-for-ai-agents-open-source-lf8
- Claude Code issue #19105, "Feature Request: Lazy-Loading Architecture for Token Optimization (~70% reduction possible)": https://github.com/anthropics/claude-code/issues/19105
- OpenAI Agents SDK issue #2906, "Lazy-Loaded Instruction Skills for OpenAI Agents SDK": https://github.com/openai/openai-agents-python/issues/2906
- OpenClaw issue #29267, "Feature: Per-agent lazy/on-demand skill loading to reduce system prompt token usage": https://github.com/openclaw/openclaw/issues/29267
- Stéphane Derosiaux, "How Lazy-Loaded Prompt Engineering is Becoming the Standard Pattern Across Claude, ChatGPT, and Gemini (Skills)," Medium/AI Advances, December 21, 2025. https://sderosiaux.medium.com/how-lazy-loaded-prompt-engineering-is-becoming-the-standard-pattern-across-claude-chatgpt-and-385955de3169
- Instruction-Tool Retrieval (ITR) paper: "Dynamic System Instructions and Tool Exposure for Efficient Agentic LLMs" (arXiv)
- Anthropic, "Effective Context Engineering for AI Agents"
- OpenAI, "Practical Guide to Building Agents"
- Google Maps MCP toolkit
retrieve-instructionspattern - Logic Agent paper: callable logic-rule tools for LLM agents (arXiv)
Suggested Title
Lazy-Loaded Procedural Policy: The Two-Layer Agent Architecture Going Mainstream
Word Count
~2,150 words (body text)
Fact-Check Notes
- The stigmem production data (50-87% reduction, zero regressions, 14 heartbeats per agent) comes directly from their published shadow audit on DEV Community. The specific numbers (CEO: 3,190→415t, 87% reduction; CTO: 1,129→356-565t, 50-69% reduction) match their tables.
- The Claude Code #19105 baseline figure of ~53k tokens for a "hi" message and ~35k controllable is stated in the issue itself. This is user-reported, not officially benchmarked.
- The OpenClaw #29267 figure of 165k/200k tokens with 87 skills is from the issue author's specific deployment. This varies by setup.
- The Bechir Trabelsi post date is listed as April 14, 2026 on Medium. The task brief says May 3. The Medium page shows April 14. I used the Medium page date.
- The stigmem DEV.to post is dated May 4, 2026, matching the brief.
- OpenAI Agents SDK issue #2906 status shows as "closed" in search results. The specific API proposal details (InstructionSkillRegistry, loader callbacks) are from the issue itself but are not yet implemented in the SDK.
- OpenClaw issues #26301, #3395, #39945, and #64760 are additional related feature requests for lazy skill loading, showing the pattern has broad community demand beyond #29267.
- The ITR paper and Anthropic context engineering guidance are referenced by Trabelsi but not directly fetched. Claims about their content are based on his summary.
- The Stéphane Derosiaux Medium post was independently fetched and confirms the skills/progressive-disclosure pattern across Claude, ChatGPT, and Gemini. The 35% context reduction and 10-20% discovery failure rate figures are from his article.