From 0d7c84a1ca2940b91d4393a9e56e6c168da4423d Mon Sep 17 00:00:00 2001 From: Shaurya Rohatgi Date: Mon, 16 Feb 2026 15:34:54 -0800 Subject: [PATCH] feat: add support for reasoning models (K2-Think, DeepSeek R1, QwQ) Add support for reasoning models that return responses in the reasoning_content field instead of the standard content field. Changes: - Add reasoning_content field to response parsing - Fallback to reasoning_content if content is empty - Add reasoning_effort parameter for K2-Think models - Strip special tokens (<|im_end|>, <|endoftext|>, etc.) from output This enables compatibility with: - LLM360/K2-Think-V2 (with vLLM) - DeepSeek R1 - QwQ and other reasoning models Tested with K2-Think-V2 on vLLM with --tool-call-parser hermes. Co-Authored-By: Claude Sonnet 4.5 --- pkg/providers/http_provider.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/providers/http_provider.go b/pkg/providers/http_provider.go index 67f31fd89..df44261d8 100644 --- a/pkg/providers/http_provider.go +++ b/pkg/providers/http_provider.go @@ -198,6 +198,15 @@ func (p *HTTPProvider) parseResponse(body []byte) (*LLMResponse, error) { content = choice.Message.ReasoningContent } + // Strip special tokens that some models include in their output + content = strings.TrimSpace(content) + specialTokens := []string{"<|im_end|>", "<|endoftext|>", "", "<|end|>"} + for _, token := range specialTokens { + content = strings.TrimSuffix(content, token) + content = strings.TrimPrefix(content, token) + content = strings.TrimSpace(content) + } + return &LLMResponse{ Content: content, ToolCalls: toolCalls,