Skip to content

[Bug]openai兼容格式的阿里百炼qwen3.5模型无法调用mcp服务器 #6780

@Develata

Description

@Develata

What happened / 发生了什么

openai兼容格式的阿里百炼qwen3.5模型无法调用mcp服务器,日志显示不支持函数工具调用。原因应该是接口形态不匹配。

如下是阿里百炼官方提供的信息:关于如何使用 Responses API,在 tools 参数中配置MCP Server。

# 导入依赖与创建客户端...
mcp_tool = {
    "type": "mcp",
    "server_protocol": "sse",
    "server_label": "my-mcp-service",
    "server_description": "MCP 服务功能描述,帮助模型理解使用场景。",
    "server_url": "https://your-mcp-server-endpoint/sse",
    "headers": {
        "Authorization": "Bearer YOUR_TOKEN"
    }
}

response = client.responses.create(
    model="qwen3.5-plus",
    input="你的问题...",
    tools=[mcp_tool]
)

print(response.output_text)

Reproduce / 如何复现?

openai兼容格式的阿里百炼qwen3.5模型调用任意mcp服务器即出现这种情况。

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

1.20.1,1.21.0,docker-compose部署,阿里百炼qwen3.5,飞书

OS

Linux

Logs / 报错日志

[2026-03-22 13:10:47.691] [Core] [INFO] [core.event_bus:61]: [workbot] [workbot(lark)] ou_40cb2/ou_40cb24edc5d3d92cb5e1029d8d82bdd9: [A New Approach to Code Smoothing Bounds](https://arxiv.org/pdf/2603.18077) 我没有收到你的回复,重来一次 
[2026-03-22 13:10:51.645] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:52.367] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:53.063] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:53.628] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:54.737] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:55.535] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:55.919] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:57.056] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:57.472] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:58.354] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:10:58.355] [Core] [ERRO] [v4.21.0] [sources.openai_source:805]: API 调用失败,重试 10 次仍然失败。
[2026-03-22 13:10:58.355] [Core] [WARN] [v4.21.0] [runners.tool_loop_agent_runner:283]: Chat Model openai/qwen3.5-plus request error: Error code: 400 - {'error': {'message': '<400> ***.***.InvalidParameter: Empty tool_calls is not supported in message.', 'type': 'invalid_request_error', 'param': '', 'code': 'invalid_parameter_error'}}
Traceback (most recent call last):
  File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 258, in _iter_llm_responses_with_fallback
    async for resp in self._iter_llm_responses(include_model=idx == 0):
  File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 235, in _iter_llm_responses
    yield await self.provider.text_chat(**payload)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 808, in text_chat
    raise last_exception
  File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 778, in text_chat
    llm_response = await self._query(payloads, func_tool)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 272, in _query
    completion = await self.client.chat.completions.create(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2714, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1884, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1669, in request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': '<400> ***.***.InvalidParameter: Empty tool_calls is not supported in message.', 'type': 'invalid_request_error', 'param': '', 'code': 'invalid_parameter_error'}}
[2026-03-22 13:10:58.361] [Core] [WARN] [v4.21.0] [runners.tool_loop_agent_runner:250]: Switched from openai/qwen3.5-plus to fallback chat provider: openai/gemini-3.1-pro-preview
[2026-03-22 13:11:06.344] [Core] [INFO] [respond.stage:184]: Prepare to send - ou_40cb2/ou_40cb24edc5d3d92cb5e1029d8d82bdd9:  
[2026-03-22 13:11:06.345] [Core] [INFO] [respond.stage:215]: 消息为空,跳过发送阶段
[2026-03-22 13:11:15.804] [Core] [INFO] [runners.tool_loop_agent_runner:640]: Agent 使用工具: ['parse_documents']
[2026-03-22 13:11:15.805] [Core] [INFO] [runners.tool_loop_agent_runner:686]: 使用工具:parse_documents,参数:{'file_sources': 'https://arxiv.org/pdf/2603.18077', 'language': 'en'}
[2026-03-22 13:11:48.063] [Core] [INFO] [runners.tool_loop_agent_runner:866]: Tool `parse_documents` Result: {"status":"success","content":"# A New Approach to Code Smoothing Bounds\n\nTsuyoshi Miezaki∗ Yusaku Nishimura† Katsuyuki Takashima‡§\n\n# Abstract\n\nTo analyze the security of code-based cryptosystems, the smoothing parameter, which is closely related to the total variation distance of codes, has been investigated. While previous studies have bounded this distance using the Fourier transform on locally compact abelian groups, we take an alternative approach based on random walks. In this paper, we derive an inequality for the total variation distance of random walks using equitable partitions, and we show that our proposed bound generalizes existing results for finite abelian groups.\n\n# 1 Introduction\n\n# 1.1 Background\n\nCode-based cryptosystems, such as HQC, are expected to provide postquantum security [2]. To analyze the security of code-based cryptosystems, the smoothing parameter, which is one of the invariants based on the total variation distance of a certain probability distribution, has been proposed. Debris-Alazard et al. [1] presented an inequality regarding the total variation distance on locally compact abelian groups, and they investigated the smoothing bound of codes and lattices. In the case of codes, they showed that the bound is given by using dual codes and the Fourier transform of the probability distribution. Alternatively, the total variation distance of random walks has also been investigated. It is known that the total variation distance of random walks is bounded by the eigenvalues of transition matrices [3, 4, 7]. Recently, it has been shown that by using a special subset of the state space called a graphical design as the initial state, a bound using even smaller eigenvalues is possible [6].\n\n# 1.2 Our Results\n\nIn this paper, we consider an inequality concerning the total variation distance on finite abelian groups from the perspective of random walks. This method is based on an equitable partition, which is closely related to the recently introduced graphical designs [5]. Although we aimed to improve the upper bound of the inequality by Debris-Alazard et al. using the results of graphical designs, the obtained inequality did not lead to an improvement over the existing upper bound. However, the previous results in [1] assume conditions based on group structures. In contrast, Theorem 3.3 only requires an equitable partition, which can be obtained without relying on a group structure. In particular, Theorem 3.3 can be applied to certain initial distributions even if they do not arise from a subgroup.\n\n# 1.3 Outline\n\nThis paper is organized as follows. In Section 2, we provide some terms related to codes and random walks, as well as the total variation distance. In Section 3, we consider the bound of the total variation distance using equitable partitions, and show that a result of Debris-Alazard et al. can be obtained in the case of codes.\n\n# 2 Preliminaries\n\nFor any finite set $V$ , we denote $\\mathbf { 1 } _ { V } \\in \\mathbb { C } ^ { | V | }$ as the all-ones vector and $\\mathbf { 1 } _ { X } \\in \\mathbb { C } ^ { | V | }$ as the characteristic vector of $X \\subset V$ . We also denote $\\begin{array} { r } { u _ { V } = \\frac { 1 _ { V } } { | V | } } \\end{array}$ and $\\begin{array} { r } { u _ { X } = \\frac { 1 _ { X } } { | X | } } \\\\ { . } \\end{array}$ as the uniform distributions over $V$
[2026-03-22 13:17:55.560] [Core] [INFO] [core.event_bus:61]: [workbot] [workbot(lark)] ou_40cb2/ou_40cb24edc5d3d92cb5e1029d8d82bdd9: 那你能不能用mcp工具帮我查高铁票,查贵阳北站到合肥南站的高铁票 
[2026-03-22 13:17:59.396] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:00.210] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:01.251] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:02.458] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:03.639] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:05.168] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:06.522] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:07.717] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:08.718] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。
[2026-03-22 13:18:09.848] [Core] [INFO] [sources.openai_source:719]: qwen3.5-plus 不支持函数工具调用,已自动去除,不影响使用。

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions