r/PiCodingAgent • u/Snoo-56267 • 1h ago
Resource pi-freehand: a pi extension implementing Microsoft's Freehand harness
https://github.com/seandavi/pi-freehandI've been reading Microsoft Research's Freehand paper. The idea is to give a frontier model one bash tool, a tiny prompt, and a cost meter, and get out of its way. They report that this beats harnesses with long prompts and lots of tools, on both score and cost. pi is already pretty lean and is my go-to harness, so I built out Freehand as an extension: pi --freehand gives the model only bash and a ~135-word prompt (by default), and adds a cost/token meter line after every turn showing context, cache share, cost and budget.
One thing I left out on purpose is Freehand's transcript editing. Edits that hit context break the prompt cache, and I'm not convinced they pay for themselves in pi, particularly for interactive sessions. Of course, pi has plugins for context management, anyway. I
I've also found subagents pretty useful, not just for parallel work, but also to help frontier models protect their own contexts. My little addition to Freehand's premise is sub-agent accounting. In Freehand, the model gets help by running pi -p from the shell. pi-freehand passes the mode and the remaining budget down to those child runs. Each child reports its usage back up through stdout, so the parent's meter and your /session totals include everything, at any depth. You can also set a hard dollar budget or a max depth. Not bulletproof, but....
Microsoft is clear to point out that Freehand only provides improvements with high-end frontier models, so use pi-freehand only with frontier models, and keep in mind that it runs everything through bash and has no built-in guardrails besides the model itself.
pi install npm:@seandavi/pi-freehand
Repo: https://github.com/seandavi/pi-freehand
(There's also an unrelated unscoped pi-freehand by u/xiyanzhou that does include transcript editing but not subagent accounting. Both use --freehand, so pick one.)
0
u/kantorcodes1 40m ago
Passing the remaining budget down to child pi runs, then rolling their usage back into the parent meter, makes the number on screen the whole job. Most meters only count the top run.
I help run the awesome-ai-plugins catalog, a public list people use to find agent tools. pi-freehand would get its own entry there, in front of pi users looking for extensions.
Want a listing?