> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamic turns

> Change routing, instructions, tools, and sampling settings between PHP agent turns.

Dynamic callbacks recalculate model parameters from the current run state before each model request.

```php theme={null}
$agent = AgentSdk::createAgent(new AgentDefinition(
    id: "support-agent",
    model: fn ($turn) => $turn->run->stepCount > 3
        ? "openai/gpt-5.4"
        : "openai/gpt-5.4-nano",
    instructions: fn ($turn) => "Resolve the request using the current context."
));
```

Dynamic tools and sampling values can use the same turn context. A tool can also set `nextTurnParams` to modify only the immediately following request. These overrides are persisted when the run pauses for approval and expire after the next turn.

Use dynamic callbacks for policy that should be recomputed every turn. Use `nextTurnParams` for a tool-specific handoff.
