feat(skills): add lazy load mode to reduce startup token usage - #19174
feat(skills): add lazy load mode to reduce startup token usage#19174LastKnight1881 wants to merge 1 commit into
Conversation
Add a `skills.lazy` config flag (default: false). When enabled, the full
skills index is not injected into the system prompt at session start.
Instead, a compact notice instructs the agent to call skill_view()/
skills_list() on demand when a task matches a known workflow.
This addresses context bloat for agents with large skill libraries
(100+ skills). On a typical install the skills index adds ~3-5k tokens
to every session; lazy mode reduces that to ~60 tokens.
Config usage:
skills:
lazy: true
Existing behavior is preserved when the flag is absent or false.
|
14 lines in If not superseded: the approach of gating skill loading behind a config flag ( Recommend: check all call sites of |
|
Thanks for the PR. Closing based on a standing design rule in our contributor guide: for tools that serve instructional / procedural content (skills, system prompts, playbooks), full-content loading should be the default AND only option. Models will use any excuse to read less — if we add a lazy mode, they'll use it, skip the bulk of the content, and miss critical pitfalls and verification steps that only appear later in a SKILL.md. The context-pressure concern is real for 32k–64k context models, but the right lever there is skill set curation (fewer installed skills / For reference: the same pattern was rejected in April 2026 when pagination was proposed for |
Summary
Adds a
skills.lazyconfig flag (default:false) to reduce token usage at session startup for agents with large skill libraries.Problem
The full skills index is injected into every session's system prompt unconditionally. On a typical install with 100+ skills across 30+ categories, this adds ~3,500–5,000 tokens to every session. For local models with smaller context windows (32k–64k), this causes aggressive context compression after only a handful of messages.
Solution
When
skills.lazy: trueis set incli-config.yaml, the full skills index is replaced with a compact ~60-token notice:The agent retains full access to all skills via
skill_view()andskills_list()— it just doesn't have them all in context at startup.Config
Changes
run_agent.py: Readskills.lazyfrom config intoself._skills_lazy; gatebuild_skills_system_prompt()on it; inject compact notice when lazy mode is active.cli-config.yaml.example: Document the newlazyflag with comments.Backwards compatibility
Default is
false— existing behavior is fully preserved for all users who don't opt in.