Loading…
gathering yarn balls…
Cat Game Research
Frontier
Dev-log transmissions from the expedition

TokenTrap Signals: How to Halt Recursive Archon Agent Loops

Commercial AI dev platforms profit from unbounded agent loops. The same primitives that make a local PI Archon safe—hard budgets, shared game-world state, and explicit kill signals—can halt them.

Architecture / Token Economics

TokenTrap Signals

How to see the loops that want to keep burning, and how to stop an Archon agent before it pays for its own recursion.

This post is about the structural tension between agentic AI and token billing. When a tool is paid by the token, every extra turn, every re-sent context, and every hidden sub-agent call is revenue. That is not a conspiracy; it is the business model. The result is a class of anti-patterns we are calling TokenTraps: design choices that make loops longer, contexts fatter, and halting signals weaker, all while the meter runs. We will survey the commercial landscape, contrast sub-agent orchestration with agent hives, argue that the right metaphor for long-running multi-agent work is an online game world rather than a linear notebook exchange, and show how the CatGame PI Archon is already wired to halt.

1. The TokenTrap is not a bug

A TokenTrap is any feature of an AI coding or dev platform that increases token consumption without a proportional, transparent increase in user value. It is not necessarily deliberate; sometimes it is just a lazy default. But the incentives are real. Under token-based billing, the platform's revenue is a function of total tokens consumed. The agent's behavior, in turn, is shaped by the architecture the platform provides. When that architecture lacks hard halting signals, the loop keeps running and the bill keeps growing.

Working definition. A TokenTrap exists when (1) the user is billed per token, (2) the platform or its default agent design can extend the conversation without an explicit user opt-in per extension, and (3) the extension produces no verifiable progress toward the stated goal. The extension may be more turns, larger context, hidden sub-agents, or silent retries.

This is not an accusation against any single vendor. It is a structural observation. In 2026, the major coding assistants moved from flat monthly seats to token-metered pricing [The New Stack]. Cursor, for example, is reported to charge a roughly 20% markup on the underlying API cost in addition to its subscription tiers, with enterprise contracts now driving the majority of its annualized revenue [Value Add VC]. PostHog open-sourced a billing model that passes LLM cost through at 1.0x with no markup, explicitly breaking from its own earlier 20% AI margin [UsageBox]. The spread between these two approaches is the entire discussion.

User promptAgent turnTool callsContext growsTokens burnedRevenueIncentiveWeaker halt
Figure 1 — The TokenTrap feedback cycle: more turns grow context, which burns tokens, which creates revenue, which weakens the incentive to halt.
The most expensive failure mode is not a bad answer. It is a loop that never stops asking the question.
On infinite agentic loops

2. The commercial playbook: a survey

The following patterns show up across multiple platforms, often documented as features. We are listing them not as hidden conspiracies but as visible defaults that every user should audit. Each one has a distinct TokenTrap signal: a counter, a latency spike, or a context-size growth curve that gives it away.

PatternWhat it looks likeWhy it burns tokensWatch this signal
Hidden model escalationThe orchestrator silently swaps the cheap fast model for a frontier model on 'difficult' sub-tasks.Price can jump 10-100x per token. The swap is invisible unless you read every event log.Model ID per turn; per-turn cost delta; unexpected latency increase.
Sub-agent fan-outOne 'agent' task spawns research, code, test, and review sub-agents in one prompt.Each sub-agent duplicates a full prompt and context; the orchestrator re-reads every result. Anthropic and MindStudio both report 3-10x token overhead versus single-agent work [Anthropic][MindStudio].Number of spawned contexts; repeated summaries; orchestrator context growth.
Unbounded retryA tool fails; the agent rephrases the call and tries again with no back-off or cap.Same tool payload is re-sent many times; the failure signal becomes noise in the context.Repeated tool names with identical or near-identical arguments; argument-hash collisions.
Context replayEvery turn re-sends the entire transcript plus all tool results so far.Input tokens scale as the square of turns, not linearly. A 10-turn loop can cost 50-100x a single turn.Input token count per turn; ratio of input to output tokens.
Vague completionThe task is 'improve the docs' or 'refactor this' with no verifiable done predicate.The loop can continue indefinitely because no external state can prove the task is finished.Absence of a test, diff, or exit predicate in the task specification.
Notebook hand-offAgents pass state by writing to and reading from a shared HTTP endpoint or file in sequence.Each hand-off serializes the whole context, creates copies, and forces round-trips. Real-time collaboration becomes impossible.Queue length; serialization size; number of blocking reads per agent.

