Skip to content

fix(llm): stop sending DashScope-only enable_thinking to official OpenAI - #39

Open
Voyagerroc-Lab wants to merge 1 commit into
Forget-C:mainfrom
Voyagerroc-Lab:fix/openai-enable-thinking-400
Open

Voyagerroc-Lab wants to merge 1 commit into
Forget-C:mainfrom
Voyagerroc-Lab:fix/openai-enable-thinking-400

Conversation

@Voyagerroc-Lab

Copy link
Copy Markdown

Fixes #38

What was wrong

thinking=False paths injected extra_body["enable_thinking"] = False unconditionally. enable_thinking is a DashScope/Qwen extension — the official OpenAI API rejects it with 400 Bad Request: Unknown parameter: 'enable_thinking', so every storyboard/dialogue extraction run against api.openai.com failed (as reproduced in the issue, where the reporter also verified that switching to reasoning_effort="none" unblocks the official endpoint).

The same unconditional bind also existed in AgentBase.__init__, so every agent sent enable_thinking to the official API regardless of its value.

What changed

Three call sites now branch on the target endpoint:

  • backend/app/services/llm/resolver.py (_build_chat_openai_model)
  • backend/app/services/llm/runtime.py (build_default_text_llm_sync)
    • official OpenAI (api.openai.com, or no custom base_url) → kwargs.setdefault("reasoning_effort", "none")
    • DashScope-style compatible endpoints → unchanged extra_body["enable_thinking"] = False
  • backend/app/chains/agents/base.py (AgentBase.__init__) — the unconditional self._model.bind(extra_body={"enable_thinking": ...}) is replaced by _thinking_extra_body(model, self.enable_thinking), which returns None (nothing bound) for official-OpenAI targets and the previous body for compatible endpoints, using the model's openai_api_base.

setdefault keeps any user-configured reasoning_effort from model.params intact.

How did you verify?

  • python -m py_compile passes for all three touched files.
  • Official-OpenAI case (base_url empty or api.openai.com): no enable_thinking key reaches the wire; reasoning_effort="none" is sent only when the caller did not set one.
  • DashScope case (custom base_url): behavior is byte-identical to before.

中文摘要enable_thinking 是 DashScope 扩展参数,官方 OpenAI API 会返回 400。现在三个调用点都会按端点区分:官方 OpenAI 使用 reasoning_effort="none",DashScope 兼容端点保持原有 enable_thinking 行为。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OpenAI models fail when thinking=False due to unsupported enable_thinking parameter

1 participant