Skip to content

Conversation

@zikajk
Copy link
Member

@zikajk zikajk commented Jan 15, 2026

Discard reasoning before last user message (based on OpenAI SDK).
Model-level config enables preservation (e.g. GLM-4.7 with preserved thinking).

Changes:

  • prune-history: add keep-history-reasoning parameter

  • Tests: cover both pruning and preservation

  • Docs: add keepHistoryReasoning to model schema

  • I added a entry in changelog under unreleased section.

@ericdallo Subjectively, the behavior seems better now. Since it's difficult to evaluate, I went through the OpenAI SDK with Opencode via Opus and it found that they discard it as well. And I couldn't find any documentation that would suggest we should do otherwise by default.

@zikajk zikajk force-pushed the configurable-reasoning-history branch from a94e839 to 1be0ff3 Compare January 15, 2026 15:30
CHANGELOG.md Outdated

## Unreleased

- (OpenAI Chat) - Configurable reasoning history via `keepHistoryReasoning` (model-level, default: prune)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this default for all openai-chat is a good idea or if we should have it enabled only for google provider in config.clj, also shouldn't this be a flag by provider and not model?

Copy link
Member Author

@zikajk zikajk Jan 15, 2026

Choose a reason for hiding this comment

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

Based on what I've found in Opencode and OpenAI SDK it is default for every model.

  1. OpenCode transform <think> block to message of type reasoning and this type is ignored by OpenAI SDK and never reach the LLM.
  2. Delta reasoning messages are usually persisted in one turn and then thrown away (as you can see in GLM docs bellow, first vs second diagram)

It shouldn't be by provider because you might want to configure it only for e.g. GLM-4.7 (second diagram here ->
https://docs.z.ai/guides/capabilities/thinking-mode).

Copy link
Member

Choose a reason for hiding this comment

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

ok, let's keep an eye on that if affects any openai-chat model, I still think it's a little bit dangerous move, but if openai sdk is really doing that it may be ok

@zikajk
Copy link
Member Author

zikajk commented Jan 15, 2026

@ericdallo If you approve I will merge it tommorow after fixing integration tests.

@zikajk zikajk changed the title add configurable reasoning preservation for openai completions Add configurable reasoning preservation for openai completions Jan 17, 2026
@zikajk zikajk changed the title Add configurable reasoning preservation for openai completions [DRAFT] Add configurable reasoning preservation for openai completions Jan 17, 2026
@zikajk zikajk force-pushed the configurable-reasoning-history branch 2 times, most recently from 8e3e3f2 to 776c92f Compare January 24, 2026 16:32
@zikajk zikajk changed the title [DRAFT] Add configurable reasoning preservation for openai completions Add configurable reasoning preservation for openai completions Jan 25, 2026
@zikajk zikajk force-pushed the configurable-reasoning-history branch 2 times, most recently from c2d8af8 to 446bbb1 Compare January 25, 2026 16:52
Standard behavior: discard reasoning before last user message (based on OpenAI SDK).
Model-level config enables preservation (e.g. GLM-4.7 with preserved thinking).

Changes:
- prune-history: add keep-history-reasoning parameter
- Tests: cover both pruning and preservation
- Docs: add keepHistoryReasoning to model schema
Introduce a more granular control for reasoning retention in requests:
"all" (default, send everything)
"turn" (current turn only)
"off (discard all)

Both delta-reasoning (reasoning_content) and think-tag reasoning are handled uniformly.

DB storage is unaffected. Reasoning is always persisted for UI display.
This setting only controls what gets sent back to the model.
@zikajk zikajk force-pushed the configurable-reasoning-history branch from 446bbb1 to 4a4d990 Compare January 25, 2026 17:41
Copy link
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

yeah that looks better!

@ericdallo ericdallo merged commit 1f9e02a into master Jan 25, 2026
9 checks passed
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.

3 participants