Thoughtworks calls this the move from 'renting software' to 'buying raw compute capacity' [Thoughtworks]. The critical point is that the old SaaS contract had a ceiling; the new token contract has a throttle with no floor. When the agent is also the one pressing the throttle, the user is no longer the customer—they are the fuel.

3. The sub-agent tax

Sub-agents are useful for isolation. They give a task its own fresh context so that a big, messy search does not pollute the orchestrator. But the cost is real. Each sub-agent call re-sends its own system prompt and instructions. Each result is appended to the orchestrator's running context. If the result is long, the orchestrator pays for it on every subsequent turn. If the result is summarized, the summarizer itself is another model call. In either case, the token budget is being spent on coordination, not on the user's actual task.

Sub-agent fan-outOrchestratorResearchCodeReviewCost = P + Σ(R_a + S_a + H_a)Hive / shared stateWorld stateAgent AAgent BAgent CAgent DCost ≈ N·c_0 + Σ|Δs_t|
Figure 2 — Sub-agents pay a coordination tax (P = prompt, R = return, S = summary, H = history replay). A hive reads and writes a shared world state and only pays for the delta.

Multi-AI Agent Patterns 2026 makes the distinction cleanly: sub-agents are a context-isolation mechanism; agent teams are for genuine parallelism [The Prompt Shelf]. If your tasks are not genuinely parallel, the team is just an expensive way to keep the notebook in the cloud.

Let a = 1 … A index sub-agents under a single orchestrator. Let P be the orchestrator's base prompt. Let R_a be the raw return from sub-agent a. Let S_a be the summarized return (if any). Let H_a be the portion of that return that is replayed in the orchestrator's history on every later turn. C_sub = P + Σ_a (P_a + R_a + S_a + H_a · (T - t_a)) If H_a is large and the orchestrator runs T more turns, the sub-agent is not a one-time cost. It is a recurring line item. Now consider a hive of N agents with shared state s_t at step t. Each agent reads the current state once and produces a local patch Δ_a,t. The shared state is updated with the union of patches: s_{t+1} = s_t ⊔ Δ_1,t ⊔ Δ_2,t … ⊔ Δ_N,t C_hive(T) = N · T · c_0 + Σ_t |s_{t+1} \ s_t| where c_0 is the fixed local reasoning cost per agent per tick and |s_{t+1} \ s_t| is the size of the state delta. The cost is linear in agents and in state churn, not quadratic in handoffs. This is the difference between a conversation and a world.

The current CatGame PI route does not use sub-agents for routine local work. The Archon is the default reasoning layer; pi glm is the explicit specialist route. The human user, through the Crypt Keeper, is the one who authorizes each escalation. This is not a detail; it is the difference between a bounded agent and a runaway one.

4. Game worlds, not notebooks

Most multi-agent systems today are modeled as a chain of HTTP requests or a shared notebook passed from agent to agent. That model works for a few sequential handoffs. It does not work for a large hive. A big, long-running swarm of agents needs the same thing a multiplayer game needs: an authoritative world state that every agent can read, a stream of events that every agent can subscribe to, and a conflict-resolution rule that keeps copies converging.

Notebook passing (linear pub/sub)Agent ANotebookAgent Bserialize whole state per hand-offGame-world sync (authoritative state)World stateAgent 1Agent 2Agent 3Agent 4events + state deltas; eventual consistency
Figure 3 — A notebook is a queue of whole-state snapshots. A game world is an authoritative state with event-based replication.

The multiplayer-game literature has been solving this for decades. Netskip combines conflict-free replicated data types (CRDTs) with skip lists to give eventual consistency without a central server [doi.org/10.1016/j.cola.2025.101370]. Colyseus distributes game objects with weakly consistent read replicas and a single-copy write path [Colyseus, Bharambe et al.]. MASS explicitly separates world dynamics from view rendering and shows that a typed, authoritative shared state can scale to 1,024 concurrent players for 10,000 recurrent steps [arXiv:2608.06257].

