Skip to content

OpenRouter provider: thinking mode causes crash with non-Anthropic models (e.g. GPT-4o) #427

@yuxianzhao0921-del

Description

@yuxianzhao0921-del

问题概述

通过 OpenRouter 接入非 Anthropic 模型(如 openai/gpt-4o-2024-05-13)时,发送消息必定失败,因为 Claude Code SDK 会自动发送 extended thinking 参数,而这些模型不支持该参数。

复现步骤

  1. 设置 → 服务商 → 添加 OpenRouter
  2. 新建对话,选择 OpenRouter 服务商
  3. 选择非 Anthropic 模型(如 GPT-4o)
  4. 发送任意消息

期望行为

对非 Anthropic 模型不发送 thinking/extended thinking 参数,正常完成对话。

实际行为

界面显示"深度思考中...",随后 Claude Code 进程报错退出:

Error: Claude Code process exited with an error (Provider: Sage-GPT-4o).
Common causes: • Thinking mode may not be supported

服务端日志:

[claude-client] Stream error: {}

排查过程

  1. src/app/api/chat/route.ts 第 226 行,尝试将 thinking 参数对非 Anthropic sdkType 设为 undefined,但 SDK 内部仍会自动启用 thinking
  2. src/lib/db.ts 第 844 行的迁移逻辑会在每次启动时删除所有 openai-compatible 协议的服务商记录,无法通过 OpenAI 兼容协议绕过
  3. provider 的 options_json 中设置 {"thinking_mode":"disabled"} 也无效,SDK 层不受此控制

环境信息

  • CodePilot: v0.45.0
  • macOS (Apple Silicon)
  • 服务商: OpenRouter,模型 openai/gpt-4o-2024-05-13

建议

能否在 SDK 调用层根据 provider 的协议类型(openrouter / openai-compatible)条件性地跳过 thinking 参数?这样通过 OpenRouter 接入 OpenAI 等非 Anthropic 模型就能正常工作了。

感谢开发了 CodePilot,非常棒的工具!🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions