Context Efficiency Optimizer
Reduce context cost with caching, masking, compaction, and partitioning while preserving answer quality.
The skill mainly gives guidance for context compaction, masking, budgeting, and caching. It shows no credential access, outbound writes, or destructive defaults, and it warns that production systems need model-specific tokenizers. However, it does not specify sensitive-data handling, permission boundaries, storage isolation, user confirmation, rollback, or source attribution, so points are deducted.
SKILL.md, the reference, and the script cover the main paths and mention several failure cases, but thresholds conflict (70% in multiple recommendations versus 80% in the script), categorization is brittle, token estimation and summarization are heuristic, and ObservationStore can evict referenced content. Static review also finds no tests targeting this script, so the score is capped below the static ceiling and further reduced.
Activation conditions, non-fit boundaries, four strategies, and some platform/runtime prerequisites are reasonably clear for context-constrained agent systems. Inputs and outputs, runtime compatibility, Chinese-language use, and mainland-China reachability are not specified, and some advice depends on controllable inference infrastructure, so points are deducted.
The material has clear structure, progressive reference disclosure, examples, metrics, pitfalls, integration guidance, version, update date, and an MIT license. Maintenance ownership, changelog, dependency/install notes, citations, and formal tests for this skill’s script are incomplete, so it does not receive full marks.
The skill can directly guide budgeting, masking, compaction, caching, and partitioning, and the script exposes reusable demonstration APIs. However, summarization is mostly heuristic extraction or truncation, token counting is approximate, cache metrics are illustrative, and representative validation or comparative evidence is absent; under static calibration the score is limited to 7 or below.
The script, reference, examples, and repository-level CI provide some auditable material, but the CI paths shown do not test skills/context-optimization/scripts/compaction.py. Performance targets are largely unsupported claims, and the skill does not provide concrete verifiable external citations. Static evidence is therefore limited.
- Do not use the example heuristics for summarization, token counting, or cache metrics as production decision logic without model-specific measurement and quality regression tests.
- Reconcile the 70% versus 80% optimization thresholds and define explicit policies for external storage, reference eviction, sensitive tool outputs, and recovery.
- Confirm runtime support, data isolation, and net cost benefit before adopting KV-cache or partitioning guidance; Chinese-language and mainland-China reachability are not evidenced.
What does this skill do, and when should you use it?
This skill helps agent builders optimize limited context windows through token budgeting, retrieval scoping, and selective information preservation. It presents four prioritized techniques: KV-cache optimization, observation masking, compaction, and context partitioning. The material includes activation thresholds, budget policies, performance targets, decision tables, examples, and failure modes. It is a fit for production agent systems where context cost, latency, or effective capacity is a constraint.
It analyzes the relative contribution of tool outputs, message history, and retrieved documents; allocates token budgets; and defines triggers based on utilization, debugging state, and quality signals. It recommends placing stable prompt content in the prefix for KV-cache reuse, replacing resolved verbose observations with retrievable references, compacting over-budget context into summaries, and splitting oversized tasks across isolated sub-agent contexts. It also specifies metrics for token reduction, cache hit rate, quality impact, latency, and net savings after partitioning overhead.
- A production agent receives verbose tool results that dominate its context and needs to reduce token usage without losing retrievability.
- A stable workload repeats similar prompts and needs higher KV-cache reuse to reduce cached-token cost and latency.
- A long-running conversation approaches its context limit and needs selective compaction that preserves goals, constraints, decisions, and active errors.
- A complex task contains several independent subtasks and requires a cost-aware decision about using isolated sub-agent contexts.
- An agent platform needs explicit budgets and trigger rules for tool outputs, retrieved documents, conversation history, and reserved capacity.
What are this skill's strengths and limitations?
- Provides a clear optimization order, thresholds, and budget-management guidance.
- Covers caching, observation masking, compaction, and multi-agent context partitioning in one workflow.
- Emphasizes measurement through token, quality, latency, and cache-hit metrics.
- Documents concrete risks such as masking debugging errors, premature compaction, and coordination overhead.
- The source does not report a standalone test suite or benchmark for this individual skill.
- The performance figures are targets and guidance, not guarantees validated across models and runtimes.
- KV-cache gains require runtime support for prefix caching, while partitioning requires an available multi-agent coordination mechanism.
- The skill does not define a specific external storage, retrieval, or host-integration implementation.
How do you install this skill?
After obtaining the repository, copy the entire skills/context-optimization directory into the host project's Agent Skills directory, for example: mkdir -p .codex/skills && cp -R skills/context-optimization .codex/skills/. Preserve the directory layout and its SKILL.md; do not flatten the skill into a standalone Markdown file. The README does not provide one universal installation command for this individual skill across all hosts.
How do you use this skill?
In an Agent Skills-compatible host, describe a context-efficiency task such as: Analyze this agent's context composition, define token budgets, and design triggers for observation masking, stable KV-cache prefixes, and compaction. Activate it when context budgets, observation masking, prefix caching, retrieval scope, or context partitioning are relevant. The source does not document a host-specific manual activation command.