# Reduce token usage in Mastra

> One setting cuts more. Agent type: building my own agent. From Use Fewer Tokens, by StackOne.

Last checked: 30 Nov 2026, against the vendor's own pages.

## Settings that cut more in Mastra
- **Load tools when needed**: ToolSearchProcessor. ([source](https://mastra.ai/reference/processors/tool-search-processor), read 30 Nov 2026)

## With StackOne
- **Deep Query**: Data Sync on the list action, then list_tickets_s1query({ filter, source, aggs })
- **Load tools when needed**: Add https://mcp.stackone.com/mcp; Advanced Tool Search is on by default
- **Ask for fewer fields**: source on any _s1query call, listing only the fields the answer uses
- **Keep live questions live**: Keep the live action next to the _s1query tool
- **Tool Policies**: Tool Policies on the project

## Other techniques for your own agent
- [Turn off tools you don't use](https://usefewertokens.com/techniques/fewer-tools/): fits. Filter the tool list per step.
- [Prompt caching](https://usefewertokens.com/techniques/prompt-caching/): fits. cache_control on the Claude API; automatic on OpenAI.
- [Let the agent run code over results](https://usefewertokens.com/techniques/code-execution/): fits. Programmatic tool calling on the Claude and OpenAI APIs; Pi codemode.
- [Clear old tool results](https://usefewertokens.com/techniques/context-editing/): fits. Context editing and compaction on the Claude API.
- [Cap tool output](https://usefewertokens.com/techniques/output-caps/): fits. Reshape results with toModelOutput in the Vercel AI SDK.
- [Read web pages as text](https://usefewertokens.com/techniques/browser-snapshots/): fits. Text snapshots, or filtered web search and fetch on the Claude API.
- [Run side tasks on a smaller model](https://usefewertokens.com/techniques/smaller-subagents/): fits. Route side tasks to a smaller model.
- [Lower the effort setting](https://usefewertokens.com/techniques/effort/): fits. The effort parameter on the Claude API.
- [Batch scheduled jobs](https://usefewertokens.com/techniques/batch/): fits. Message Batches API, 50% off.
- [Keep instruction files short](https://usefewertokens.com/techniques/instruction-files/): partly. Keep the system prompt short.
- [Measure what fills the window](https://usefewertokens.com/techniques/audit-commands/): partly. Log input tokens per request.

## Links
- Optimizer set to Mastra: https://usefewertokens.com/harnesses/mastra/
- How to reduce AI agent token usage: https://www.stackone.com/blog/reduce-ai-agent-token-usage/
