Cache results of a custom AI or code tool
A custom AI or code tool can reuse a recent result when it is called again with the same inputs. Later work items, later steps, Try It, and the tool's own tests can then skip running the tool — including any tools it would have called.
This is off by default. Turn it on only when the tool reads data and does not change anything. Spreadsheet Lookup, database, API, document template, and tool-wrapper tools do not have this setting.
Result caching is not the same as the cheaper cached prompt tokens an AI model may use. Those show up as a cache hit rate on cost views. See Token Costs. This article is about reusing the tool's output.
How to build the tool is in Custom Tools. For the JavaScript a code tool can run, see How custom code tools work.
When to turn it on
Turn Reuse identical lookups on when all of these are true:
The same inputs should produce the same answer for a while — a lookup, a classification, a calculation — not a one-off write.
The tool does not create, update, or delete anything, send a message, or otherwise change a system.
Tools this tool would call are also safe to skip. A reused result does not call them. An AI tool that would search the web, or a code tool that would
await tools.send_email(...), does none of that on a cache hit.A slightly older answer is acceptable for the reuse window you set.
Leave it off when the tool must run every time: sending mail, writing a record, charging a card, minting a unique id, or reading a value that must be this instant's value.
The setting is an assertion you make. Thunk.AI does not infer it from the tool's name or type.
Turn it on
Open Custom-built tools, select the AI or code tool, and open the Implementation tab.
Open Behavior. The closed header already summarizes the section; when reuse is on it includes caches results.
Under Result caching, turn on Reuse identical lookups.
Set Reuse for (seconds) — how long an identical lookup may reuse a stored result. The default is 60 seconds. One day is
86400. The most you can set is 7 days.
The caption under the controls repeats the rule: only turn this on when the tool reads data and does not change anything.
An AI assistant that builds the tool through the Builder MCP can turn on the same reuse setting and, after you change what the tool does, clear the cache so stored results are not reused. See Build thunks with the Builder MCP.
What a reused result does
When a later call has the same inputs and a stored result is still within the reuse window:
The tool does not run. An AI tool does not start its nested agent. A code tool does not run its function.
Tools it would have called are not called.
Call history still records the call, marked cache hit. A miss — the tool ran — is marked cache miss. A hit on an AI tool has no nested run to expand: the tool's agent did not start.
A hit does not add model or tool cost for that call, because the work was not done again.
For how to read Call history, including cost and time views, see Tool call history and performance.
Try It, the tool's unit tests, and live runs share one cache. A Try It call can be reused by a test or a work item with the same inputs, and the other way around.
A reused result stays on this thunk. A different environment, a different connected account, or a step running as a different person does not reuse it.
Clear the cache
Changing the tool's instruction or code does not forget stored results. Identical inputs will keep getting the previous answer until the reuse window ends.
Clear cache (next to the duration, while reuse is on) makes every stored result miss. The next identical lookup runs the tool again. It does not turn reuse off and does not change the duration.
Clear the cache when you:
change the tool's instruction, code, inputs, or outputs
change which tools it may call, in a way that should change the answer
need a fresh read of data that may have changed inside the reuse window
When a call still runs the tool
A later call with reuse on still runs the tool when:
the inputs are not the same
the reuse window has ended
you (or an assistant) cleared the cache
the earlier call failed — failures are not reused
the result was a file, or included a link that expires
a person has to approve the call
the call is in a different environment, for a different connected account, or for a different person
Using it
A lookup many work items repeat. A code tool that resolves a country code, or an AI tool that classifies the same document type, can reuse the answer for the window you set instead of paying for every work item.
After you edit the tool. Clear the cache, then use Try It or tool tests so you are not looking at an old stored result.
When a nested send or write did not happen. Check Call history for a cache hit. If the tool is not a pure read, turn reuse off.
