Next Turn Params
Build encapsulated, context-aware tools with nextTurnParams. Create skills systems, plugins, and adaptive multi-turn agents.
Build encapsulated, context-aware tools with nextTurnParams. Create skills systems, plugins, and adaptive multi-turn agents.
Traditional tool execution returns results to the model, but sometimes you need more:
With nextTurnParams, tools can modify any callModel parameter for the next turn.
This example shows how to recreate Claude Code’s skills system as a single encapsulated tool:
Understanding when nextTurnParams runs is crucial:
nextTurnParams functions receive two arguments:
The validated input parameters that were passed to the tool:
The current request context, including:
You can modify CallModelInput parameters:
Build up context as research progresses:
Upgrade to better models when needed:
Load multiple skills at once:
Adapt to user language preferences:
Always check if context was already added:
Use proper typing for context access:
Only modify what’s necessary: