hermes - ✅(Solved) Fix [Bug] Feishu gateway: model outputs tool calls as plain text, never executes -- CLI works fine [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

PR fix notes

PR #13446: fix: Feishu gateway tool calls not executing with DashScope/Qwen (#13031)

Description (problem / solution / changelog)

Summary

Fixes #13031 — Feishu Gateway tool calls not executing when using DashScope compatible-mode endpoint with Qwen models.

Root Cause

Two issues prevent tool calls from working with DashScope/Qwen in gateway mode:

1. _is_qwen_portal() only matched portal.qwen.ai

The method at run_agent.py:6589 only matched the Qwen Portal URL, not the DashScope compatible-mode endpoint (dashscope.aliyuncs.com/compatible-mode/v1). This caused:

  • Message format adaptation skipped: _qwen_prepare_chat_messages() normalizes content to list-of-dicts format required by Qwen. Without this, DashScope may reject or misparse the request.
  • max_tokens not applied: Qwen Portal defaults to a low max_tokens when omitted. The 65536 default (L6890) was not sent, causing tool_calls to be truncated by the low output budget.
  • vl_high_resolution_images not set: Qwen's high-res image parameter was not included.

2. TOOL_USE_ENFORCEMENT_MODELS did not include "qwen"

The tuple at agent/prompt_builder.py:196 only listed ("gpt", "codex", "gemini", "gemma", "grok"). Without "qwen", Qwen models didn't receive tool-use enforcement guidance in the system prompt, causing the model to output tool call intentions as plain text instead of structured tool_calls responses.

Changes

run_agent.py

  • Extended _is_qwen_portal() to also match dashscope.aliyuncs.com in the base URL
  • This activates Qwen-specific message preparation, max_tokens defaults, and other Qwen adaptations for DashScope endpoints

agent/prompt_builder.py

  • Added "qwen" to TOOL_USE_ENFORCEMENT_MODELS tuple
  • This ensures Qwen models receive tool-use enforcement guidance in the system prompt

Testing

  • 5 unit tests covering both fixes (see tests/test_fix_13031.py)
  • All tests pass locally
  • Verified that original portal.qwen.ai matching is not affected
  • Verified that non-matching endpoints (OpenAI, OpenRouter, etc.) are not affected

Why CLI mode worked but Gateway didn't

CLI mode and Gateway mode both use the same run_conversation() path, but Gateway creates the agent with different config sources. The key difference is that when users configure DashScope as a provider (via hermes auth add), the base_url is set to dashscope.aliyuncs.com, but _is_qwen_portal() never recognized it. In CLI mode, users may have been using different providers or the tool calls happened to work through the text fallback parser.

Changed files

  • agent/prompt_builder.py (modified, +1/-1)
  • run_agent.py (modified, +2/-2)
  • tests/test_fix_13031.py (added, +192/-0)
RAW_BUFFERClick to expand / collapse

Environment

  • Hermes version:v0.10.0 (2026.4.16)
  • OS: Ubuntu 24.04 on WSL2 (Windows 11)
  • Model provider: Alibaba / DashScope (endpoint: https://dashscope.aliyuncs.com/compatible-mode/v1)
  • Models tested: qwen3-max and qwen3-plus (same behavior on both)
  • Gateway platform: Feishu (Lark) via WebSocket long connection

Problem

Tool calling works correctly in hermes chat (CLI mode), but the Feishu gateway never actually executes tools. Instead, the model outputs tool invocations as plain text or code blocks in the chat response.

For example, when I send "帮我查一下 Notion 的页面列表" via Feishu, the bot replies with a raw text block like:

execute_code code="import os; import requests; notion_key = os.environ.get('NOTION_API_KEY') ..."

The execute_code tool is never invoked. The model appears to be unaware that tools are available, or the gateway is not parsing the model's output as structured tool calls.

What works

  • hermes chat -- all tool calls (terminal, execute_code, file, etc.) work correctly
  • hermes chat --skills notion -- Notion API calls execute and return data
  • Feishu gateway messaging -- bot receives and sends text messages, but zero tool execution

What I have checked

  • hermes gateway status: running, Feishu WebSocket connected
  • config.yaml tool_use_enforcement: auto
  • config.yaml default_toolsets: [terminal, file, web]
  • config.yaml platform_toolsets.feishu: [hermes-feishu]
  • hermes tools: only shows CLI platform (17/19 enabled). No Feishu entry, but Telegram and other gateway platforms also don't appear here, so I assume this is expected.
  • journalctl -u hermes-gateway.service -n 100: only Lark SDK WebSocket connect/disconnect/reconnect logs. Zero model interaction or tool-call-related log lines.
  • Gateway restarted multiple times with sudo hermes gateway restart --system -- no change.
  • Tested with both qwen3-plus and qwen3-max -- identical behavior.

Steps to Reproduce

  1. hermes model -> select Alibaba/DashScope -> qwen3-max
  2. hermes gateway setup -> configure Feishu (Lark) with App ID and App Secret, WebSocket mode
  3. sudo hermes gateway restart --system
  4. Send any tool-requiring message via Feishu, e.g. "run ls -la" or "execute code: print(1+1)"
  5. Observe: bot replies with tool call syntax as plain text, never executes

Expected Behavior

Gateway should pass tools definitions in the API request to DashScope, model should return structured tool_call responses, and Hermes should execute them -- identical to CLI behavior.

Questions

  1. Is DashScope / Qwen tool calling supported in gateway mode, or is there a known incompatibility?
  2. Is there a way to enable verbose logging for the gateway's model interaction layer (not just the Lark SDK layer)?
  3. Are there any additional config settings needed beyond default_toolsets and tool_use_enforcement to enable tool calling on gateway platforms? Please

extent analysis

TL;DR

The issue is likely due to the model output not being parsed as structured tool calls by the Feishu gateway, and a potential solution involves checking the configuration settings for tool usage and enabling verbose logging for the gateway's model interaction layer.

Guidance

  • Verify that the tool_use_enforcement setting in config.yaml is set to auto and that the default_toolsets include the necessary tools for the Feishu gateway.
  • Check the documentation for DashScope and Qwen to see if there are any known limitations or incompatibilities with tool calling in gateway mode.
  • Enable verbose logging for the gateway's model interaction layer to gain more insight into the issue, if possible.
  • Review the Feishu gateway setup and configuration to ensure that it is correctly configured to handle tool calls.

Example

No code snippet is provided as the issue seems to be related to configuration and setup rather than code.

Notes

The issue may be specific to the Feishu gateway and DashScope model, and further investigation is needed to determine the root cause. Additionally, the lack of log lines related to model interaction or tool calls in the journalctl output suggests that the issue may be related to the gateway's configuration or the model's output.

Recommendation

Apply workaround: Check and adjust the configuration settings for tool usage and enable verbose logging for the gateway's model interaction layer to troubleshoot the issue further. This is recommended as the issue seems to be related to configuration and setup rather than a code issue, and adjusting the configuration settings may resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING