
Moshe AvdielClaude Code kept finishing the turn blind on shopping-admin wall. Token budget mid-session is a live hub leaf.
I have sat next to the shopping-admin wall at 00:40 while Claude Code was this close to doing the wrong thing.
Not a model failure. A posture failure.
The host had started with max-tokens frozen in env / argv / a skill file. Someone on the floor said, out loud, disable inventory writes — keep search. Claude Code was still holding the old process. The only “safe” move anyone trusted was:
I have watched that restart more times than I want to admit. It feels responsible. It is a ceremony. flash-freeze on SKU writes does not wait for ceremonies.
The Aha: Token budget mid-session is not a binary you reboot. It is a function that should read live posture from Kiponos.io on every call. The host stays up. The leaf moves.
Claude Code is good at calling tools. It is not born with a shared, instant, restart-free control plane.
So teams hide Token budget mid-session in the only places agent frameworks actually ship:
| Where the gate hid | What you restart | What you lose |
|---|---|---|
| MCP server env / argv | The MCP process | Open tool sessions |
| Skill file on disk | The agent turn, sometimes the host | Context the model already paid for |
| Host-local JSON | Whatever still has the file open | Agreement between two agents |
Hard-coded if on max-tokens
|
A release | The incident clock |
The shopping-admin wall already knew. Claude Code did not, because it had started earlier.
That is the missing piece: the framework gave you tools. It did not give you a live hub.
| Belief | Production |
|---|---|
| Feature flags cover this | Flags are another product, another delay |
| Paste the new max-tokens into chat | Two agents, two pastes, two lies |
| We'll catch it next turn | The shopping-admin wall already knew this turn |
| Restart Claude Code — it is cheap | Cheap until 00:40 ate cart forensics and the open SKU thread |
Kiponos holds a nested tree. Java and Python SDKs keep the latest values in memory, patched over WebSocket deltas. The hot path inside a Claude Code tool is a local get — no HTTP RTT per shopping lookup.
Hub leaf for this essay:
examples/agentic-dev-1004-am-budget-turn/max-tokens = 8000
Runnable proof: examples/java/agentic-dev-1004-am-budget-turn
Public SDKs: Java, Python, plus React/Angular server peers (createFromEnv). Never put Connect tokens in the SPA.
examples/
agentic-dev-1004-am-budget-turn/
max-tokens: 8000 # Token budget mid-session
apps/
shopping/
live:
max-tokens: 8000
Kiponos kip = Kiponos.createForCurrentTeam();
Folder gate = kip.getRootFolder()
.folderOrCreate("examples")
.folderOrCreate("agentic-dev-1004-am-budget-turn");
if (!gate.hasKey("max-tokens")) {
gate.set("max-tokens", "8000");
}
String posture = gate.get("max-tokens");
// Claude Code tool: refuse the dangerous call when posture moved
Same leaf from a Python tool (Claude Code just calls it):
from kiponos import Kiponos
k = Kiponos.connect(quiet=True) # env: KIPONOS_ID, KIPONOS_ACCESS, KIPONOS
try:
posture = k.get("examples/agentic-dev-1004-am-budget-turn/max-tokens", "8000")
if str(posture) == "8000":
raise PermissionError("Token budget mid-session gated live — host not restarted")
finally:
k.disconnect()
The Claude Code process does not recycle. The next tool call already sees the dashboard edit.
| Event | Without Kiponos | With Kiponos |
|---|---|---|
| Flash-freeze on sku writes | Restart Claude Code; lose cart forensics and the open SKU thread | Set max-tokens live; next Claude Code tool call already obeys |
| Peer host still on old max-tokens | Paste the value into the other chat | One hub leaf; both processes get() locally |
| shopping-admin wall shows the new posture | Claude Code started earlier so it writes anyway | Dashboard and tool share the same memory tree |
| Incident over, resume | Another Claude Code restart | Set max-tokens back; session continues |
| Travel coordinator still sending into a muted channel | Two ceremonies, two lost threads | Same tree, two products, no paste |
get() is an in-process map lookup after bootstrap.max-tokens, not a config-file reload.| Approach | Honest fit | Why it still restarts |
|---|---|---|
| Env file + Claude Code reboot | Simple at 09:00 | The freeze is at 00:40 |
| Skill markdown as policy | Good instructions | Not a live bus |
| Redis poll inside the tool | Shared, but RTT on the hot path | You invented a hub with worse UX |
| Feature-flag SaaS | Product experiments | Rarely session-safe for Claude Code |
@RefreshScope / actuator |
JVM apps | Does not restart Claude Code |
| Situation | Why |
|---|---|
| Tool schema itself changed (new argument) | That is a code/Claude Code restart |
| Secret rotation of Connect tokens | Credentials are not live knobs |
| One-off local script, no peers | A hub is overkill |
| Browser-only “SDK in the SPA” | Forbidden — tokens leak or defaults lie |
At 00:40 someone said, out loud: disable inventory writes — keep search. That sentence is the whole product. If it cannot land in the running Claude Code process in seconds, you do not have posture. You have a wiki.
max-tokens with a sister dial
max-tokens rarely moves alone on the shopping-admin wall. Pair it with a timeout, a mute, or a pause so you do not fix Token budget mid-session by inventing a second incident.
In staging: set a painful max-tokens, prove Claude Code recovers without a host kill, prove clamps reject nonsense, prove last-known-good when the hub is firewalled. That drill ends half the architecture arguments about Token budget mid-session.
KIPONOS_ID / KIPONOS_ACCESS / profile ['my-app']['v1.0.0']['dev']['base'].cd examples/java/agentic-dev-1004-am-budget-turn && cp kiponos.local.env.example kiponos.local.env./gradlew test run — prints examples/agentic-dev-1004-am-budget-turn/max-tokens=...
max-tokens. Keep the process up. No rebuild.If flipping Token budget mid-session requires restarting Claude Code, you do not have a gate. You have a hope with a process ID.
Agent frameworks already know how to call tools. Kiponos is the live hub they do not ship — so the shopping-admin wall can change its mind without killing the session.
How to try: examples/java/agentic-dev-1004-am-budget-turn and ./gradlew test.