context-optimization

Applies compaction, observation masking, KV-cache optimization, and partitioning to extend effective context capacity.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill context-optimization-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-optimization
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/context-optimization
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill context-optimization-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Long-running agents and extended conversations exhaust limited context windows, driving up token costs, latency, and response degradation. This Skill provides concrete techniques to reduce token usage while preserving the information that matters. ## Core Features & Use Cases - Compaction Strategies: Summarize tool outputs, old conversation turns, and retrieved documents when context approaches limits, targeting 50-70% token reduction with minimal quality loss. - Observation Masking: Replace verbose tool outputs (often 80%+ of agent token usage) with compact references that remain retrievable on demand. - KV-Cache Optimization: Order context elements with stable content first to maximize prefix cache hits and reduce cost and latency. - Context Partitioning: Split work across sub-agents with isolated contexts, then aggregate validated results. - Use Case: A production agent system hits 80% context utilization mid-task. Apply trigger-based compaction to summarize early turns, mask stale tool outputs, and continue the task without losing critical decisions. ## Quick Start Use the context-optimization skill to reduce token usage in my long-running agent conversation that is approaching its context limit.

Frequently Asked Questions about context-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce token usage in long LLM conversations?

Apply compaction to summarize old conversation turns and tool outputs when utilization exceeds 80%, and mask verbose observations with compact references. Combining these techniques typically achieves 50-70% token reduction with under 5% quality degradation.

What is observation masking in agent systems?

Observation masking replaces verbose tool outputs with compact references once they have served their purpose, since tool outputs often comprise over 80% of agent token usage. Never mask observations critical to the current task or from the most recent turn.

How does KV-cache optimization reduce LLM costs?

KV-cache optimization reuses cached Key and Value tensors across requests sharing identical prefixes, avoiding recomputation. Place stable content like system prompts and tool definitions first, avoid dynamic elements like timestamps, and keep formatting consistent to maximize cache hit rates above 70%.

When should I use context partitioning with sub-agents?

Use partitioning when a task decomposes into independent subtasks that would otherwise accumulate excessive shared context. Each sub-agent operates in an isolated clean context, and the coordinator aggregates validated results after all partitions complete.

What are the limitations of context compaction?

Compaction risks losing details during summarization, so it should preserve key decisions, metrics, and conclusions while discarding filler. Never compress the system prompt, and monitor quality degradation, keeping it under 5% relative to uncompressed baselines.