Skip to content

Fix admin chat preserve_thinking history serialization#1329

Open
gindinconsulting wants to merge 1 commit into
jundot:mainfrom
gindinconsulting:fix-admin-chat-preserve-thinking
Open

Fix admin chat preserve_thinking history serialization#1329
gindinconsulting wants to merge 1 commit into
jundot:mainfrom
gindinconsulting:fix-admin-chat-preserve-thinking

Conversation

@gindinconsulting
Copy link
Copy Markdown

Summary

Fixes preserve_thinking in the built-in admin chat UI.

The raw /v1/chat/completions API preserves historical reasoning correctly when prior assistant messages include reasoning_content. However, the admin chat UI was storing streamed reasoning only in the UI-private _thinking field and then dropping it when serializing conversation history for the next request.

This made preserve_thinking work with raw API calls but fail inside the built-in chat.

Changes

  • Include reasoning_content when building messagesForApi
  • Fall back to _thinking so existing localStorage conversations continue to work
  • Store streamed thinking as both:
    • reasoning_content, for API history replay
    • _thinking, for existing UI rendering
  • Preserve reasoning on normal assistant messages, aborted streams, and assistant tool-call turns

Manual test

Tested locally with Qwen3.6-35B-A3B-oQ8-mtp.

Prompt 1:

Generate two random 20-digit numbers, validate that both are 20 digits, do not use tools, and only give me one of the two.

Prompt 2:

Now give me the second number only.

Before this fix, the built-in chat could not retrieve the hidden second number because prior reasoning was not sent back. After this fix, the built-in chat returns the second number from preserved reasoning 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.

1 participant