Skip to content

fix(session/runner): force MiniMax XML tool-call mode for threatbook-…#183

Merged
xiami762 merged 1 commit intomainfrom
fix/minimax-text-tool-call-threatbook-cn-llm
Apr 24, 2026
Merged

fix(session/runner): force MiniMax XML tool-call mode for threatbook-…#183
xiami762 merged 1 commit intomainfrom
fix/minimax-text-tool-call-threatbook-cn-llm

Conversation

@duguwanglong
Copy link
Copy Markdown
Contributor

The threatbook-cn-llm gateway exposes MiniMax models over an OpenAI-compatible endpoint but its streaming chunks omit the tool_calls field entirely (observed 2026-04 with minimax-m2.7: first ChoiceDelta only carries content / role, model_extra_keys=[]). With native function-calling the model can never emit a tool call, so every turn ends with finish_reason=stop and tool_calls=0 — users in IM channels just see a short text reply (e.g. a couple of IPs) and no tool execution.

Add threatbook-cn-llm to the MiniMax text-call provider whitelist so _should_use_text_tool_call_mode() returns True for this provider+model pair. The runner then injects the
<minimax:tool_call> XML instructions and the existing text parser picks the calls up from the content stream, restoring tool execution end-to-end.

  • Other models routed through the same gateway (qwen, GLM, etc.) remain on the standard OpenAI native function-calling path.
  • Comment in _should_use_text_tool_call_mode() records the root cause for future maintainers.

Tests:

  • New regression cases in TestMiniMaxTextToolMode:
    • threatbook-cn-llm + minimax-m2.7 → XML mode enabled
    • case-insensitive provider/model id handling
    • threatbook-cn-llm + qwen3.6-plus → XML mode disabled
  • tests/session/test_runner_step.py (48 cases) all pass.

…cn-llm

The `threatbook-cn-llm` gateway exposes MiniMax models over an
OpenAI-compatible endpoint but its streaming chunks omit the
`tool_calls` field entirely (observed 2026-04 with `minimax-m2.7`:
first `ChoiceDelta` only carries `content` / `role`,
`model_extra_keys=[]`). With native function-calling the model can
never emit a tool call, so every turn ends with `finish_reason=stop`
and `tool_calls=0` — users in IM channels just see a short text
reply (e.g. a couple of IPs) and no tool execution.

Add `threatbook-cn-llm` to the MiniMax text-call provider whitelist
so `_should_use_text_tool_call_mode()` returns True for this
provider+model pair. The runner then injects the
`<minimax:tool_call>` XML instructions and the existing text
parser picks the calls up from the content stream, restoring tool
execution end-to-end.

- Other models routed through the same gateway (qwen, GLM, etc.)
  remain on the standard OpenAI native function-calling path.
- Comment in `_should_use_text_tool_call_mode()` records the root
  cause for future maintainers.

Tests:
- New regression cases in `TestMiniMaxTextToolMode`:
  - threatbook-cn-llm + minimax-m2.7 → XML mode enabled
  - case-insensitive provider/model id handling
  - threatbook-cn-llm + qwen3.6-plus → XML mode disabled
- `tests/session/test_runner_step.py` (48 cases) all pass.

Made-with: Cursor
@duguwanglong duguwanglong requested a review from xiami762 April 24, 2026 07:43
@xiami762 xiami762 merged commit ba687bc into main Apr 24, 2026
2 checks passed
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.

2 participants