r/PiCodingAgent • u/Equivalent_Idea8839 • Sep 28 '26
Discussion What's your top 3 techniques that helped you save tokens / better accuracy from models?
1) Focusing on curating the context, keeping it under 150k. Making tools to trim git / grep / ls output to my liking
2) indexing my large code base and making the basic tools show short index options + hints. Custom tools was a massive red herring and waste of time, models hate using them and never use them properly
3) live filter on my codebase to sandbox models. i.e. exclude file types, files older than N days. etc
25
Upvotes
6
u/sofuego Sep 28 '26
40
u/zebedeolo Sep 28 '26
my best technique was to convince work to pay for my sub.
5
u/seba_alonso Sep 28 '26
Small task clear intent, almost no usage of skills or mcp, no subagents, usage of ripgrep instead of common grep.
13
u/Wandering_By_ Sep 28 '26
1)Figure out what I actually want to build. Come up with a full TDD. Review it twice.
2)Have the models make phased plans to complete the work with exit criteria for each phase.
3)Write the ADRs as things change.
Nothing like good documentation to keep them on track instead of wasting tokens making a mess.
4
u/j3free Sep 28 '26 edited Sep 28 '26
I was surprised to see that when having a specific approach to subagents can improve the quality of long running tasks immensely while also having the same or even less token usage due to:
Shameless plug: ive implemented this exactly in Pi Herdsman
Edit: and yes, this keeps token usage for the main agent below 100k tokens for my usual PR workflows
2
u/Momsbestboy Sep 29 '26
3
u/james__jam Sep 28 '26
Avoid subagents as much as you can. They’re actually great for managing context and using less overall tokens. but 9/10 times, when you use it, you’d use way more tokens than needed
Once you feel like you do need subagent, watch its tool calls and what it’s bringing in into its context. Most of the time, subagents eats a lot of token because they keep re-reading the same thing over and over again.
1
u/npittas Sep 28 '26
A good orchestration layer (custom extension that enables/disables and appends a prompt to the main pi session) that defines all the correct ways to use agents.
4 agents
(
review->k3-256k/sol/astra,
plan->astra/fable/sol,
research/scout->glm5.3-flash/minimax-m3/luna/qwen3.2-27b,
coding/worker->luna/glm5.3
)
Define how the orchestrator has to treat each agent, give them specific files, small scoped tasks, what the review agent should actually review (intent+code, not only code), what the plan should include (details+task separation based on parallel work).
This is token making and codebase specific. orchestration can be a bitch if you do not define how it should be done based on your way of working.
The above is what I found a good middle ground, and then adjust without contradictions by adding an agents.md in the root of your codebase.
1
u/WintertideFellow Sep 28 '26
Very tight system prompt, then if you're not still working on the exact same thing, start a new session and bring over what you need. Do not vary your system prompt so you keep it cached. I haven't hit 1k sessions in a day yet, but some days are close.
1
u/crotch-mavens Sep 29 '26
Stopped reading cargo cult based-advice and using cargo cult based-skills and started paying attention to token usage while my agents work.
1
u/sigmoia Oct 02 '26
Realizing that saving tokens is a losing game. I only optimize when speed and accuracy are improved. Chasing cost saving actively hampers exploration. Get your employer pay for tokens.
1
u/Top_Air_3424 Sep 28 '26
This has been my personal formula so far and works pretty well.
1
u/13henday Sep 28 '26
Put my local model In charge of compaction with blackhole. Doesn’t really save tokens on aggregate but makes the api usage much lower
0
u/tulwio Sep 28 '26
pi-blackhole + and delete most skills, plugins, extensions and just have a strong AGENTS.md and saved prompts that I use constantly.
0
u/cosmicnag Sep 29 '26
Was using blackhole earlier, trying billion context now - when it works, its like blackhole on autopilot
-1
u/137_1 Sep 28 '26
I would say RTK.