Enable language models to actively manage their context using memory tools (read, index, note-take, delete). Models receive agency to self-engineer context rather than passively consume pre-staged information, maintaining compact high-quality reasoning states through strategic deletion of irrelevant information while preserving distilled notes.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
pensieve-stateful-context
title
The Pensieve Paradigm: Stateful Language Models Mastering Context
version
0.0.2
engine
skillxiv-v0.0.2-claude-opus-4.6
license
MIT
url
https://arxiv.org/abs/2602.12108
keywords
["Stateful Language Models","Context Management","Memory Tools","Long-Horizon Tasks","Active State Engineering"]
description
Enable language models to actively manage their context using memory tools (read, index, note-take, delete). Models receive agency to self-engineer context rather than passively consume pre-staged information, maintaining compact high-quality reasoning states through strategic deletion of irrelevant information while preserving distilled notes.
The Pensieve Paradigm: Stateful Language Models Mastering Context
Problem Context
Current language models passively receive context that humans curate, creating a bottleneck: they cannot adapt information selection to specific reasoning needs. The Pensieve Paradigm shifts agency to the model itself: models receive memory tools and actively manage context throughout long-horizon tasks. The key insight is transforming from monotonic context accumulation (until context window exhaustion) to sawtooth profiles (strategically deleting irrelevant information while preserving high-value summaries).
Core Concept
Models coordinate four memory operations: (1) read: retrieve chunks from document corpus, (2) index: catalog retrieved information, (3) note: take distilled notes on key facts, (4) delete: remove irrelevant context. This maintains a compact, high-quality reasoning state throughout extended tasks. The model gains the "wand" to use memory tools directly (unlike external retrieval systems that manipulate context without model input).
"""
Retrieve relevant document chunks.
Args:
query: Natural language query
num_chunks: Number of chunks to retrieve
Returns:
retrieved_chunks: List of document excerpts
"""
# Simplified: keyword matching (would use semantic search)
for
in
self
sum
for
in
if
0
# Get top-k documents
sorted
lambda
1
True
self
for
in
# Store in memory
for
in
self
self
return
def
index
self,
facts: List[str],
category: str = "general"
"""
Index and catalog facts from current context.
Args:
facts: List of factual statements to index
category: Topic category for organization
"""
When to use: Long-horizon reasoning (100+ steps); information-rich domains; tasks requiring selective fact retention
Hyperparameters:
context_limit: 4K-32K tokens (window size)
cleanup_threshold: 0.7-0.9 (when to trigger compression)
note_importance_weight: 0.5-2.0 (value of notes vs. raw facts)
deletion_incentive: 0.1-0.5 (bonus for removing facts)
Key advantages:
Models adapt information selection to tasks
Maintains compact reasoning state
Handles 100+ step trajectories
Transparent memory operations
Common pitfalls:
Over-deletion → loses important context
Under-deletion → context window exhaustion
Notes too verbose → defeats compression
Tool calls not grounded in actual retrieval
Scaling: Number of documents linearly affects retrieval cost; use semantic indexing for large corpora.
Reference
Paper: https://arxiv.org/abs/2602.12108
Related work: Retrieval-augmented generation, active learning, state management
Benchmarks: Long-horizon question-answering, multi-document reasoning
Metaphor: Pensieve (Harry Potter) — memory tool controlled by the user