lauren-framework/lauren-ai/context-window-management
Claude Code and agent skill by lauren-framework/lauren-ai
- community
Checking that the SKILL.md file is still in the repository.
Shows how to manage an agent's context window using ShortTermMemory sliding-window trimming and manual message truncation helpers. Use when limiting token usage, implementing conversation history pruning, or estimating prompt sizes before sending to the LLM.
Install
npx vskill@latest install lauren-framework/lauren-ai/context-window-managementSKILL.md
The same SKILL.md was published earlier as lauren-framework/lauren-ai/context-window-management.
Usecodemap find "SymbolName"to locate any symbol before reading — it givesexact file + line range and is faster than grep across the whole repo.
Agent Context Window Management & Trimming
Overview
ShortTermMemory automatically trims the oldest non-system messages when the conversation grows beyond max_tokens. Configure it per-agent via @agent(memory=ShortTermMemory(max_tokens=N)).
Configuring a sliding window
ShortTermMemory.messages() returns a trimmed snapshot without mutating the internal buffer. The oldest non-system messages are dropped first.
Manual trim helper
Token estimation
ShortTermMemory.token_estimate uses the same heuristic internally.
When to use each approach
| Approach | When to use | |
|---|---|---|
ShortTermMemory(max_tokens=N) | Automatic per-run sliding window | |
trim_messages(msgs, max_turns=N) | Manual preprocessing before injecting history | |
memory.trim_to_fit(max_tokens) | Mutate the buffer in-place (use sparingly) |
Full ShortTermMemory API
Reference files
| File | Contents | |
|---|---|---|
src/lauren_ai/_memory/__init__.py | ShortTermMemory implementation | |
src/lauren_ai/_memory/_stores.py | InMemoryConversationStore | |
src/lauren_ai/_agents/_runner.py | Memory creation and restore in run() |
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/context-window-management/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lauren-framework/lauren-ai/context-window-management)