Token Economics
Token Economics
Section titled “Token Economics”Token cost is a first-class metric in AgentCTX. Every operation is measured in tokens, and the platform is designed to minimize waste at every layer.
The Token Problem
Section titled “The Token Problem”Without context management, agents waste massive amounts of tokens:
| Activity | Without AgentCTX | With AgentCTX | Savings |
|---|---|---|---|
| Tool descriptions (70 tools) | 9,950 tokens | 850 tokens | 91% |
| Tool invocations (150 calls) | 7,350 tokens | 1,800 tokens | 76% |
| File search + retrieval | 16,925 tokens | 1,290 tokens | 92% |
| Documentation search | 11,900 tokens | 890 tokens | 93% |
| Total session | 46,125 tokens | 4,830 tokens | 90% |
How AgentCTX Saves Tokens
Section titled “How AgentCTX Saves Tokens”1. Single Tool (~300 tokens)
Section titled “1. Single Tool (~300 tokens)”Instead of exposing 70+ tool schemas (~140 tokens each), AgentCTX exposes one tool: the actx gateway. Agents query through CTX:
?t github → discover tools (3 tokens)>t github.issues.create title="Fix" → call tool (~25 tokens)2. Content-Addressed Deduplication
Section titled “2. Content-Addressed Deduplication”Static content (tool schemas, docs, configs) is stored once and referenced by hash:
First session: Store full schema → SHA-256 hash (CAS)Next sessions: Reference by hash → 3 tokens vs 140+ tokens3. Context Compaction (CTX-ACCE)
Section titled “3. Context Compaction (CTX-ACCE)”The Adaptive Context Compaction Engine reduces context window usage by:
- Removing stale entries
- Merging redundant memories
- Archiving accessed-but-not-recently-used data
Enable with: actx start --compact
4. Memory Decay
Section titled “4. Memory Decay”The 5-layer memory system automatically expires low-value memories, keeping the active context focused and token-efficient.
Economy Tracking
Section titled “Economy Tracking”The gateway’s economy middleware tracks costs in real-time:
interface CostReport { inputTokens: number; outputTokens: number; totalCost: number; // USD provider: string; // "openai", "anthropic", etc. model: string; // "gpt-4", "claude-sonnet", etc.}Budget Enforcement
Section titled “Budget Enforcement”Set per-agent or per-session token budgets:
economy: budget: perSession: 100000 # Max tokens per session perDay: 500000 # Max tokens per dayThe budget middleware (pipeline position 3) rejects requests that would exceed the budget.
ROI Model
Section titled “ROI Model”AgentCTX’s 12-dimension inference pipeline ROI model projects:
| Dimension | Value |
|---|---|
| Token cost savings | 36% of ROI |
| Recovered productivity | 28% of ROI |
| Autonomous uptime | 20% of ROI |
| GPU infrastructure efficiency | 16% of ROI |
| Per-developer annual value | ~$43,831/year |
Token cost is important, but it’s only 36% of the total value. The majority comes from productivity gains — agents that remember context, share knowledge, and don’t repeat work.
See Also
Section titled “See Also”- Introduction — the token waste problem
- Memory & Persistence — how decay reduces bloat
- Gateway & Routing — economy middleware