autosearch:context-retention-policy

autosearch:context-retention-policy is a skill for Claude Code from 0xmariowu/Autosearch. It costs 89 tokens per session (1,188 once invoked), scanned A, original, MIT.

A policy for managing an AI agent’s working context during long research sessions. It says which recent results and important records to keep, when to move older evidence to files, and when to summarize it.

In plain words
What is it for?
Controlling tool-result history, archiving older research evidence, triggering context compaction, and retaining citations, rubrics, and other required records.
Why use it?
Research can produce more material than the agent can keep in its active context. The policy helps preserve citations and planning information while reducing older evidence.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the autosearch plugin — 63 skills, 1 command, 1 agent shipped together

Good fit Controlling tool-result history, archiving older research evidence, triggering context compaction, and retaining citations, rubrics, and other required records.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/0xmariowu/autosearch/context-retention-policy
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add 0xmariowu/Autosearch --skill context-retention-policy
Clone the repo
git clone --depth 1 https://github.com/0xmariowu/Autosearch

Made for: Claude Code.

Or install autosearch, the plugin that ships this one along with the rest of its 63 skills, 1 command, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for autosearch:context-retention-policy

README.md
[![agentmods](https://agentmods.dev/badge/skills/0xmariowu/autosearch/context-retention-policy/github.svg)](https://agentmods.dev/skills/0xmariowu/autosearch/context-retention-policy)
Your own site
<a href="https://agentmods.dev/skills/0xmariowu/autosearch/context-retention-policy"><img src="https://agentmods.dev/badge/skills/0xmariowu/autosearch/context-retention-policy/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for autosearch:context-retention-policy

Your own site · 80×15
<a href="https://agentmods.dev/skills/0xmariowu/autosearch/context-retention-policy"><img src="https://agentmods.dev/badge/skills/0xmariowu/autosearch/context-retention-policy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,188 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00089 $0.01188
Opus 5.5 $0.00036 $0.00475
Sonnet 5.5 $0.00018 $0.00238
Haiku 4.5 $0.00009 $0.00119

Measured 1mo ago against content hash 30cb07dd25f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

autosearch:context-retention-policy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 1 executable file (__init__.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

autosearch/skills/meta/context-retention-policy/SKILL.md · 115 lines

How it starts

The opening of the file, as written. The whole thing — 115 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Retention Policy — Session-Level Context Governance

A research session can generate more evidence / tool results than any reasonable context window. This skill tells the runtime AI what to keep, what to offload, and when to compact.

Policy Parameters (defaults)

policy:
  keep_last_k_tool_results: 12         # inline, full
  keep_all_citations_index: true       # citation_index stays in context always
  keep_all_rubrics: true               # rubrics stay in context always
  offload_trigger_token_ratio: 0.7     # compact when context ≥ 70% full
  offload_target_token_ratio: 0.4      # after compact, aim for 40% full
  offload_archive_path: "session/<id>/offloaded/<ts>.jsonl"
  prefer_compact_over_drop: true       # summarize instead of silently drop
  never_compact:
    - clarify_result
    - reflective_loop_state
    - graph_plan
    - citation_index
    - rubrics

Compaction Procedure

When current_tokens / max_tokens >= offload_trigger_token_ratio:

  1. Sort evidence / tool_results by age (oldest first).
  2. Identify candidates — everything NOT in never_compact and older than the last K results.
  3. For each candidate batch (every ~3 evidence items):
    • If prefer_compact_over_drop: use a Fast-tier LLM to summarize the batch into a single "digest" item (5-10 lines max, preserves URLs + key specifics verbatim).
    • Else: drop the batch but write full content to offload_archive_path for later recovery.
  4. Replace the original items with the digest. Keep URLs in the citation_index so citations still resolve.
  5. Recheck token ratio. If still above offload_target_token_ratio, iterate.

Preservation Rules (never compact these)

  • The current reflective-search-loop state (gaps, visited, bad_urls).
  • The current graph-search-plan graph structure.
  • The citation-index entries (they're short and referenced by all sections).
  • The rubrics from run_clarify.
  • The original query + clarify verification message.
  • The last 3 tool results regardless of K.

Read the full file on GitHub · 115 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 115 lines · 89 tokens per session scan A 30cb07dd25f7

Subscribe to this mod's changes

autosearch:context-retention-policy is a skill published in the GitHub repository 0xmariowu/Autosearch (52 stars, last pushed 2d ago), licensed MIT. It adds 89 tokens to every session and 1,188 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

quarry-capture

Persist something worth keeping into quarry so it survives context compaction and is findable by quarry-recall later — a durable fact, a distilled lesson, or a URL to index. Trigger phrases: "remember this", "save this fact", "note that we decided X", "learn this lesson", "the rule going forward is X", "ingest this…

punt-labs/quarry · 189 tokens

quarry-recall

Retrieve what quarry already knows before researching from scratch or guessing. Covers three overlapping intents, one tool: understand code ("how does X work", "where is X defined", "what calls X"); recall project knowledge or a decision ("what did we decide about X", "why is it this way", "did we consider Y…

punt-labs/quarry · 192 tokens

stats

Show Captain Memo's corpus statistics (chunks per channel, observation counts, indexing progress, embedder info). Use when the user types /captain-memo:stats.

kalinbogatzevski/captain-memo · 36 tokens

search

Hybrid search across Captain Memo's local memory + skills + observations. Use when the user types /captain-memo:search to retrieve top hits without the model having to decide whether to call searchall on its own.

kalinbogatzevski/captain-memo · 49 tokens

doctor

Health probe across the worker, embedder, summarizer, queue, vector index, schema, cross-AI wiring and plugin install (cache and live versions). Use when the user types /captain-memo:doctor or when something seems wrong.

kalinbogatzevski/captain-memo · 52 tokens

observations

List recent captured session observations (the summarized voyage logs). Use when the user wants to see what Captain Memo has logged from past sessions.

kalinbogatzevski/captain-memo · 30 tokens