Docs

Everything you need to give your agents managed memory. Five minutes to your first compacted session.

Quickstart

Context Controller works as a drop-in proxy in front of any OpenAI-compatible API. Point your existing client at the proxy URL with your API key — no prompt or tool changes required.

bash
# 1. Install the CLI
npm install -g @contextcontroller/cli

# 2. Create a managed session with the aggressive policy
cc session create --policy aggressive --model gpt-5

# 3. Point your client at the proxy (drop-in replacement)
export OPENAI_BASE_URL=https://proxy.contextcontroller.com/v1
export OPENAI_API_KEY=cc_live_...

# 4. Watch it work
cc watch <session-id>

That's it. From here the proxy tracks token usage, compacts stale content, enforces your priority tiers, and logs everything to the dashboard.

Python SDK

Wrap your chat client to get managed sessions, priorities, and recall in code:

python
from contextcontroller import Client, Priority

cc = Client(api_key="cc_live_...")

# Open a managed session with a compaction policy
session = cc.sessions.create(
    model="gpt-5",
    policy="aggressive",          # or "balanced", "conservative", custom
    target_utilization=0.6,         # compact when usage passes 60%
)

# Pin what must never be evicted
session.add("You are a senior SRE. Never reveal secrets.",
            role="system", priority=Priority.PINNED)

session.add("Debug the latency spike in checkout.",
            role="user", priority=Priority.HIGH)

# Tool outputs default to LOW priority: summarized first, evicted first
session.add(tool_result_json, role="tool")

# The SDK compacts automatically; force it any time
report = session.compact()
print(report.reclaimed_tokens)   # e.g. 50202
print(report.usage_after)      # e.g. 0.556

# Recall something that was evicted hours ago
hits = session.recall("what did the PDF say about refund policy?")
for hit in hits:
    print(hit.text, hit.source_message_id)

JavaScript SDK

javascript
import { ContextController, Priority } from "@contextcontroller/sdk";

const cc = new ContextController({ apiKey: process.env.CC_API_KEY });

const session = await cc.sessions.create({
  model: "claude-opus-4-6",
  policy: "balanced",
  targetUtilization: 0.7,
});

await session.add("You are a helpful coding assistant.", {
  role: "system",
  priority: Priority.PINNED,
});

// Stream a completion through the managed session
for await (const chunk of session.stream(messages)) {
  process.stdout.write(chunk.delta);
}

const report = await session.compact();
console.log(`reclaimed ${report.reclaimedTokens} tokens`);

Policies

A policy decides what gets compacted, when, and how aggressively. Three ship built-in; you can compose your own from primitives.

PolicyBehaviorBest for
conservativeCompacts only tool outputs; evicts nothing below 95% utilization.Short sessions, maximum fidelity.
balancedSummarizes tools + rolling digest of old turns; evicts low-priority at 85%.General-purpose agents. The default.
aggressiveCompacts from 60%; semantic dedupe on; evicts low/normal oldest-first.Long-running agents, research, coding sessions.

API reference

Base URL: https://api.contextcontroller.com/v1 — authenticate with Authorization: Bearer cc_live_….

Method & endpointDescription
POST /sessionsCreate a managed session (model, policy, target utilization).
GET /sessions/{id}Session state: usage, message counts, active policy.
POST /sessions/{id}/messagesAppend a message with role + priority tier.
POST /sessions/{id}/compactTrigger compaction; returns before/after report.
POST /sessions/{id}/recallSemantic search over evicted/compacted content.
GET /sessions/{id}/eventsAudit log of compactions, evictions, recalls.
GET /sessions/{id}/usageToken accounting: used, reclaimed, recall spend.
DELETE /sessions/{id}Close a session and purge its recall index.

Full OpenAPI spec and per-endpoint schemas ship with the private beta.

Glossary

Compaction
Replacing verbose content with a dense summary in place, preserving a provenance link to the original.
Eviction
Removing a message from the active window entirely. Evicted content remains available via semantic recall.
Priority tier
Pinned, high, normal, or low. Determines the order in which content is compacted or evicted under pressure.
Recall
Semantic retrieval of evicted or compacted content, returned as compact chunks with source citations.
Target utilization
The usage threshold (e.g. 60%) at which the compaction policy fires automatically.
Managed token
Any token processed by the compaction engine — the unit of billing.
Session
A managed conversation: messages, policy, priorities, and recall index under one id.
Shared context pool
A context store shared by multiple agents, each with its own view and budget.