Deep Query
Call the _s1query tool over MCP or the API.
Data Sync on the list action, then list_tickets_s1query({ filter, source, aggs })
Describe its job and get the fixes that cut its tokens and wait time, ranked for your harness.
StackOne agentFixing your agent
Example result
Claude API and Agent SDK
Zendesk List Tickets
Your agent answers in 0.6 s, not 2.4 min
Same question, answered from a synced copy of your Zendesk data: 50 live calls become 2 reads.1,2
| Switch | Setting | Today | With fixes |
|---|---|---|---|
| Deep Query | 50 live calls · 2.4 min | 2 reads · 0.6 s | |
| Load tools when needed | 72 tools · 25K tokens | 2 tools · 7.3K tokens | |
| Model | Opus 5.5 $29 a month | Haiku 5.5 $0.73 a month | |
| Thinking | High effort | Low effort | |
| Prompt cache | Prefix sent fresh | Prefix cached | |
| Old results | Kept in context | Cleared |
Data Sync keeps a copy of Zendesk List Tickets, so 5,000 records take 2 reads instead of 50 live calls.
The live API returns 100 a page.
Waiting 2.4 min → 0.6 s at production averages; 33% to 74% fewer tokens per connector on 1,345 benchmark tasks.2
Data Sync on Zendesk List Tickets
list_tickets_s1query with filter, source and aggs
72 tool definitions, about 25K tokens, go out with every request before the first word.
Tool Search was 3.8x cheaper per request than loading every tool across 824 tasks. Anthropic reported over 85% fewer tool-definition tokens with its own tool search.3
Add https://mcp.stackone.com/mcp; "Load tools when needed" is on by default (Project Settings, General, MCP Settings, or ?tool-mode=search_execute)
defer_loading: true on your tools, plus the tool_search_tool_bm25_20251119 tool
This task doesn't need Opus 5.5.
Haiku 5.5 for counts and lookups, Sonnet 5.5 for filtering and summarising, Opus 5.5 for multi-step work. This one is counts, totals and lookups, where Deep Query or the API does the work and the model reads one small result, so Haiku 5.5 fits. Check it on your own runs first.
Over 1,000 runs, the 7.3K tokens of tool definitions per request cost $29 a month on Opus 5.5, $15 on Sonnet 5.5 and $0.73 on Haiku 5.5, at list input prices.
model: "claude-haiku-5-5"
The same tools and system prompt open every run, so the prefix can be cached.
Cache hits bill at $0.20 per million tokens on Claude Opus 5.5 and $0.10 on Sonnet 5.5 (0.05x their input price), and $0.01 on Haiku 5.5 (0.1x).5
cache_control: {"type": "ephemeral"} after the tools and system prompt
Long sessions keep every old tool result in context.
Beta: context_management with clear_tool_uses_20250919, or server-side compaction
Keep the live action for questions about one record or the provider's state this minute.
Keep the live action next to the _s1query tool
Counting and retrieval rarely need high effort.
effort: "low" for high-volume or latency-sensitive work (the default is high, or medium on Opus 5.5 and Haiku 5.5)
Narrow which actions and fields the agent can use, per project.
No token figure: it's a control.
Tool Policies on the project
Sources
This result
list_tickets, Data Sync available).How every result is worked out
Benchmark and production figures are explained on the Deep Query page and the Tools Discovery page. Your own systems will differ.
Want us to look at your agent with you?
Go through your harness, your apps and these numbers with our engineers.
Pick yours for the three to start with, or open the comparison of all 16 under it.
Call the _s1query tool over MCP or the API.
Data Sync on the list action, then list_tickets_s1query({ filter, source, aggs })
Tool Gateway MCP, or the SDK's own tool search.
Add https://mcp.stackone.com/mcp; Advanced Tool Search is on by default
defer_loading: true on your tools, plus the tool_search_tool_bm25_20251119 tool
defer_loading on your tools with the tool search tool (gpt-5.4 and later)
toolSearch() with deferLoading on your tools
ToolSearchProcessor
On by default: MCP tools default to codemode exposure, so scripts find them with searchTools() instead of every tool loading up front
cache_control on the Claude API; automatic on OpenAI.
cache_control: {"type": "ephemeral"} after the tools and system prompt
On by default: long, repeated prefixes are cached automatically; keep the prefix stable
Then
/context, /usage, /skill-doctor in Claude Code.
/context, /usage, /skill-doctor, /doctor prompt-audit
Disable servers and tools you don't use.
/mcp to switch off servers you don't use; prefer CLIs such as gh over an MCP server
enabled_tools or disabled_tools per MCP server; tool_input_schema_max_bytes trims long schemas (default 5,000)
"disabled": true on an MCP server, or a deny permission for its tools
Through the Tool Gateway MCP.
Add https://mcp.stackone.com/mcp, then ask in plain words
Then
One Tool Gateway MCP server exposes two tools.
Add https://mcp.stackone.com/mcp; it exposes 2 tools and finds the rest
On by default: tool search hands agents a small set of the MCP tools that fit each request
On by default: tool access "Auto" loads connectors as needed; "On demand" defers every connector
Through the Tool Gateway MCP.
Add https://mcp.stackone.com/mcp as one MCP server
Copilot Studio and Gemini Enterprise cap tools per agent.
Switch individual tools off on the app's details page in settings
Keep 25 to 30 tools per agent
Enable only the actions the agent uses
Then
One MCP server with Advanced Tool Search in n8n.
MCP Client Tool pointed at https://mcp.stackone.com/mcp
Zapier suggests 3 to 5 actions per agent.
MCP Client Tool: Tools to Include, "Selected"
3 to 5 actions per agent
Select only the MCP tools the agent needs; extra servers and tools raise token use
Keep the live action next to the query tool.
Keep the live action next to the _s1query tool
Then
| YesPartlyNoNot confirmed on the vendor's page Open a technique for what it does and where to read more | ||||
| Technique | Your own agent | Coding agents | Enterprise assistants | Workflow tools |
|---|---|---|---|---|
| Query instead of paging | ||||
| Call the _s1query tool over MCP or the API | Through the Tool Gateway MCP | Through the Tool Gateway MCP | n8n's MCP Client Tool; Zapier and Make not confirmed | |
Deep QueryDeep Query answers counts, filters and totals from a synced copy of a list action, so the agent gets one result instead of paging through every record. Data Sync keeps the copy fresh, and the agent calls the matching _s1query tool with a filter, the fields it needs and any aggregation. 33% to 74% fewer tokens per connector across 1,345 benchmark tasks; 0.3 s per read against 2.9 s per live call in production StackOne benchmark | ||||
| Keep the live action next to the query tool | Keep the live action next to the query tool | Keep the live action next to the query tool | Keep the live action next to the query tool | |
Keep live questions liveSynced data reflects the last sync, so a question about the provider's state this minute, or a single record you already know, belongs on the live action. Keep both tools available and let the agent choose per question; for one known record, the live call is already the shortest path. | ||||
| Programmatic tool calling on the Claude and OpenAI APIs; Pi codemode | Experimental in Claude Code and Codex, on by default in OpenCode | Not offered in enterprise assistants | Use a code step instead | |
Let the agent run code over resultsWhen a task chains many tool calls, the agent can write a short program that calls the tools and returns only the final result, so intermediate results stay out of context. Anthropic and OpenAI call it programmatic tool calling; Pi runs it by default, OpenCode runs its MCP tools through it by default, and Claude Code and Codex have an experimental code mode. Anthropic reported 37% fewer tokens, and no gain on flows of one or two calls Vendor-reported | ||||
| Load fewer tools | ||||
| Tool Gateway MCP, or the SDK's own tool search | Claude Code and Cursor do it by default | One Tool Gateway MCP server exposes two tools | One MCP server with Advanced Tool Search in n8n | |
Load tools when neededInstead of sending every tool definition on every request, the agent sees a search tool and loads the few definitions a task needs. StackOne's Tool Gateway MCP does this with Advanced Tool Search, on by default; several harnesses also offer their own tool search for tools defined in code. 3.8x cheaper per request than loading every tool, across 824 tasks; Anthropic reported over 85% fewer tool-definition tokens with its tool search StackOne benchmark | ||||
| Filter the tool list per step | Disable servers and tools you don't use | Copilot Studio and Gemini Enterprise cap tools per agent | Zapier suggests 3 to 5 actions per agent | |
Turn off tools you don't useEvery enabled tool costs tokens on every request where definitions load up front, and a long tool list makes the right one harder to pick. Most harnesses let you switch off whole servers or single tools, and several enterprise assistants cap how many tools one agent can hold. | ||||
| Keep the system prompt short | CLAUDE.md under 200 lines; Cursor rules under 500 | Keep agent instructions short | Keep the agent prompt short | |
Keep instruction files shortInstruction files such as CLAUDE.md and Cursor rules load into every session, so every line is paid for on every run. Keep them short, move detail into skills or docs the agent opens when needed, and check what loads at the start of a session. | ||||
| Return less | ||||
| source on any _s1query call | source on any _s1query call | source on any _s1query call | Where the workflow calls _s1query | |
Ask for fewer fieldsA live list action returns whole records, so a question about two fields still reads every field. Deep Query's source parameter returns only the fields the answer needs, which keeps large lists out of the context window. The saving depends on how wide the records are. One benchmark list went from 1.33M tokens to 18.9K for the same correct answer One benchmark example, not a forecast | ||||
| Context editing and compaction on the Claude API | /compact and automatic compaction | Handled by the vendor | Runs are short | |
Clear old tool resultsLong sessions keep every earlier tool result in context, and most of it is never read again. Context editing drops stale tool results as the conversation grows, and compaction summarises older turns. Both keep long runs inside the window without starting over. | ||||
| Reshape results with toModelOutput in the Vercel AI SDK | MAX_MCP_OUTPUT_TOKENS, tool_output_token_limit | No setting exposed | Cap history and output in Make | |
Cap tool outputA single chatty tool response can fill the window. Coding agents and SDKs let you cap how many tokens one tool result may return, or reshape the result before the model sees it, so one broad list call can't crowd out the rest of the task. | ||||
| Text snapshots, or filtered web search and fetch on the Claude API | agent-browser or Playwright CLI with a skill | The vendor's browsing tool decides | Fetch the page as text, not a screenshot | |
Read web pages as textAn agent that browses by screenshot or by reading raw HTML pays for every pixel and tag. Open-source tools such as agent-browser and Playwright return the page as compact text with a ref per element. On the Claude API, web search and fetch can filter results in code first. | ||||
| Pay less per token | ||||
| cache_control on the Claude API; automatic on OpenAI | The harness caches for you | The vendor caches for you | Depends on the model node | |
Prompt cachingWhen every run opens with the same tools and system prompt, the model provider can cache that prefix and bill repeat reads at a fraction of the input price. Put stable content first and changing content last, so the cached prefix survives from one run to the next. Cache hits bill at $0.20 per million tokens on Claude Opus 5.5 and $0.10 on Sonnet 5.5 (0.05x their input price), and $0.01 on Haiku 5.5 (0.1x) Published list price | ||||
| Route side tasks to a smaller model | model: haiku in a Claude Code subagent | The vendor picks the model | Pick the model per node | |
Run side tasks on a smaller modelSearching, reading files and summarising rarely need a frontier model. Coding agents let a subagent run on a smaller, cheaper model and hand back only its conclusion, which keeps both the bill and the main context smaller. | ||||
| The effort parameter on the Claude API | /effort in Claude Code | The vendor picks | Where the model node exposes it | |
Lower the effort settingReasoning effort sets how much the model thinks before answering. Retrieval and counting tasks rarely need high effort, so lowering it cuts output tokens and latency. Check completion on your own tasks before and after, because a cheaper failed run costs more than a dearer successful one. | ||||
| Message Batches API, 50% off | Interactive | Interactive | Scheduled runs only | |
Batch scheduled jobsJobs nobody waits on, such as nightly reports, can go through a batch API at a discount in exchange for a slower turnaround. It suits scheduled workflows, not an assistant answering a person. Anthropic's Message Batches API bills at 50% of standard prices Published list price | ||||
| Measure and govern | ||||
| Log input tokens per request | /context, /usage, /skill-doctor in Claude Code | No per-request view | Execution logs show each step | |
Measure what fills the windowBefore changing anything, look at what fills the context window. Claude Code shows it per source with /context, ranks skills by context cost against use with /skill-doctor, and suggests fixes from /usage. Measure again after each change, on the same tasks. | ||||
| Per project in StackOne | Per project in StackOne | Per project in StackOne | Per project in StackOne | |
Tool PoliciesTool Policies narrow which actions an agent can call and which fields it can read, per project. Fewer allowed actions means fewer definitions to load and fewer wrong turns. Rules apply to synced reads too: a refused action's copy is refused, and withheld fields are masked. | ||||
For one harness at a time, with each setting and its source, see the harness guides on usefewertokens.com.
Let your agent run it. Any agent that can make an HTTP request can use the optimizer.
Use StackOne's AI agent token optimizer on my agent.
POST https://www.stackone.com/api/v1/token-optimizer/ with JSON {"task": "[what the agent does, naming the apps]", "segment": "build" | "coding" | "enterprise" | "workflow", "harness": "[for example claude-api, claude-code, copilot-studio, n8n]", "records": [how many records a question covers], "runs_per_month": [number]}, or call the optimize_agent_tokens tool if this browser offers it on stackone.com.
Tell me the lead number, the fixes that apply with the exact setting for my harness, and which inputs were assumptions. FAQ
The AI agent token optimizer takes where your agent runs and what it does, matches the apps and list actions involved in StackOne's catalogue of 640+ connectors, and ranks the token and latency fixes that apply to that harness, with the exact setting to turn each one on.
Reduce an AI agent's token usage by loading tool definitions only when needed, answering counts and filters with a query instead of paging through records, asking for fewer fields, caching the stable part of the prompt and clearing old tool results. Which of these matter depends on the harness and the question.
Deep Query doesn't always help. It helps when a question covers many records and takes more than one live page. For one known record, or for the provider's state this minute, the live action is the right tool, and the optimizer says so.
Claude Code already loads MCP tool definitions when needed, so tool search is on by default there. The fixes that matter more in coding agents are capping tool output, keeping CLAUDE.md short, running side tasks on a smaller model and checking /context.
Enterprise assistants cap tools per agent: Copilot Studio allows 128 and Microsoft suggests 25 to 30, and Gemini Enterprise allows 100 enabled actions on a custom MCP server. One StackOne Tool Gateway MCP server with Advanced Tool Search exposes two tools and finds the rest per task.
The model your agent needs depends on the task. Counts and lookups that a query does for the agent run well on a small model such as Claude Haiku 5.5. Filtering and summarising suits Claude Sonnet 5.5 at low or medium effort, and multi-step work suits Opus 5.5. Compare cost per completed task on your own runs.
Your question isn't stored. It's sent in the body of a request, never in a URL, and used only to work out the result. Share links carry the agent type, harness, apps and counts, not the question. You don't connect a system or create an account.
Your own agent can use the optimizer. It's a public endpoint at POST /api/v1/token-optimizer/, described in the website API docs, and browsers that support WebMCP expose it on stackone.com as the optimize_agent_tokens tool.
One Tool Gateway MCP server for 640+ connectors, with Advanced Tool Search and Deep Query.