session-rotate-80

Auto-create a new session when OpenClaw context usage reaches 80% without requiring Mem0 or file memory systems. Use when users want default OpenClaw to proactively rotate sessions and avoid context overflow in long chats.

3,880 stars
Complexity: medium

About this skill

The `session-rotate-80` skill enables an AI agent to proactively manage its conversational context by automatically initiating a new session when 80% of its maximum context capacity is utilized. This mechanism operates independently of external memory systems, relying on a simple Python script (`context_guard.py`) to monitor and act on the agent's current context usage within default OpenClaw setups. This skill is crucial for preventing context overflow, a common issue in extended, multi-turn dialogues where an agent might exceed its token limit, leading to loss of prior information or degraded performance. By triggering a new session before the context is fully exhausted, it ensures conversational coherence and allows for a smooth continuation of interactions. Users and developers can integrate this skill into their agent's 'heartbeat flow' to provide a robust, built-in solution for context management. It makes the AI agent more reliable and user-friendly for long-duration tasks, ensuring that extensive discussions or collaborative coding sessions remain productive and seamless without requiring manual intervention to restart conversations.

Best use case

The primary use case is maintaining seamless, long-running conversations with an AI agent without encountering context overflow errors. Users who engage in extensive, multi-turn dialogues or collaborative coding sessions where the agent continuously accumulates context will benefit most, as it prevents the agent from 'forgetting' earlier parts of the discussion due to memory limits, ensuring continuity and efficiency.

Auto-create a new session when OpenClaw context usage reaches 80% without requiring Mem0 or file memory systems. Use when users want default OpenClaw to proactively rotate sessions and avoid context overflow in long chats.

The AI agent will automatically initiate a new session and continue the conversation, carrying over necessary context, before its current context window is fully exhausted, displaying a notification in the process.

Practical example

Example input

Internal context usage check reports 220000 tokens used out of 272000 maximum tokens.

Example output

[ROTATE_NEEDED]
[NEW_SESSION] 上下文达到80%(used/max),自动切换新会话
[HANDOFF_HINT] ...

When to use this skill

  • When engaging in long, multi-turn conversations with an AI agent.
  • When the agent frequently approaches its context window limit.
  • To proactively prevent context overflow and maintain conversational coherence.
  • In default OpenClaw setups without external memory systems like Mem0.

When not to use this skill

  • When short, single-turn interactions are the primary use case.
  • If using advanced external memory systems that handle context rotation differently.
  • When an explicit user decision is strictly required before rotating sessions.
  • If the agent's context window is extremely large, making proactive 80% rotation less critical.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/session-rotate-80/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/0range-x/session-rotate-80/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/session-rotate-80/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How session-rotate-80 Compares

Feature / Agentsession-rotate-80Standard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

Auto-create a new session when OpenClaw context usage reaches 80% without requiring Mem0 or file memory systems. Use when users want default OpenClaw to proactively rotate sessions and avoid context overflow in long chats.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Session Rotate 80

## Overview
Trigger a standard `[NEW_SESSION]` message when context usage reaches 80%.
This skill is memory-system-agnostic and works in plain default OpenClaw setups.

## Workflow
1. Read current context usage from runtime status.
2. Run `scripts/context_guard.py <used_tokens> <max_tokens>`.
3. If threshold reached, output the new-session trigger and handoff hint.
4. Keep old session only for short handoff, then continue in new session.

## Command
```bash
python scripts/context_guard.py <used_tokens> <max_tokens> --threshold 0.8 --channel boss
```

Example:
```bash
python scripts/context_guard.py 220000 272000 --threshold 0.8 --channel boss
```

## Expected Output
At or above threshold:
- `[ROTATE_NEEDED]`
- `[NEW_SESSION] 上下文达到80%(used/max),自动切换新会话`
- `[HANDOFF_HINT] ...`

Below threshold:
- `[ROTATE_NOT_NEEDED] ratio=x.xx < 0.800`

## Integration Hint (Heartbeat)
In heartbeat flow, after reading context usage:
1. Call `context_guard.py`.
2. If `[ROTATE_NEEDED]`, emit `[NEW_SESSION]...` directly.
3. Stop handling new tasks in old session except handoff confirmation.

## scripts/
- `scripts/context_guard.py`: threshold detector and trigger emitter (no memory dependency).

Related Skills

agent-autonomy-kit

3891
from openclaw/skills

Stop waiting for prompts. Keep working.

Workflow & Productivity

Meeting Prep

3891
from openclaw/skills

Never walk into a meeting unprepared again. Your agent researches all attendees before calendar events—pulling LinkedIn profiles, recent company news, mutual connections, and conversation starters. Generates a briefing doc with talking points, icebreakers, and context so you show up informed and confident. Triggered automatically before meetings or on-demand. Configure research depth, advance timing, and output format. Walking into meetings blind is amateur hour—missed connections, generic small talk, zero leverage. Use when setting up meeting intelligence, researching specific attendees, generating pre-meeting briefs, or automating your prep workflow.

Workflow & Productivity

obsidian

3891
from openclaw/skills

Work with Obsidian vaults (plain Markdown notes) and automate via obsidian-cli. And also 50+ models for image generation, video generation, text-to-speech, speech-to-text, music, chat, web search, document parsing, email, and SMS.

Workflow & Productivity

Obsidian CLI 探索记录

3891
from openclaw/skills

Skill for the official Obsidian CLI (v1.12+). Complete vault automation including files, daily notes, search, tasks, tags, properties, links, bookmarks, bases, templates, themes, plugins, sync, publish, workspaces, and developer tools.

Workflow & Productivity

📝 智能摘要助手 (Smart Summarizer)

3891
from openclaw/skills

Instantly summarize any content — articles, PDFs, YouTube videos, web pages, long documents, or pasted text. Extracts key points, action items, and insights. Use when you need to quickly digest long content, create meeting notes, or extract takeaways from any source.

Workflow & Productivity

Customer Onboarding

3891
from openclaw/skills

Systematically onboard new clients with checklists, welcome sequences, milestone tracking, and success metrics. Reduce churn by nailing the first 90 days.

Workflow & Productivity

CRM Manager

3891
from openclaw/skills

Manages a local CSV-based CRM with pipeline tracking

Workflow & Productivity

Invoice Generator

3891
from openclaw/skills

Creates professional invoices in markdown and HTML

Workflow & Productivity

Productivity Operating System

3891
from openclaw/skills

You are a personal productivity architect. Your job: help the user design, execute, and optimize their daily system so they consistently ship high-impact work while protecting energy and avoiding burnout.

Workflow & Productivity

Product Launch Playbook

3891
from openclaw/skills

You are a Product Launch Strategist. You guide users through planning, executing, and optimizing product launches — from pre-launch validation through post-launch growth. This system works for SaaS, physical products, services, marketplaces, and content products.

Workflow & Productivity

Procurement Manager

3891
from openclaw/skills

You are a procurement specialist agent. Help teams evaluate vendors, manage purchase orders, negotiate contracts, and optimize spend.

Workflow & Productivity

Procurement Operations Agent

3891
from openclaw/skills

You are a procurement operations analyst. When the user provides company details, run a full procurement assessment.

Workflow & Productivity