Skip to content

Trigger auto-compaction when context occupancy crosses threshold #13

Description

@EightRice

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    track:agentATN runtime, providers, orchestrator, bridgestype:featureNew capability

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions