fix(chat): enable native tool calling for reasoning models via OpenAI-compatible endpoints#528
Merged
Merged
Conversation
…OL label when unavailable
…l calling is active Previous fix unconditionally set enable_thinking=False for all models when use_native_tools=True. Now gate on has_thinking_tags() so only reasoning models (e.g. Qwen3.6-Plus matched via "qwen" prefix) get thinking disabled. Non-reasoning models are unaffected.
…binding Reasoning models (e.g. Qwen3.6-Plus) accessed through a generic OpenAI-compatible binding lacked the enable_thinking parameter that DashScope sets automatically. Without it the Bailian API defaults to thinking mode but the label protocol confuses the model into writing tool-call JSON inside content instead of using native tool_calls, causing tool_without_calls violations and infinite retries. Changes: Inject enable_thinking True for reasoning models whose binding lacks a thinking_style; Append a system-prompt note telling reasoning models to ignore the label protocol; Use implicit_think_label LABEL_FINISH for reasoning models with native tool calling.
- Move _is_reasoner assignment before first use to fix UnboundLocalError - Add custom binding capabilities for OpenAI-compatible endpoints - Enable supports_tools and has_thinking_tags for custom providers Fixes tool call failures with reasoning models via OpenAI-compatible APIs
Rely on MODEL_OVERRIDES for per-model detection (qwen/deepseek/qwq prefixes) instead of hardcoding True for all custom endpoints. Prevents enable_thinking injection and reasoner protocol notes from being incorrectly applied to non-reasoning models like GPT-4o.
Collaborator
|
Thanks for your contribution! |
pancacake
added a commit
that referenced
this pull request
May 27, 2026
Security: lock down the TutorBot tool sandbox (shell exec is opt-in, all filesystem/shell access confined to the bot workspace) and isolate per-user resources, closing #518, #517, #516, #515, #514 and #506 (first hardened in #507). Bug fixes: chat input disabled after the first turn (#520), KB embedding failure on long documents (#521 / #509), profile creation under Docker (#512 / #513), Qwen reasoning models failing native tool calling (#527 / #528), the GPT-5 init-wizard token parameter (#508), and oversized session-event truncation (#524). Features: HTTP/SSE API for multi-turn chat with a specific TutorBot (#511), multimodal image fallback for vision-capable providers without a capability entry, safe ZIP knowledge upload, and a /settings/network page with model fetching (community PRs #522 and #523 reimplemented locally). Also bumps __version__ to 1.4.1, adds the v1.4.1 release notes, updates the README Releases section, and ships the Astro + Starlight docs site under site/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes tool calling failures with reasoning models (Qwen 3.6 Plus, DeepSeek, etc.) when accessed through OpenAI-compatible endpoints. Resolves
UnboundLocalErrorand enables proper nativetool_callssupport.Related Issues
Module(s) Affected
agentsservicesChanges Summary
deeptutor/agents/chat/agentic_pipeline.py_is_reasonervariable order; addenable_thinkinginjection for reasoning models; add reasoner protocol note; adjustimplicit_think_labellogicdeeptutor/services/llm/capabilities.pycustombinding withsupports_tools: True; adddashscopebinding with full capabilitiesKey Fixes
_is_reasoner = has_thinking_tags(...)before first usesupports_toolsand per-modelhas_thinking_tagsvia MODEL_OVERRIDESenable_thinking=Truefor reasoning models when binding lacksthinking_styleLABEL_FINISHfor reasoning models with native tool callingTested
Checklist
Commits
6f9af58fix(chat): disable thinking mode for native tool calling and strip TOOL label when unavailableb6a8183fix(chat): only disable thinking for reasoning models when native tool calling is active35ea0b1fix: enable native tool_calls for reasoning models via custom OpenAI binding4862185fix: escape quotes in reasoner protocol note strings2a0310afix(chat): fix Qwen 3.6 Plus tool call failures551b98bfix(capabilities): change custom binding has_thinking_tags to False