Define Context Compression Rules for Long-Running AI Agents
Create a formal policy for compressing conversation history and managing agent memory to ensure long-running threads remain efficient without losing critical task data.
Agent prompt for Claude and ChatGPT
Prompt
mkdir -p .agents/skills/define-context-compression-rules-for-long-running-ai-agents && curl -sL "https://prompts-gpt.com/prompts/define-context-compression-rules-for-long-running-ai-agents/raw" -o .agents/skills/define-context-compression-rules-for-long-running-ai-agents/SKILL.md---
name: define-context-compression-rules-for-long-running-ai-agents
description: "Create a formal policy for compressing conversation history and managing agent memory to ensure long-running threads remain efficient without losing critical task data."
---
# Define Context Compression Rules for Long-Running AI Agents
Create a formal policy for compressing conversation history and managing agent memory to ensure long-running threads remain efficient without losing critical task data.
## Prompt
```
Act as a Lead AI Architect. Draft a set of rules for managing context windows in long-running agent threads. Focus on compression, memory compaction, and state recovery. Follow these rules: 1. Define specific triggers for summarization based on token usage thresholds. 2. Establish criteria for which messages must remain immutable vs. which can be summarized. 3. Include a protocol for handling failure recovery and state serialization. 4. Use clear, non-technical language that developers can implement directly. Output format: 1. Compression Triggers (list). 2. Message Retention Policy (table with columns: Message Type, Status, Retention Rule). 3. Memory Compaction Protocol (numbered list). 4. Failure Recovery Steps (numbered list). This is technical architectural guidance; review against your specific system constraints before implementation.
```
## Usage Notes
Use this when your AI agents are losing context or hitting token limits in long-running sessions. Paste this prompt into Claude, ChatGPT, or Gemini. No additional input is needed; the model will generate a standardized framework for your development team to apply to your agent orchestration layer.
Act as a Lead AI Architect. Draft a set of rules for managing context windows in long-running agent threads. Focus on compression, memory compaction, and state recovery. Follow these rules: 1. Define specific triggers for summarization based on token usage thresholds. 2. Establish criteria for which messages must remain immutable vs. which can be summarized. 3. Include a protocol for handling failure recovery and state serialization. 4. Use clear, non-technical language that developers can implement directly. Output format: 1. Compression Triggers (list). 2. Message Retention Policy (table with columns: Message Type, Status, Retention Rule). 3. Memory Compaction Protocol (numbered list). 4. Failure Recovery Steps (numbered list). This is technical architectural guidance; review against your specific system constraints before implementation.Example output
Tips and common edits
Why this works
- Forces the model to categorize data types, preventing loss of vital logic.
- Uses a structured table to clarify complex retention rules for developers.
- Provides actionable, step-by-step protocols for both maintenance and failure recovery.
Use this when your AI agents are losing context or hitting token limits in long-running sessions. Paste this prompt into Claude, ChatGPT, or Gemini. No additional input is needed; the model will generate a standardized framework for your development team to apply to your agent orchestration layer.
Common edits
- Adjust the token threshold based on the specific model context window (e.g., 128k vs 200k).
- Add specific data privacy requirements if your agents handle PII or sensitive user information.
Reuse it: Use in a workflowAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
More like this
Design Idempotent API Tool Schemas and Retry Policies
Generate robust JSON tool schemas for AI agents that enforce idempotency, define safe retry status codes, and specify clear error recovery strategies for external APIs.
Design Mock Tool Fixtures for Agent Trajectory Testing
Generate deterministic mock tool responses to test agent decision trees, edge-case failures, and schema-breaking payloads without live API usage or costs.
Map AI Agent State Payloads and Handover Contracts
Generate a strict Pydantic state schema for agent pipelines that defines delta updates, discard rules, and structured rejection envelopes for handoffs.
Triage Dead-Letter Queue Logs for Failed AI Agents
Sort unhandled agent run failures into an actionable classification table separating tool downtime, invalid schema calls, and missing user context.
Parallel Git Worktree Task Split with Interface Contracts and Merge Order
Turns a pasted feature spec into independent coding-agent tasks with file ownership, interface contracts, a merge order and a done command for each task.
Create Error Handling Contracts for AI Agents
This prompt transforms raw stack traces into structured error envelopes that provide agents with specific remediation steps and valid parameter constraints for self-correction.
- Create Role-Based Tool Gating Matrix for AI Agents
- Design Human-in-the-Loop Escalation Gates for AI Agents
- Evaluate AI Agent Performance for Infinite Loops and Goal Drift
- Subagent Fan-Out Plan for a Large Codebase Migration
- Agent Run Post-Mortem: Trace Root Cause and Prompt or Tool Fixes
- DAG Scheduler with Fan-Out/Fan-In Barriers and Resumable Run Ledger for Agent Pipelines