freshcrate
Skin:/
Home > AI Agents > pi-boomerang

pi-boomerang

Token-efficient autonomous task execution with context collapse for pi coding agent

Why this rank:Strong adoptionRecent releaseHealthy release cadence

Description

Token-efficient autonomous task execution with context collapse for pi coding agent

README

pi-boomerang

pi-boomerang

Token-efficient autonomous task execution with automatic context collapse for pi coding agent.

/boomerang Fix the login bug

The agent executes autonomously. When done, the entire exchange collapses to a brief summary—work gets done, tokens get saved.

Why

Long autonomous tasks consume massive context. A bug fix that reads 10 files, makes 5 edits, and runs tests might burn 50k tokens. With pi-boomerang, the LLM only sees:

[BOOMERANG COMPLETE]
Task: "Fix the login bug"
Actions: read 10 file(s), modified src/auth.ts, src/login.ts, ran 3 command(s).
Outcome: Fixed the login bug by correcting the JWT validation logic...

Same outcome. Fraction of the tokens. The session tree preserves full history for /tree navigation if you need it.

An inverted D-Mail: where D-Mail rewrites reality while the observer remembers, boomerang rewrites the observer while reality persists. The session tree is your Reading Steiner.

Install

pi install pi-boomerang

Then restart pi to load the extension.

Quick Start

# Plain task
/boomerang Refactor the auth module to use JWT

# Run a prompt template
/boomerang /commit "fix auth bug"

# Chain templates together
/boomerang /scout "map the auth module" -> /planner "design JWT refresh" -> /impl

# Cancel mid-task (no collapse)
/boomerang-cancel

The agent works without asking questions, making reasonable assumptions. When complete, everything collapses into a summary branch.

Chain Execution

Run multiple templates in sequence with a single collapse at the end:

/boomerang /scout "analyze the codebase" -> /planner "design the fix" -> /impl "build it"

Each step can specify its own args inline. You can also set global args as a fallback for steps without inline args:

/boomerang /scout -> /planner -> /impl -- "build the auth system"

Each template's frontmatter controls model, skill, and thinking level for that step. Scout runs on sonnet, planner on opus, impl on whatever—boomerang switches automatically and restores your original config after collapse.

Status indicator shows progress as chain 1/3, chain 2/3, etc.

Rethrow Execution

Use --rethrow N to run the full task N times, collapsing context between each pass:

/boomerang /deslop --rethrow 3
/boomerang "improve code quality" --rethrow 2
/boomerang /scout -> /impl --rethrow 2 -- "auth module"

How it works in boomerang mode:

  • N is required and must be 1-999
  • each pass does: execute task -> collapse to summary -> start next pass
  • file changes persist on disk across passes
  • each new pass sees accumulated summaries from prior passes, not full raw turn history
  • rethrow uses an internal auto-anchor at the current leaf for that run

Status shows rethrow 2/3, and for chain rethrows rethrow 2/3 · chain 1/2.

--loop N compatibility in boomerang:

  • /boomerang ... --loop N is treated as alias for /boomerang ... --rethrow N
  • if both flags are present, --rethrow wins and --loop is ignored
  • boomerang strips loop metadata from the rendered task so inner prompt args do not receive --loop tokens
  • bare --loop (no count) is invalid in boomerang and returns --loop requires a count (1-999)

Examples:

# alias -> rethrow
/boomerang /deslop --loop 2

# mixed flags: --rethrow takes precedence
/boomerang /deslop --rethrow 3 --loop 9

Cancel mid-rethrow with /boomerang-cancel.

Prompt Templates

If the task starts with /, boomerang treats it as a template reference:

/boomerang /commit "fix the auth bug"
/boomerang /codex/review "the auth module"

Templates load from <cwd>/.pi/prompts/ first, then ~/.pi/agent/prompts/. Subdirectories map to path segments (/codex/reviewcodex/review.md).

Frontmatter fields:

---
model: claude-opus-4-6
skill: git-workflow
thinking: xhigh
---
Commit current work. $@
  • model — switches before the task, restores after
  • skill — injects into the system prompt
  • thinking — sets thinking level, restores after
  • $@ expands to all args, $1 $2 etc. for positional

Anchor Mode

By default, each boomerang collapses just its own work. Set an anchor when you want multiple tasks to share the same collapse point:

