Topic

Context Window Management

All digests tagged Context Window Management

5 Best Practices for Building AI Agent Skills thumbnail

· 13:22

5 Best Practices for Building AI Agent Skills

This guide outlines five best practices for building reliable, secure, and effective AI agent skills. Skills are defined as procedural knowledge packaged in a `skill.md` file that teaches an AI agent specific job functions. Best practices emphasize improving skill triggering via detailed descriptions, grounding content in real domain expertise, managing context window size by using progressive disclosure, enforcing deterministic logic through scripts for critical steps, and rigorously vetting all skills for security vulnerabilities.

Key takeaways

  1. Best Practice 1: Optimize the Skill Description (Triggering) 2:19

    The agent uses the skill's name and description to decide if it should run. The description must be highly informative, stating what the skill does and when it should be used. It is recommended to 'oversell' the description slightly rather than underselling it, as models tend to under-trigger.

  2. Best Practice 2: Build from Real Expertise 5:58

    Skills must contain domain expertise that the model cannot generate on its own. This content should be synthesized from existing artifacts (e.g., old reports, run books, PR feedback). The highest value section in the skill body is often 'gotchas'—environment-specific facts or corrections made during manual execution.

  3. Best Practice 3: Spend Context Wisely 11:15

    The goal is to keep the skill body lean. Since the entire skill body contributes to the context window, only include information the agent wouldn't know otherwise. For large bodies of text, use a dedicated `references` sub-folder and implement 'progressive disclosure,' allowing the agent to open files only when needed.

  4. Best Practice 4: Use Deterministic Scripts for Fragile Steps

    For steps that must be exactly correct (fragile steps), do not rely on the model's probabilistic improvisation. Instead, write deterministic code and place it in a dedicated `scripts` directory within the skills folder. This ensures consistent, reliable execution.

  5. Best Practice 5: Vet Skills Before Running Them

    Treat agent skills like any external dependency package. Because skills can run code and access local file systems or APIs, they must be audited for security flaws (e.g., prompt injection or malware) before deployment.

Watch on YouTube Full article

Paste This Into Claude, Never Hit a Token Limit Again thumbnail

· 20:17

Paste This Into Claude, Never Hit a Token Limit Again

This guide details advanced strategies for minimizing token consumption when interacting with Large Language Models (LLMs) like Claude and Codex. The core problem is 'reused input,' where every subsequent message resends the entire conversation history, leading to massive waste (up to 96% of tokens). Solutions are tiered: Level 1 involves user habits (e.g., editing mistakes instead of re-asking); Level 2 introduces automated tools like the 'Token Saver skill'; and Level 3 utilizes advanced frameworks such as Ringer for local, pre-model request constraint.

Key takeaways

  1. Edit Mistakes Instead of Re-Asking 4:40

    When correcting an AI error or typo, use the edit function rather than starting a new chat thread and stating 'that was wrong.' This prevents unnecessary token accumulation. (04:40)

  2. Start Clean Tasks for Job Changes 15:35

    When switching to a new, specific task, start a fresh chat thread. Continuing long conversations is good for focus but highly token-intensive and increases the volume of 'reused input.' (15:35)

  3. Carry Forward Artifacts, Not Arguments 15:35

    In multi-step processes (e.g., research followed by writing), only pass the final artifact or result from Stage A to Stage B. Do not include all previous drafts, criticisms, or rejected sources. (15:35)

  4. Use Local Retrieval and Caching

    Whenever possible, perform searches locally rather than relying on the model to search files, as this is a massive token burner. Also, use external databases (like OpenBrain) for frequently needed data points to avoid recalculation. (18:51)

  5. Enforce Hard Token Limits

    For critical workflows, use an intermediary tool like Ringer to enforce hard limits on the input/output packet size, ensuring predictable resource usage. (18:51)

Watch on YouTube Full article