Change settings every turn
What you can change per turn
TypeScript, Python, PHP, and Ruby take a function in place of the fixed field. Go, C#, and Java use separate callback fields next to the fixed
Model and Instructions. In TypeScript, tools left out of activeTools stay callable, so earlier calls still resolve.
The turn argument has the same four values in every language:
In Python, a
model or preset passed to run() replaces the definition’s model for every turn.
Update application context from a tool
A tool can replace the application context that later turns read:context.setContext() in TypeScript, runtime.set_context() in Python, and the equivalents in Tools. Keep context small and serializable when you save runs and continue them later.
Override only the next turn
Set next-turn parameters on a tool to change the request that immediately follows it, without changing the agent definition. They win over the per-turn functions for that one turn.
Use per-turn functions for policy you want recalculated every turn, and next-turn parameters for a one-off handoff from a specific tool.
Set the model per run in Rust
Rust’sphaseo-agent 0.2 has no per-turn callbacks, context updates from tools, or next-turn parameters. Set the model, step limit, and application context per run with RunOptions: