How CLI Tools Can Drastically Reduce Token Consumption ⚡
After discovering that tools were silently burning my context window, I had a new problem:
How do I keep powerful agents without paying the cost of massive schemas?
The answer did not come from AI.
It came from something much older.
👉 The command line.
🧠 The Problem with Traditional Tools
Most agent tools today are defined with JSON schemas, nested parameters, verbose descriptions, and strict typing.
They look clean to us as developers.
But to an LLM?
👉 They are heavy prompt payloads.
Every request includes:
- full schema
- all parameters
- all descriptions
Even if the user only says:
“order coffee”
💥 Why This Does Not Scale
Let’s say you have:
- 30 tools
- each with 800 tokens
That means:
👉 24,000 tokens before the user even speaks
And most of those tokens are:
- never used
- rarely relevant
- repeated every time
🔍 Rethinking Tools
So I asked myself:
Do tools really need to be JSON schemas?
Or…
👉 Do they just need to be understandable commands?
⚡ Enter CLI-Style Tools
Instead of this:
{
"name": "create_order",
"parameters": {
"userId": "...",
"productId": "...",
"quantity": "..."
}
}
You define tools like this:
create_order uid pid qty
Or even:
order coffee size=large sugar=0
🧬 Why This Works
Because LLMs are incredibly good at:
- parsing text
- understanding intent
- filling structured patterns
You do not need:
- deep JSON
- verbose schemas
- long descriptions
👉 You just need clear syntax
📉 Token Cost Comparison
JSON Tool
~800–1500 tokens
CLI Tool
~10–30 tokens
👉 That is a 50x–100x reduction
🧠 Less Structure, Better Reasoning
With CLI tools:
- fewer tokens means more room for conversation
- simpler format means easier decisions
- less noise means better accuracy
The model does not need to:
- parse nested JSON
- match schemas
- validate deep structures
It just:
👉 generates a command
⚙️ How It Looks in Practice
User says:
“I want a large coffee with no sugar”
Agent outputs:
order_coffee size=large sugar=0
Your backend:
- parses the string
- validates parameters
- executes the action
🧩 You Move Complexity Out of the Model
This is the key shift:
Before:
- the model handles structure
- the model handles validation
- the model handles formatting
After:
- the model generates intent
- your code handles everything else
👉 Which is exactly what we want as engineers
🚀 Benefits for Real Systems
If you are building something like:
- WhatsApp or Telegram agents
- multi-domain assistants
CLI tools give you:
- massive token savings
- faster responses
- lower cost per user
- better scalability
- simpler tool definitions
⚠️ Trade-offs
CLI tools are not magic.
You lose:
- strict schema validation in the prompt
- automatic argument formatting
- some guardrails
So you must:
- validate inputs in your backend
- handle errors gracefully
- design clean command syntax
🧠 Best Practices
1. Keep commands short
order_coffee book_yoga pay_invoice
2. Use key=value pairs
book_yoga date=2026-03-28 time=10:00
3. Avoid ambiguity
Bad:
order stuff
Good:
order_food item=pizza size=large
4. Build a parser layer in C#
This fits perfectly with a .NET stack:
- Regex or tokenizer
- map to DTO
- validate
- execute
5. Combine with routing
The best setup looks like this:
Router → Domain → CLI tools
Now you get:
- small toolsets
- tiny prompts
- efficient agents
💡 The Big Insight
After all this, I realized:
JSON schemas are for machines.
CLI commands are for language models.
🏁 Conclusion
The goal is not to remove tools.
The goal is to:
👉 make tools cheaper to think about
CLI-style tools:
- reduce tokens
- simplify reasoning
- scale better
And most importantly:
They let your agent focus on what actually matters — understanding the user.