Conjecture (TokenTrap Equilibrium). For a platform that bills per token and profits by a per-token markup, an unbounded agent loop is a local revenue maximum even when it is a global user-value minimum. The marginal cost of an extra turn is paid by the user; the marginal revenue is captured by the platform. Therefore the platform's default optimizer has no interior incentive to halt the loop. The halt must come from an external budget or from a user-controlled runtime.

The implication is that we should not expect the market to self-correct. The same way a free-to-play game monetizes attention, a token-billed agent monetizes turns. The architecture that protects the user is a hard, client-side budget and a world model that lets agents observe state without re-sending the entire conversation.

5. How the PI Archon halts

CatGame's local PI runtime is built around bounded loops from the start. The pi-daemon owns the inference context. The pi_agent binary runs a client-side tool loop. The Crypt Keeper issues the capability that lets either one start. The human user is the root of trust, not the model.

8
max_turns default
240s
shipped timeout
16K
context tokens
1
daemon owner

The bounds are real and they are in the code. The agent loop in pi/pi_agent.cpp is a for loop over config_.agent.max_turns; the default is 16, and our shipped config/tools/pi_agent.toml sets it to 8. The loop also checks !cancel_.is_cancelled() on every iteration, so a kill signal can abort the turn immediately. The timeout_seconds in the same config caps wall-clock time at 240 seconds.

Theorem (Budget-Governed Termination). Let an agent loop maintain a turn counter t, a token counter τ, a cost counter γ, and a wall-clock timer θ. Let there exist finite constants T_max, Θ_max, Γ_max, and a no-progress predicate Π(t) such that Π(t) is true when the last k turns produced no state change. If the loop guard is (t < T_max) ∧ (τ < Ξ_max) ∧ (γ < Γ_max) ∧ (θ < Θ_max) ∧ ¬Π(t) then the loop terminates in finite time. Proof sketch. The first four conjuncts are monotone resources bounded above. The fifth conjunct is a safety valve. Because at least one of t, τ, γ, or θ strictly increases on every iteration, and each has a finite ceiling, the conjunction must become false in a bounded number of steps. If the loop is stuck in a cycle, Π(t) becomes true and the fifth conjunct is false. Therefore the loop cannot run forever. QED.

The pi loop supervisor in scripts/lib/pi/pi-loop.sh is not a recursive daemon. It is a client-side queue worker: it waits in .cache/pi/loop/tasks/, processes each Markdown task once, and moves it to .cache/pi/loop/completed/. It has an explicit --interval, a bounded --write opt-in, and a pi loop stop command. The pi monitor tool shows daemon, loop, and Crypt status in one panel, so a runaway turn is visible before it becomes expensive.

This is the opposite of an unbounded recursive Archon. The Archon is provisioned by the Crypt Keeper, managed by the human, and halted by hard counters in the runtime. It is a governed capability, not a self-perpetuating process.

6. The five TokenTrap signals

We are proposing a small, portable signal board that any agent runtime can expose. Each signal is a predicate. The loop stops when any one of them is true. The signals are cheap to compute and hard to ignore because they live outside the model's stop_reason.

1. Turn cap

A hard limit on model iterations. The crudest, most reliable signal. Set it from the task class: 5 for a lookup, 8 for a coding task, 40 for a complex refactor. If a run routinely hits the cap, the cap is not the problem.

2. Token budget

Cumulative input plus output tokens across the run. Catches the loop that stays under the turn cap but re-sends a huge context every turn. Use the provider's usage metadata, not an estimate.

3. Cost budget

The only signal that stays meaningful when you change models mid-run. Convert tokens to the user's currency. When the cost budget trips, the loop exits with a partial answer and a reason.

4. No-progress predicate

Hash the normalized tool call and arguments. If the same hash appears n times, the agent is looping. Also track state-delta magnitude; k steps with |Δs| < ε is a halt signal.

5. Wall-clock timeout

Budgets bound work; a timeout bounds latency. A hanging tool or a slow model should not be able to outlast the user's patience. The timeout is the kill switch, not the primary budget.

