context-engineering

Budgets and manages which tokens enter an agent's context window across prompts, retrieval, and memory.

Updated Aug 2, 2026
One-click install
npx skills add https://github.com/dperussina/function2agent --skill context-engineering-dperussina
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: context-engineering
Source: https://github.com/dperussina/function2agent/tree/main/.cursor/skills/context-engineering
Command: npx skills add https://github.com/dperussina/function2agent --skill context-engineering-dperussina

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Agents degrade as their context window fills: they loop, repeat actions, chase nonexistent files or endpoints, pick the wrong tool, and contradict themselves over long runs. This Skill provides a framework for diagnosing those failures and deciding exactly which tokens earn a place in the window at each step. ## Core Features & Use Cases - Failure-mode diagnosis: Classify agent misbehavior into the four standard modes — poisoning, distraction, confusion, and clash — each with distinct mitigations. - Context budgeting and reclamation: Plan working budgets as a fraction of the rated window, and apply the raw → compaction → summarization preference ordering with correct trigger placement around 70–75% of budget. - System prompt, retrieval, and memory design: Guidance on what belongs in a system prompt, when agentic search beats embeddings, the four memory tiers (working, episodic, semantic, procedural), and subagent context isolation. - Use Case: An agent loops on the same failed tool call after 40 turns. Use this Skill to identify distraction as the failure mode, cap history, add a no-progress detector, and compact earlier turns while keeping recent tool calls raw. ## Quick Start Ask the agent to diagnose why my long-running agent keeps repeating itself and to propose a context budget and compaction strategy for it.

Frequently Asked Questions about context-engineering

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

FAQPage Schema
How do I stop an AI agent from looping or repeating itself?▼

Looping is the distraction failure mode: the model over-weights its history and repeats prior actions. Compact aggressively, cap history length, and add a no-progress detector as a hard stop rather than enlarging the context window.

What is the difference between context compaction and summarization?▼

Compaction is reversible: it strips information that still exists in the environment, like file contents that can be re-read. Summarization is lossy: an LLM rewrites history into prose and anything omitted is gone. Always prefer compaction first.

When should I trigger context compaction in an agent?▼

Trigger compaction at roughly 70–75% of your intended working budget, which is itself a fraction of the model's rated window, not at the API limit. Keep the most recent tool calls raw through any summarization to preserve the agent's working rhythm.

Should I use embeddings or agentic search for code retrieval?▼

Agentic search with grep, glob, and read_file often beats embedding search for code and structured corpora because the model iterates against ground truth. Reserve embeddings for genuinely unstructured, large corpora, and fetch fewer, higher-precision chunks.

Why does my agent contradict itself after adding long-term memory?▼

That is the clash failure mode, usually caused by your own memory system injecting statements that contradict the current thread. Timestamp and rank memories by recency and authority, remove superseded entries, and set a high bar for promoting facts into durable memory.

When should I use subagents for context isolation?▼

Subagents give each task a clean window: the parent sends a self-contained brief and receives a short result, never seeing the child's exploration tokens. Isolation works for read-heavy exploration but fails for write-heavy interdependent work where findings and writes are the same object.