Skip to content

Comments

fix: preserve reasoning_content for OpenAI-compatible reasoning models#604

Open
winterfx wants to merge 1 commit intosipeed:mainfrom
winterfx:fix/reasoning-content-missing
Open

fix: preserve reasoning_content for OpenAI-compatible reasoning models#604
winterfx wants to merge 1 commit intosipeed:mainfrom
winterfx:fix/reasoning-content-missing

Conversation

@winterfx
Copy link

@winterfx winterfx commented Feb 21, 2026

Models like Moonshot kimi-k2.5 and DeepSeek-R1 return a reasoning_content field in assistant messages. When thinking is enabled, the API requires this field to be echoed back in subsequent requests. PicoClaw was silently dropping it, causing 400 errors on tool-call round-trips.

  • Add ReasoningContent to Message and LLMResponse types
  • Parse reasoning_content in openai_compat parseResponse()
  • Carry reasoning_content through assistant tool-call messages
  • Add unit test for reasoning_content parsing

Fixes #588

📝 Description

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • **Reasoning:**reasoning_content is a standard field in OpenAI-compatible APIs for reasoning models. It was completely absent from the codebase — not parsed, not stored, not echoed back.

🧪 Test Environment

  • Hardware: Mac (Apple Silicon)
  • OS: macOS
  • Model/Provider: Moonshot kimi-k2.5
  • Channels: CLI

📸 Evidence (Optional)

Click to view Logs/Screenshots image after fixed image

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

Models like Moonshot kimi-k2.5 and DeepSeek-R1 return a
reasoning_content field in assistant messages. When thinking is enabled,
the API requires this field to be echoed back in subsequent requests.
PicoClaw was silently dropping it, causing 400 errors on tool-call
round-trips.

- Add ReasoningContent to Message and LLMResponse types
- Parse reasoning_content in openai_compat parseResponse()
- Carry reasoning_content through assistant tool-call messages
- Add unit test for reasoning_content parsing

Fixes sipeed#588
Copy link
Collaborator

@alexhoshina alexhoshina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Ready for @yinwm to merge.

Copy link
Collaborator

@Huaaudio Huaaudio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second. Preserving reasoning content is quite necessary for agent iterations.

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.

[Bug] Moonshot kimi-k2.5 reasoning_content missing in tool calls leads to API Error 400

3 participants