Skip to content

fix(agent): derive NextTurnParamsContext.models from the SDK request type - #134

Draft
LukasParke wants to merge 1 commit into
mainfrom
fix/next-turn-params-models-type
Draft

LukasParke wants to merge 1 commit into
mainfrom
fix/next-turn-params-models-type

Conversation

@LukasParke

@LukasParke LukasParke commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Port of OpenRouterTeam/typescript-sdk#821. NextTurnParamsContext.models is now typed as NonNullable<models.ResponsesRequest['models']> instead of the hand-written string[] (packages/agent/src/lib/tool-types.ts).

Why

openrouter-web#34136 adds reason-gated fallback entries, which turns models into (string | ReasonGatedFallbackModel)[]. A hand-written string[] would then stop type-checking against the generated request type. Deriving the type from the request keeps the two in sync.

Compatibility

  • This change is forward-compatible. The pinned @openrouter/sdk@0.13.7 still types ResponsesRequest.models as Array<string>, so today the type stays string[] and nothing changes. The latest published SDK (1.4.25) is also still Array<string>.
  • The only consumer on main, buildNextTurnParamsContext, assigns request.models ?? [], which already has this type.
  • Once the SDK regenerates, code that reads context.models[i] as a string will need to narrow it. Nothing on main does that today. Open PR fix(agent): populate primary model from models fallback array (#121) #124 reads models[0] from the request, not from this context, and already guards it with a typeof string check.

Testing

pnpm typecheck, pnpm lint and the unit tests pass. Added a patch changeset.

🤖 Generated with Claude Code

…type

Port of OpenRouterTeam/typescript-sdk#821. Replace the hand-written
string[] with NonNullable<models.ResponsesRequest['models']> so the field
accepts reason-gated fallback entries once the spec regenerates
(openrouter-web#34136). With @openrouter/sdk 0.13.7 the type is still
string[], so this is a no-op today.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant