Learning resourcesReviewed · OpenRouter

OpenRouter Agent SDK: Next Turn Params

OpenRouter's Next Turn Params guide teaches agent developers to let tools change the next AI request, but some examples need correction before use. It covers skill loading, conversation updates, model switching and generation settings through the OpenRouter Agent SDK.

Researched 15 Nov 2026

In short.

OpenRouter's Next Turn Params guide shows agent developers how tools can change the next AI request, but several sample patterns are incomplete or internally inconsistent. It explains callbacks that update conversation history, instructions, model choice and generation settings after tool execution. Its strongest contribution is the explanation of callback timing and tool-local context management. The complexity-routing example reads a field absent from its input schema, and the first skill loader does not explicitly insert the marker used to prevent duplicate loading. No code was executed; runtime behavior, compatibility, reliability and costs remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete supplied page at [https://openrouter.ai/docs/agent-sdk/call-model/next-turn-params.md], including all examples and the documentation-index notice. The linked index, Skills Loader Example, Dynamic Parameters and Stop Conditions pages are excluded. No code, API requests or model calls were executed. Runtime behavior, model availability, performance, security behavior and costs were not assessed through execution.

The overview

Resource and scope

This is an OpenRouter documentation guide to nextTurnParams, a feature used with tools and callModel in the Agent SDK. The original page is [https://openrouter.ai/docs/agent-sdk/call-model/next-turn-params.md]. It is instructional material with TypeScript examples, rather than a standalone application or a ready-made skill package.

Practical value

The guide is useful when a tool should manage the instructions or request settings needed after it is called. It explains how that behavior can stay inside the tool definition, reducing what callers need to know about skill files or context changes.

Treat the examples as implementation patterns requiring review. The page explains the intended mechanism, but it supplies no execution results, reliability measurements or evidence that these patterns improve answer quality.

Who it suits

The main audience is developers building agents that make repeated model requests and call tools between them. Relevant projects include assistants that load specialized instructions, change response language or adjust model settings as a conversation progresses.

Beginners will need familiarity with TypeScript functions, message history and schema validation. Experienced developers can use the execution-order details to assess how several tools might change the same request. The page assumes existing SDK setup and does not provide complete onboarding.

What it documents

The examples change input messages, system instructions, the selected model, temperature and the maximum output-token setting. The documented context also includes fallback models, topP and topK. The page broadly states that nextTurnParams can modify callModel parameters.

Demonstrated patterns include expert-mode instructions, single and multiple skill loading, research-related context, complexity-based model selection and language switching. These are illustrated uses, not verified guarantees of correct skill loading, routing or generated answers.

Using it

Dependencies and prerequisites

The examples import tool from @openrouter/agent and use Zod for input and output schemas. File-based skill examples also depend on filesystem access through helpers such as readFileSync and existsSync, with instruction files available locally.

The usage example assumes an initialized openrouter object. Installation commands, client initialization, authentication setup, dependency versions and supported runtime versions are not provided. The multi-skill snippet uses existsSync without showing its import.

How updates happen

The documented sequence starts with the model requesting tool calls. All tool execute functions run, followed by nextTurnParams callbacks in tools-array order. The resulting parameters are used for the next model turn, and the cycle repeats while the model continues requesting tools.

Each callback receives params, meaning validated tool inputs, and context, meaning current request values. The page does not document a separate argument containing the execute result. It also leaves unspecified how conflicting updates combine, whether later callbacks observe earlier updates, and how callback failures affect the loop.

Adapting the examples

The demonstrated integration is to define a tool with schemas, implement execute, attach nextTurnParams callbacks and include the tool in callModel's tools array. Existing instructions are preserved in several examples by reading context.instructions before appending new text.

File-based examples need additional work. Their paths begin with ~, which the shown Node filesystem calls do not automatically expand to a home directory. Resolve the intended directory explicitly, provide the missing filesystem imports and restrict skill names to approved paths. Some snippets also spread context.input as an array, while the multi-skill example explicitly handles an input that is not an array.

A straightforward example

The expert-mode tool accepts a domain string and returns an enabled flag. Its nextTurnParams callbacks preserve existing instructions, append domain-specific guidance and set temperature to 0.3 for the next request.

For a domain such as Kubernetes, the intended result is a subsequent model request containing guidance to give detailed technical explanations and examples. The page does not establish that this temperature or instruction text improves accuracy. This example was not executed.

Assessment & evidence

Important example gaps

The complexity analyzer declares only code in its input schema, but its callbacks read params.complexity. The computed complexity comes from execute, whereas the page defines params as validated tool input. As written, the example does not show how the computed result reaches the model-selection or temperature callbacks.

The first skill loader checks for a message containing Skill followed by the skill name and is already loaded, but its normal return value and injected message do not explicitly add that marker. Reliable duplicate prevention is therefore not established. The later multi-skill example does explicitly add the marker it checks.

Skill names are unrestricted strings used in filesystem paths, and file contents are inserted into future conversation messages. The examples do not show path containment checks, file-size limits or handling for unreadable files. These gaps require attention before adopting file loading in an application.

Design implications

Keeping context changes inside a tool is attractive when activating that tool should consistently change subsequent requests. It also means tool definitions control more than their returned data: they can alter instructions, retained messages and model choice.

The documented ordering makes overlapping updates important to review. Two tools changing instructions or the model may interact, and repeated appends may grow the conversation. Use explicit duplicate markers and small updates, and do not assume a callback receives execution results merely because it runs after execute. Loading instruction files also requires a deliberate decision about which files the application trusts.

Simpler approaches and related material

The page contrasts this hook with ordinary tool execution that returns results to the model. Returning tool data may be sufficient when no instructions or request settings need to change. Fixed request parameters are another simpler design when behavior does not depend on tool activation.

The guide names Claude Code's skills pattern as inspiration, but provides no comparison establishing equivalent behavior. It links to Skills Loader Example, Dynamic Parameters and Stop Conditions; those pages are outside this scope, and their contents were not assessed.

Evidence and confidence

The evidence is the complete supplied documentation page at [https://openrouter.ai/docs/agent-sdk/call-model/next-turn-params.md], including its explanations, context table and embedded examples. It supports describing the documented interface and identifying inconsistencies visible in those examples.

No SDK implementation, execution traces, benchmark results or completed application journey are included. Conclusions about example gaps come from reading the supplied code. Actual runtime behavior, performance and production reliability remain unverified.

Access & freshness

Costs and usage

The page supplies no prices, token totals or cost measurements. SDK charges, model-request rates and infrastructure costs are unknown from this evidence.

Appending instructions can increase context size, repeated tool calls can lead to additional model turns, and callbacks can change the model. These are potential cost drivers inferred from the documented behavior; their financial effect was not measured.

Licensing and permissions

The supplied page states no license for its documentation or code examples and provides no redistribution terms. Permission to copy, adapt or redistribute these materials is not established by this source. Service terms and the rights attached to locally loaded skill files are also unspecified.

Dates and compatibility

The supplied page was captured at 2026-11-15T16:27:47.908Z. It states no publication date, SDK release version or compatibility range, so the capture date does not establish when the examples were last updated.

The model identifiers anthropic/claude-sonnet-4.5 and openai/gpt-5-nano appear in examples. Their current availability, pricing and compatibility with the illustrated requests are not established by this page.

What to verify before adoption

Begin with a small change such as the expert-mode or language callback, then confirm that the intended instructions and settings reach the next request in your environment. Establish the SDK version, initialization requirements and applicable model pricing before estimating implementation effort or operating cost.

Before using the more complex patterns, correct the complexity-result handoff, repair the first loader's duplicate marker and resolve filesystem paths explicitly. Check repeated skill activation, missing files and overlapping tool updates. Confirm applicable documentation, code and skill-file permissions before copying or distributing materials.

Evidence for this report

selected-page.txtselected · checked 2026-11-15