Skip to content

workers-ai-provider: modelSettings not forwarded to inputs — reasoning_effort and chat_template_kwargs silently ignored #501

Closed

Description

@alexander-zuev

Problem

modelSettings passed to the provider (2nd arg of workersAi(modelId, modelSettings)) are forwarded to getRunOptions() which becomes the 3rd argument (options) of binding.run(model, inputs, options).

However, Cloudflare Workers AI parameters like reasoning_effort and chat_template_kwargs belong on the inputs level (2nd argument of binding.run()). buildRunInputs() only constructs inputs from AI SDK-mapped args (max_tokens, temperature, top_p, response_format, tools, tool_choice) and never includes anything from modelSettings.

This means these parameters are silently dropped:

const workersAi = createWorkersAI({ binding: env.AI })

// reasoning_effort ends up in runOptions (3rd arg), not inputs (2nd arg)
const model = workersAi('@cf/zai-org/glm-4.7-flash', {
  reasoning_effort: 'low',
})

// chat_template_kwargs also silently dropped
const model = workersAi('@cf/zai-org/glm-4.7-flash', {
  chat_template_kwargs: { enable_thinking: false },
})

Affected parameters

From @cloudflare/workers-types (ChatCompletionsCommonOptions):

  • reasoning_effort — "low" | "medium" | "high" | null
  • chat_template_kwargs — { enable_thinking?: boolean, clear_thinking?: boolean }

Both are typed on the inputs object and accepted by binding.run(), but the provider never puts them there.

Where it breaks

In [email protected]:

  • buildRunInputs() in workersai-chat-language-model.ts — hardcoded field list, no passthrough from settings
  • getRunOptions() in workersai-chat-language-model.ts — rest-spreads settings into options (wrong destination for these params)

Impact

GLM-4.7-flash, Kimi K2.5/K2.6, and any other reasoning model on Workers AI cannot have reasoning controlled via the provider. In our case, GLM-4.7-flash burned all 16,384 output tokens on an infinite reasoning loop because reasoning_effort: 'low' was silently ignored, causing AI_NoOutputGeneratedError after exhausting retries.

Expected behavior

reasoning_effort and chat_template_kwargs from modelSettings should be included in the inputs payload passed to binding.run().

Versions

Activity

  1. Specy commented on Apr 23, 2026

    @Specy
    Contributor

    I came across this issue when trying to disable thinking in Kimi models, once fixed it would also be nice to document in the docs as it's not mentioned currently

  2. added a commit that references this issue on Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions