Skip to content

Conversation

@ochafik
Copy link
Owner

@ochafik ochafik commented Dec 23, 2025

Summary

This PR implements auto-detection of thinking/reasoning capabilities for chat templates, as requested in #19.

Changes

New Capability Flags

Added 5 new capability flags to `chat_template_caps`:

  • `supports_thinking` - Template supports `reasoning_content` field
  • `supports_disable_thinking` - Template respects `enable_thinking=false`
  • `supports_reasoning_only` - Can emit reasoning without content/tool calls
  • `supports_reasoning_with_content` - Can mix content text with reasoning
  • `reasoning_requires_tools` - Reasoning only appears with tools present

Detection Logic

The detection tests templates by rendering messages with `reasoning_content` field and checking if the content appears in the output.

Tests

  • Added tests for `Qwen/Qwen3-235B-A22B-Thinking-2507`
  • Added tests for `zai-org/GLM-4.6`

Both templates correctly detect `supports_thinking = true`.

Model IDs

Added model IDs from llama.cpp tests:

  • `deepseek-ai/DeepSeek-V3.1`
  • `ibm-granite/granite-3.3-2b-instruct`
  • `zai-org/GLM-4.7`

Note on GLM-4.7

GLM-4.7 introduces a new `clear_thinking` variable for "Preserved Thinking" - thinking content stays in context but can be shown as empty ``` tags. This differs from `enable_thinking` which controls whether ``` tags are emitted at all.

Closes #19

- Add supports_thinking flag to detect reasoning_content field support
- Add supports_disable_thinking, supports_reasoning_only, supports_reasoning_with_content flags
- Add reasoning_requires_tools flag for templates that only reason with tools
- Add tests for Qwen3-235B-A22B-Thinking-2507 and GLM-4.6
- Add model IDs: DeepSeek-V3.1, granite-3.3-2b-instruct, GLM-4.7

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Feature: Auto-detect template capabilities (supports_disable_thinking, supports_reasoning_only, etc.)

2 participants