← Catalog

@giladbarnea/pi-context-auto-heads-up

Give Pi agents context-window heads-ups at 50%, 75%, and 90% usage.

Package

Install

Install with PiG

pig install npm:@giladbarnea/pi-context-auto-heads-up

Install with Pi

pi install npm:@giladbarnea/pi-context-auto-heads-up
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.0.9 (README.md). PiG does not review it.

pi-context-auto-heads-up

Keep the agent aware of its remaining context window.

pi extension npm version tests license

Long coding sessions can run out of context before the work is done. This Pi extension gives the agent one hidden heads-up when usage crosses 50%, 75%, or 90%.

The agent gets the guidance inside its model context. The user sees only a small notification that names the crossed threshold.

Install

pi install npm:@giladbarnea/pi-context-auto-heads-up

Run /reload in an existing Pi session after installation.

What each heads-up does

UsageGuidance
50%Compare progress with remaining context. Consider delegating noisy read-only work.
75%Inform the user when substantial work remains. Delegate more implementation work.
90%Warn the user and other agents. Write a handoff when unattended. Move direct work to fresh agents.

The wording is intentionally opinionated. It treats delegation and handoffs as context-management tools, not as automatic responses to every large task.

Behavior

  • Each threshold fires once per upward crossing.
  • A jump across several thresholds emits only the highest crossed threshold.
  • Compaction clears pending delivery. A later measured decrease can rearm thresholds; warnings already written are not retracted.
  • After every compaction, manual or automatic, the agent gets one hidden notice: “Your context window was just compacted and is now at N% usage. Ignore context usage measurements from before this compaction. You will receive context usage notifications as usual for your current context window.” Pi reports usage as unknown until the first response after compaction, so the notice follows that response. In print mode, when that response is the final answer, the next prompt delivers the notice instead.
  • Mid-run heads-ups are appended persistently after the completed assistant/tool turn. The next natural model call sees them; no extra response is forced.
  • In print mode (pi -p), which outputs only a trailing assistant message, a crossing on the final answer is recorded in the session at once instead, keeping the answer printable. The next prompt delivers that heads-up, including after the process exits or the session resumes. A compaction before then discards it, because it measured the pre-compaction context; the compaction notice reports the new usage instead. Other modes deliver it immediately.
  • Delivery appends new context without rewriting earlier prompt or tool messages. A heads-up remains in history instead of disappearing after one request.
  • Resuming a session starts from its current percentage. The extension does not emit retrospective heads-ups.

Timing and compaction

A heads-up records the crossing when the turn finishes, before Pi's next automatic-compaction decision. Compaction may retain an earlier warning, so treat it as a historical crossing—not a guarantee of current usage. The extension does not retroactively remove delivered warnings or invent a percentage while Pi reports usage as unknown.

Persistent delivery avoids a subtle failure of temporary context-hook messages: returning a changed conversation list can fold historical system/tool declarations into a new leading prompt and break preserved-thinking or cache prefixes. See issue #2 for the general failure category, official Pi references and controlled evidence.

Development

npm ci
./setup.sh
npm run check
npm pack --dry-run

See DEVELOPMENT.md for the release process and manual test flow.