The bounded agentic loop pattern [AI Architect] formalizes this as five bounds plus an out-of-band kill switch. The Typed Tool-Loop Failure Detector pattern adds per-tool caps, so a thirty-call canvas-action burst is caught before the global budget is exhausted [Agent Patterns Catalog]. These patterns are stack-agnostic; the implementation belongs in the harness, not in the prompt.

7. Caveats and honest framing

Not every token spent is a TokenTrap. Some tasks are legitimately expensive. The point is transparency and control. A user should be able to see the turn counter, the model ID, the running token total, and the cost before the bill arrives. A platform that hides those signals is not 'more agentic'; it is less accountable.

Sub-agents are not evil. They are the right tool when the problem is genuinely parallel and the cost of context pollution is higher than the cost of coordination. The mistake is using them as the default shape for every task, especially under a billing model that rewards every extra call.

The game-world metaphor is also not a universal solution. Authoritative shared state introduces its own problems: consistency models, conflict resolution, permissions, and the cold-start problem of bootstrapping the world. But for large hives and long-running tasks, it is a better starting point than a chain of HTTP POSTs.

Finally, the references below are a snapshot of the 2026 landscape. Vendor pricing and features change. The structural observation—per-token profit creates an incentive for unbounded loops—does not.

8. References and cross-links

External sources
Hou, Wang, Zhao & Wang, When Agents Do Not Stop: Uncovering Infinite Agentic Loops in LLM Agents, arXiv:2607.01641, 2026. https://arxiv.org/abs/2607.01641
Sayed Ali et al., The Harness Effect: How Orchestration Design Sets the Token Economics of Enterprise Agentic AI, arXiv:2607.06906, 2026. https://arxiv.org/abs/2607.06906
Cai et al., MASS: Multiplayer World Models with Authoritative Shared State, arXiv:2608.06257, 2026. https://arxiv.org/abs/2608.06257
Paredes et al., Netskip: A novel architecture for consistent multiplayer videogame state, Journal of Computer Languages, 2025. https://doi.org/10.1016/j.cola.2025.101370
Bharambe, Pang & Seshan, Colyseus: A distributed architecture for online multiplayer games, NSDI 2006. https://www.usenix.org/conference/nsdi-06/colyseus-distributed-architecture-online-multiplayer-games
Anthropic, Building Multi-Agent Systems: When and How to Use Them. https://claude.com/blog/building-multi-agent-systems-when-and-how-to-use-them
MindStudio, Claude Code Agent Teams vs Sub-Agents. https://www.mindstudio.ai/blog/claude-code-agent-teams-vs-sub-agents
The Prompt Shelf, Multi-AI Agent Patterns: Sub-agents vs Agent Teams. https://thepromptshelf.dev/blog/multi-ai-agent-patterns-2026/
AI Architect, The Bounded Agentic Loop. https://aiarch.dev/patterns/bounded-agentic-loop
Agent Patterns Catalog, Typed Tool-Loop Failure Detector. https://www.agentpatternscatalog.org/patterns/typed-tool-loop-detector/
The New Stack, Cursor cuts prices and adds enterprise spend controls amid 'tokenomics' reckoning. https://thenewstack.io/cursor-pricing-token-billing/
Thoughtworks, The Dangers of Token Usage Billing. https://www.thoughtworks.com/en-us/insights/blog/generative-ai/dangers-token-usage-billing
UsageBox, Pass-Through, Markup, or Flat: How AI Products Decide to Rebill LLM Costs. https://usagebox.com/articles/ai-rebilling-pass-through-vs-markup-vs-flat-2026
Value Add VC, How Does Cursor Make Money. https://valueaddvc.com/blog/how-does-cursor-make-money-subscriptions-token-pricing-and-the-business-model-breakdown

Project links. The PI runtime is in tools/pi_agent, tools/pi_daemon, pi/, and scripts/pi.sh. The bounded loop is visible in pi/pi_agent.cpp and the shipped configuration in config/tools/pi_agent.toml. The loop supervisor is scripts/lib/pi/pi-loop.sh and the status panel is scripts/lib/pi/pi-monitor.sh.

← All transmissions