Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

williamleong/pi-compact

Repository files navigation

pi-compact

pi-compact is a Pi package for scheduling future context compactions by rule.

Instead of only compacting immediately, it lets Pi compact:

  • after this task
  • after N turns
  • when context usage crosses a threshold
  • after agent_end
  • after turn_end
  • after a specific tool call

Install

pi install git:github.com/williamleong/pi-compact

Then reload Pi:

/reload

What it adds

  • tool: compact_control
  • commands:
    • /compact-after <when>
    • /compact-rules
    • /compact-clear [id|all]
  • skill: pi-compact

Examples

Natural language:

  • compact after this task
  • compact after 3 turns
  • compact when context > 80%
  • compact after tool bash
  • what compact rules are active?
  • clear compact rule 2

Direct commands:

/compact-after this task
/compact-after 2 turns
/compact-after context > 75%
/compact-after tool read
/compact-rules
/compact-clear 1
/compact-clear all

Supported schedules

  • this task
  • this turn
  • N turns
  • context > N%
  • agent_end
  • turn_end
  • tool <name>

Rule behavior

  • this task, this turn, agent_end, turn_end, and tool <name> are one-shot rules.
  • N turns counts down at each turn_end and fires once.
  • context > N% remains active until cleared.
  • tool-triggered rules are armed when the tool is observed, then compact safely at turn_end.
  • compaction runs at safe checkpoints rather than in the middle of a tool execution.

Development

Useful checks:

npm run check
npm test

License

MIT

About

Pi extension + skill for scheduling context compaction after tasks, turns, context thresholds, or tool events.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

AltStyle によって変換されたページ (->オリジナル) /