-
### Codemode In the traditional approach, the agent calls tools one by one, and each response enters the context in full. In Codemode, the model writes a short script: the script calls the required tools, filters the data, and returns only the result to the model. In a publication on code execution with MCP, Anthropic gave an example where this approach reduced usage from 150,000 to 2,000 tokens, a 98.7% reduction.
-
Savings in a specific project depend on the task, but the order of magnitude is illustrative. ### Lazy tool loading
-
The agent keeps a short tool catalog in context and loads the full description only for the tool needed at the current step.
-
Forty connected systems no longer occupy memory during steps where they are not involved. ### Cache warming
-
Providers cache the unchanged beginning of a request: the system prompt, instructions, and tool descriptions. With Anthropic, reading from the cache costs about 10% of the base price for input tokens.
-
During cache warming, this prefix is sent in advance, so the user's first real request is cached and the response arrives faster. ###
-
Durable execution is a long-established integration technique: after each step, the process state is saved, and after a failure, the process resumes from the last checkpoint.
-
If an external API fails on the agent's thirtieth step, durable execution allows that single call to be retried.
-
Without it, the task must be restarted and the tokens paid for a second time.
-
This describes the principle; the implementation in Pi Durable should be verified in the project documentation.