Skip to content

fix: preserve reasoning_content in multi-turn conversation history#946

Merged
yinwm merged 1 commit intosipeed:mainfrom
winterfx:fix/preserve-reasoning-content-in-history
Mar 2, 2026
Merged

fix: preserve reasoning_content in multi-turn conversation history#946
yinwm merged 1 commit intosipeed:mainfrom
winterfx:fix/preserve-reasoning-content-in-history

Conversation

@winterfx
Copy link
Contributor

@winterfx winterfx commented Mar 1, 2026

The openaiMessage struct and stripSystemParts() were not carrying over the ReasoningContent field when serializing conversation history for API requests. This caused thinking models (e.g. kimi-k2.5) to receive incomplete assistant messages on subsequent turns, resulting in 400 errors from the Moonshot API.

Add the ReasoningContent field to openaiMessage and copy it in stripSystemParts(). Also add a test to verify reasoning_content is preserved when sending conversation history.

Related: #876

📝 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:

🧪 Test Environment

  • Hardware: PC
  • **OS:**macOS
  • Model/Provider: Moonshot kimi-k2.5
  • Channels:

📸 Evidence (Optional)

Click to view Logs/Screenshots

☑️ 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.

The openaiMessage struct and stripSystemParts() were not carrying over
the ReasoningContent field when serializing conversation history for
API requests. This caused thinking models (e.g. kimi-k2.5) to receive
incomplete assistant messages on subsequent turns, resulting in 400
errors from the Moonshot API.

Add the ReasoningContent field to openaiMessage and copy it in
stripSystemParts(). Also add a test to verify reasoning_content is
preserved when sending conversation history.

Fixes sipeed#588
Related: sipeed#876

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@winterfx
Copy link
Contributor Author

winterfx commented Mar 1, 2026

Hi @yinwm ,
This PR fixes the same issue as #876 (identical code change toopenaiMessage and stripSystemParts), but adds a test case to prevent regression. If this one gets merged, #876 can be closed.

Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

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

LGTM

@yinwm yinwm merged commit 26d1b8e into sipeed:main Mar 2, 2026
2 checks passed
@yinwm
Copy link
Collaborator

yinwm commented Mar 2, 2026

thanks for the pr

hyperwd pushed a commit to hyperwd/picoclaw that referenced this pull request Mar 5, 2026
…ntent-in-history

fix: preserve reasoning_content in multi-turn conversation history
Pluckypan pushed a commit to Pluckypan/picoclaw that referenced this pull request Mar 6, 2026
…ntent-in-history

fix: preserve reasoning_content in multi-turn conversation history
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