*Continent · 2 territory*
## Summary
Two code changes on two days: an ambient buffer in server.ts that truncates, expires and meters sessions, and an agent-state layer in session.ts that creates, rewards and ticks agents.
## Explanation
- On Mar 25, 2026, the ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded, purges stale entries on a configured TTL, and tracks sessions by counting sends and estimated tokens consumed.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- The ambient buffer tracks sessions by counting sends and estimated tokens consumed.
- In server.ts, ambient buffer initialization and management are added to session state, and constants for its configuration are added: a 120s default and a 700 token budget.
- In server.ts, ambient buffer initialization and management are added to session state.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- The ambient buffer purges stale entries based on a configured TTL.
- The ambient buffer tracks sessions by counting sends and estimated tokens consumed.
- The ambient buffer tracks sessions by counting sends and estimated tokens consumed.
- In server.ts, ambient buffer initialization and management are added to session state.
- In server.ts, ambient buffer initialization and management are added to session state.
- In server.ts, constants for ambient buffer configuration are added: a 120s default and a 700 token budget.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
- Agent state management provides createAgentState, applyConsequence, applyReward and tickAgentStates.
- Agent state management provides createAgentState, applyConsequence, applyReward and tickAgentStates.
- session.ts adds agent state tracking, tickRound() and getAgentState().
- session.ts adds agent state tracking, tickRound() and getAgentState().
- Nothing in these entries says how the 120s default and the 700 token budget relate to the truncation and TTL behaviors, or which limit the per-call truncation measures against.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
## Threads
- The ambient buffer's limits: truncating oldest entries past a per-call limit, TTL purging, and counting sends and estimated tokens
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- The ambient buffer tracks sessions by counting sends and estimated tokens consumed.
- Wiring the ambient buffer into session state in server.ts, with a 120s default and a 700 token budget
- In server.ts, ambient buffer initialization and management are added to session state.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
- Agent state functions: createAgentState, applyConsequence, applyReward and tickAgentStates
- Agent state management provides createAgentState, applyConsequence, applyReward and tickAgentStates.
- Agent state tracking in session.ts, with tickRound() and getAgentState()
- session.ts adds agent state tracking, tickRound() and getAgentState().
## How it formed
Agent state tracking in session.ts and the agent state functions came first, on Mar 19, 2026; the ambient buffer and its 120s default and 700 token budget followed in server.ts on Mar 25, 2026.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- The ambient buffer tracks sessions by counting sends and estimated tokens consumed.
- In server.ts, ambient buffer initialization and management are added to session state.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
- …and 2 more
## What's still open
The newest entries set the 120s default and 700 token budget without saying which behavior they govern or which limit the per-call truncation measures against.
- The ambient buffer enforces a token budget by auto-truncating the oldest entries when per-call limits are exceeded.
- The ambient buffer purges stale entries based on a configured TTL.
- In server.ts, constants for ambient buffer configuration are added: 120s default and 700 token budget.
## Consultant
**Where it shows up** — The ambient buffer keeps coming up: auto-truncating the oldest entries past a per-call limit, purging on a TTL, counting sends and estimated tokens, with a 120s default and a 700 token budget set in server.ts.
**A way forward** — Keep the 120s default and 700 token budget written next to the truncation and TTL code in server.ts, so the two limits read as one decision.
## Territories
- [[Bevia/World/Territories/Ambient buffer truncation, TTL purge and session tracking|Ambient buffer truncation, TTL purge and session tracking]]
- [[Bevia/World/Territories/Agent state functions and session round ticking|Agent state functions and session round ticking]]