Goal
When an agent's running context approaches its provider's window, automatically run the SDK compaction step instead of failing or silently exceeding.
Current state
atn/providers/codex_bridge.py and the bridge code track last_round_input_tokens and have context_window from model_specs.py. The data is there to compute occupancy. No agent currently consumes it to trigger compaction.
Scope
- Add an occupancy check after each turn in the runtime loop.
- When occupancy > N% of
context_window(model) (suggested default: 70%), trigger the SDK's compact action before the next turn starts.
- Make the threshold configurable per agent, with a sensible default.
- Emit a runtime event so the snapshot/UI can show "compacted at turn X."
Acceptance
- A long-running agent passes through the threshold and continues without hitting the provider's hard limit.
- Snapshot reflects the compaction event.
Goal
When an agent's running context approaches its provider's window, automatically run the SDK compaction step instead of failing or silently exceeding.
Current state
atn/providers/codex_bridge.pyand the bridge code tracklast_round_input_tokensand havecontext_windowfrommodel_specs.py. The data is there to compute occupancy. No agent currently consumes it to trigger compaction.Scope
context_window(model)(suggested default: 70%), trigger the SDK's compact action before the next turn starts.Acceptance