/boomerang anchor              # set anchor here
/boomerang "task A"            # collapses to anchor with summary A
/boomerang "task B"            # collapses to anchor with summaries A + B
/boomerang anchor clear        # remove anchor

Summaries accumulate, so each task's context includes what came before.

Agent-Callable Tool

When enabled, the extension registers a boomerang tool the agent can call directly. Two modes:

Task mode — pass a task string and it runs autonomously when the current turn ends:

boomerang({ task: "refactor the auth module" })
boomerang({ task: "/deslop --rethrow 3" })
boomerang({ task: '/scout -> /impl -- "auth module"' })

Supports everything the command does: templates, chains, --rethrow N. The task queues and executes after the agent's current turn completes.

Anchor mode — call with no task to toggle an anchor/collapse point. First call sets the anchor, second call collapses everything since the anchor into a summary. Useful for self-managed context without user intervention.

Disabled by default because agents got too aggressive with it. Enable with:

/boomerang tool on

You can provide guidance for when the agent should use it:

/boomerang tool on "Use only for tasks that modify 3+ files"
/boomerang guidance "Use for refactoring or multi-step implementations"

Tool state and guidance persist to ~/.pi/agent/boomerang.json across restarts.

One quirk: tool-initiated anchor/collapse may not update the UI immediately (the context IS collapsed, agent sees it, but chat display lags until /reload).

Commands

Command What it does
/boomerang <task> Execute and collapse
/boomerang <task> --rethrow N Re-run full task N times with collapse between rethrows
/boomerang <task> --loop N Alias for --rethrow N in boomerang mode
/boomerang /<template> [args] Run template and collapse
/boomerang /a -> /b -> /c Chain templates
/boomerang /a -> /b --rethrow 2 Chain templates, then rethrow full chain twice
/boomerang-cancel Abort without collapsing
/boomerang anchor Set collapse point
/boomerang anchor show Show anchor info
/boomerang anchor clear Remove anchor
/boomerang tool [on|off] Enable/disable agent tool
/boomerang guidance [text] Set/show/clear guidance

vs pi-context

pi-context gives the agent Git-like tools to manage its own context—create milestones, monitor token usage, decide when to squash.

The problem: LLMs cut corners when told about resource limits. "You're at 80% capacity" triggers scarcity mindset—rushing, skipping exploration, shallower analysis.

pi-boomerang keeps the agent unaware. It sees the task, works thoroughly, collapse happens invisibly.

File State

Boomerang only collapses context/tokens—it never touches file state. All file changes made during the task are preserved. This is intentional; restoring files after the task would undo the work boomerang just completed.

The rewind extension is not required. Install it separately if you want to manually restore previous file states via /tree or /fork. Boomerang operates independently; rewind will not prompt during boomerang-triggered collapses.

Limitations

  • Summary is heuristic—extracts file operations from tool calls, may miss semantic details
  • Agent might still ask questions despite instructions (boomerang completes anyway)
  • Anchor state is in-memory only, clears on session start/switch
  • Tool-initiated collapse may not update UI immediately (/reload to refresh)

Release History

