← 返回
未分类 中文

CertainLogic Context Manager

Prevent AI session token bloat and runaway costs. Tracks query count per session, warns at a configurable threshold, auto-writes a dense handoff summary befo...
Prevent AI session token bloat and runaway costs. Tracks query count per session, warns at a configurable threshold, auto-writes a dense handoff summary befo...
certainlogicai
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 343
下载
💾 0
安装
1
版本
#latest

概述

Context Manager

Keeps sessions lean. Tracks query count, warns before context bloats, saves a handoff summary so work continues cleanly in the next session.

How It Works

  1. Counter — Increment session_query_count.txt every turn
  2. Warn — At threshold, write handoff.md and alert the user
  3. Reset — User runs /new; next session reads and deletes handoff.md

Files

FilePurpose
------
session_query_count.txtInteger. Increment each turn. Create if missing (default 0).
handoff.mdWorkspace root. Written at threshold. Read + deleted on next session start.

Every Turn (mandatory)

1. Read session_query_count.txt (default 0 if missing)
2. Increment by 1
3. Write back
4. If count == THRESHOLD: trigger handoff flow

Default threshold: 10. Configurable per deployment.

Handoff Flow (at threshold)

  1. Write handoff.md — see handoff-format.md for exact spec
  2. Tell the user:

> ⚠️ 10 queries in — context is getting heavy. Handoff saved. Run /new when ready to continue.

  1. Do NOT auto-reset. User controls the reset.

Session Start Flow

1. Check if handoff.md exists
2. If exists AND file is < 3 hours old:
   a. Read it
   b. Apply context to current session
   c. Delete handoff.md
3. Reset session_query_count.txt to 0

Topic Switch Detection

When the user says "BTW", "switching gears", "new topic", or starts a clearly unrelated task:

  1. Write/overwrite handoff.md immediately (don't wait for threshold)
  2. Tell the user: "Handoff saved — /new when ready"
  3. Resume or continue current task

Why This Matters

Session context is cumulative. Every prior message, tool call, and assistant response is re-sent on every new query. Without resets, a lean 18K-token session becomes 50K–400K+ within hours.

See token-math.md for cost impact data and reset savings estimates.

Commands

CommandBehavior
------
/new or /resetUser-triggered. New session starts; skill reads handoff.md if present.
/handoffExplicit handoff write. Same as threshold flow, on demand.
/counterReport current query count and threshold.

Configuration

Override defaults in AGENTS.md or equivalent workspace config:

- CONTEXT_THRESHOLD: 10        # Queries before warning (default: 10)
- HANDOFF_TTL_HOURS: 3         # Hours before handoff.md is considered stale (default: 3)

Reliability Rules

  • Never skip the counter increment — even for one-liner responses
  • Never auto-reset — the user owns the session lifecycle
  • Handoff must be written before warning — never warn without saving state first
  • Counter file is source of truth — do not track in memory

What This Saves You

Without this skillWith this skill
------
Sessions balloon to 400K+ tokensSessions stay under 25K
Cost multiplies 22x over a dayCost stays near baseline
Work lost on manual /new resetsHandoff auto-saved, resumed next session
No signal before context degradesWarning fires before quality drops

See token-math.md for the full cost breakdown.


Built by CertainLogic — trusted fact infrastructure for AI agents.

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 17:20 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Skill Vetter Plus

certainlogicai
AI代理技能安全扫描器。9个内置检测签名,识别密钥、不安全执行模式和提示词注入。50毫秒内出结果。
★ 0 📥 408

Certainlogic Onboarding Wizard

certainlogicai
为新 OpenClaw 用户检测环境、推荐技能并生成个性化 Markdown 设置报告,无需自动安装...
★ 0 📥 337

Skill Oracle

certainlogicai
技能预言 — 精心整理的高质量 ClawHub 技能文档,Markdown 表格指示代理哪些工具可用、哪些为空,非 API 或代码库。
★ 0 📥 472