Skip to content

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.

Without context management, agents waste massive amounts of tokens:

ActivityWithout AgentCTXWith AgentCTXSavings
Tool descriptions (70 tools)9,950 tokens850 tokens91%
Tool invocations (150 calls)7,350 tokens1,800 tokens76%
File search + retrieval16,925 tokens1,290 tokens92%
Documentation search11,900 tokens890 tokens93%
Total session46,125 tokens4,830 tokens90%

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)

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+ tokens

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

The 5-layer memory system automatically expires low-value memories, keeping the active context focused and token-efficient.

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.
}

Set per-agent or per-session token budgets:

economy:
budget:
perSession: 100000 # Max tokens per session
perDay: 500000 # Max tokens per day

The budget middleware (pipeline position 3) rejects requests that would exceed the budget.

AgentCTX’s 12-dimension inference pipeline ROI model projects:

DimensionValue
Token cost savings36% of ROI
Recovered productivity28% of ROI
Autonomous uptime20% of ROI
GPU infrastructure efficiency16% 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.