[Feature Request] Add automatic context usage monitoring - Agent has zero introspection into its own context-budget — and human-facing surfaces (/context, statusline) don't close the gap
Bug Description (as dictated with Wispr)
Ich hab immer wieder die Situation, dass die Session nicht weiß, wo der Kontext steht und sie anfängt zu raten. Zum Beispiel ist das jetzt eine Heavy Session. Wir haben viel gearbeitet. Ich denke, wir sind bei Kontext 60 %. Wenn wir in der Relativität bei einem Kontext von 35% sind. Gleichzeitig habe ich eine für mich eine Grenze definiert, dass wir ab 40 % anfangen, eine Session abzuschließen, nicht in die Gefahr zu kommen, was zu vergessen und so viele Tokens zu verbrauchen. Es wäre also super, wenn der Agent oder die Session selber schauen könnte, wie viel Kontext noch übrig ist. Ich denke, dafür braucht es keinen manuellen Eingriff eines Menschen. Das könnte man auch reinpumpen oder rein diktieren und sagen: Hey, schau mal, was dein Kontext ist, und triff eine Entscheidung, ob wir weitermachen.
Summary
There is an asymmetry: the human can see context utilization (/context, and
optionally a statusline), but the agent cannot. The model is never given its own
used/remaining token count as a tool result or system field. So when the agent
reasons about "how full are we," it guesses — and guesses badly (it will assert ~60%
in a session /context actually reports at ~35%). The agent confidently makes wrong
assumptions about its own state.
Why this is the bug (and why displays don't fix it)
A statusline or /context only informs the human. Both require a person to watch the
gauge and intervene — which is exactly the manual step this request aims to
eliminate. The goal is agent autonomy over session lifecycle; any human-facing
readout is, by definition, not a solution to an agent-introspection problem. The gap
is the agent's own blindness, not a missing display.
Current Behavior
- The agent has no way to query its remaining context budget.
- It estimates utilization, frequently far off from /context.
- Threshold discipline ("wrap up at 40%") is therefore unenforceable by the agent
itself — it depends entirely on the human noticing and stepping in.
Expected Behavior
- The agent can read its own context utilization (used / remaining tokens + percent).
- Given a user-defined threshold (e.g. "begin closing at 40% remaining"), the agent
self-triggers the wrap-up routine — writes the handoff report, commits, proposes a
fresh session — with no human watching the gauge.
Impact
- Heavy sessions silently overrun, losing context and burning excess tokens before
anyone notices.
- The user's explicit policy is currently impossible for the agent to honor on its
own.
- The agent's false confidence about its own state erodes trust in every other
self-assessment it makes.
Proposed Solution (any one helps; all are agent-facing, not human-facing)
- Expose a callable tool, e.g. get_context_usage → { used, remaining, percent }.
- Auto-inject a system reminder at configurable thresholds (40% / 50% / 60%) that
the agent is instructed to act on.
- Settings-level hard threshold that, when crossed, makes the agent run a defined
wrap-up workflow.
Note: A context-percentage statusline would help the human in parallel, but it is
explicitly not a fix for this report — the agent still can't read it.
Environment Info
- Platform: darwin
- Terminal: iTerm.app
- Version: 2.1.165
- Feedback ID: 97d99da7-ddb8-46c9-a043-b2d8840e7973
Errors
[]This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