VersionChangesUrgencyDate
v0.6.6### Fixed - Delay fallback summary auto-refresh until Pi reports idle; session replacements cancel stale handoffs, while idle timeouts warn and still send the hidden handoff. - Queue chained boomerang steps as follow-ups so they advance from Pi 0.75.4 `agent_end` handlers without busy-agent errors. - Document the correct `pi install npm:pi-boomerang` install command. - Preserve much longer validation commands and failure details in boomerang summaries while still bounding huge logs. High5/20/2026
v0.6.5## [0.6.5] - 2026-05-03 ### Fixed - Auto-refresh fallback boomerang summaries with `/reload`, including shortcut-first auto mode before any `/boomerang` command has initialized a command context, so stale raw branch content is not left visible after the summary appears. - Preserve draft editor text while auto-refreshing shortcut-first fallback summaries through the temporary `/reload` editor path. - Removed the duplicate visible `boomerang-summary` message; the branch summary remains the singleHigh5/3/2026
v0.4.5 ### Fixed - Expanded completed boomerang branch summaries by default so users no longer need to press Ctrl+O to reveal details. - Avoided expanding the UI if a rethrow collapse is cancelled before boomerang still owns the collapse. High5/1/2026
v0.4.4 ### Fixed - Migrated extension tool schemas from `@sinclair/typebox` to `typebox` 1.x so packaged installs follow Pi's current extension runtime contract. ### Changed - Added `typebox` as a runtime dependency for packaged installs. High4/23/2026
v0.4.3## [0.4.3] - 2026-04-04 ### Changed - Added a `promptSnippet` for the `boomerang` tool so Pi 0.59+ includes it in the default tool prompt section and reliably discovers it during autonomous runs.High4/4/2026
v0.4.2 ### Fixed - Boomerang branch summaries now keep the full `Outcome` text instead of truncating at 500 characters, so collapsed context preserves complete results for future turns. - Preserved assistant formatting in `Outcome` summaries by normalizing line endings without flattening multiline content. Medium4/4/2026
v0.4.1 ### Changed - Migrated boomerang session reset handling to the `session_start` lifecycle event and removed the legacy `session_switch` hook. - Clarified `--rethrow` and `--loop` boomerang behavior in the README, including count requirements, alias precedence, and pass-by-pass execution details. Medium4/3/2026
v0.4.0 ### Added - **`--rethrow N` syntax** — Run full multi-pass boomerang execution with context collapse between rethrows (for example `/boomerang /task --rethrow 3`) - **Synchronous rethrow execution model** — Rethrows run in-command via `waitForIdle`, with per-rethrow collapse and accumulated summaries - **Boomerang tool accepts a task parameter** — When enabled, the agent can call `boomerang({ task: "fix bugs --rethrow 3" })` to queue tasks with full rethrow/chain/template support ### Changed Low3/19/2026
v0.2.1### Fixed - Added missing `pi` manifest to package.json so pi can auto-discover the extensionLow3/10/2026
v0.2.0### Added - **Chain execution** - Run multiple templates in sequence with `/boomerang /scout -> /planner -> /impl -- "task"`. Each step can have its own args, model, skill, and thinking level. Context collapses after the final step. - **Prompt template execution** - `/boomerang /<template> [args...]` runs templates from `.pi/prompts/` with frontmatter support for `model`, `skill`, and `thinking` - **Tool guidance** - Customize when the agent should use boomerang with `/boomerang guidance <text>Low3/5/2026
v0.1.1### Fixed - README install instructions now show `pi install` commandLow3/2/2026
v0.1.0## [0.1.0] - 2026-03-01 ### Added - `/boomerang <task>` command for autonomous task execution with context collapse - `/boomerang anchor`, `/boomerang anchor show`, `/boomerang anchor clear` commands - `/boomerang-cancel` command to abort active boomerang - `boomerang` tool for agent-initiated context collapse (toggle anchor/collapse) - Automatic summary generation from tool calls (file reads, writes, edits, bash commands) - Status indicator in footer (yellow during execution, cyan for anchor)Low3/2/2026

Dependencies & License Audit

Loading dependencies...

Similar Packages

capitaineCapitaine — fork a repo, click Codespaces, the agent is alive. The repo IS the agent.master@2026-06-08
ralphy-openspec🤖 Enhance AI coding with ralphy-openspec, a spec-driven tool that enables iterative execution for predictable, efficient development.main@2026-06-08
karpathy-llm-wikiThe Self-Growing Karpathy LLM Wiki — grown by an AI agent yoyo from Karpathy's founding promptmain@2026-06-08
claude-memA Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresses it with AI (using Claude's agent-sdk), and injects relevant context back into future sesv13.4.1
uix-ai-agent🤖 Generate UI & UX flows for web and mobile apps using natural language prompts with UIX AI Agent, your intelligent design assistant.main@2026-06-07

More from nicobailon

pi-interactive-shellPi coding agent extension that allows Pi to autonomously control interactive CLIs in an observable overlay. Full PTY emulation, no tmux, token efficient. User can take over anytime.

More in AI Agents

claude-memA Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresses it with AI (using Claude's agent-sdk), and injects relevant context back into future ses
Awesome-AI-AgentsA collection of autonomous agents 🤖️ powered by LLM.
tamuxA terminal multiplexer and user interface (TUI) with a super-powerful agent. Tamux is the only agent runtime that treats the daemon like an operating system kernel – sessions, targets, memory, managem
karpathy-llm-wikiThe Self-Growing Karpathy LLM Wiki — grown by an AI agent yoyo from Karpathy's founding prompt