# pi-better

By Saurabh Kumar · TIL note, Nov 20, 2026 · Tags: pi-agent

Source: https://saurabh-kumar.com/til/1795162342/

[nicobailon/pi-better](https://github.com/nicobailon/pi-better) adds `/better` to Pi. Type `/better add retries to the sync job` and a helper reads your repo in the background, answers Felix Rieseberg's four ["Depth" questions](https://felixrieseberg.com/how-to-be-more-ambitious-a-tutorial-for-humans-with-models/#depth) (what a pro would do that you didn't ask for, the raw material, the methods and tools, what proves it right), then puts the rewritten prompt in your input box. Nothing is sent until you press Enter.

- **It doesn't wait its turn.** Pi runs an extension's slash command the moment you press Enter, while a normal message waits in the queue. So the next prompt gets written while the agent is still on this one. A meter above the input box shows which question the helper is on. The first Esc cancels the helper, the second stops the agent.
- **It vetoes tool calls instead of narrowing the tool list.** The helper is a `pi -p` process with a fork of your chat. A read-only tool list would change the start of its request, and providers cache tools, system prompt and history as one prefix ([how prompt caching works](https://saurabh-kumar.com/articles/2026/06/how-prompt-caching-works/)). So the helper sends the chat's full tool list, and pi-better's own copy loaded inside it (`PI_BETTER_HELPER=1`) refuses every call except read, grep, find, ls and the shell. The README measures 1,651 tokens read from cache with a narrowed list, 36,860 with the chat's.

**Figure:** A helper with its own read-only tool list sends a new request from the first block; pi-better's helper sends the chat's tools, system prompt and history unchanged, so only its task is new. Ember is written to the cache again; ink is read from it. Widths are not to scale.


Two catches on my setup. The README's number is from Pi's Claude provider. In my runs the fork's history wasn't read from cache through [pi-claude-bridge](https://github.com/theskumar/pi-claude-bridge) (4,320 tokens read, 13,336 written) or on gpt-6-luna (none read). Both tie the cache to the session: the bridge maps each Pi session to its own Claude Code session, and Pi sends OpenAI the session id as `prompt_cache_key`. A fork gets a new id, so it starts cold. And with codemode set to `only`, the helper was blind: the guard refused `codemode` itself, all four of its calls failed, and the rewrite named no files. Allowing it is a one-line fix that stays read-only, because Pi sends every call made inside a codemode script through the same `tool_call` hook. A nested `write` still gets refused.
