Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

fix: convert thinking blocks sent as text to reasoning parts#257

Closed
Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Ashwinhegde19:dev
Closed

fix: convert thinking blocks sent as text to reasoning parts#257
Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Ashwinhegde19:dev

Conversation

@Ashwinhegde19
Copy link

Summary

OpenRouter/Kilo Gateway sometimes sends thinking content as text-delta events instead of reasoning-* events. When this happens, thinking blocks remain visible after response completion because they're stored as text parts instead of reasoning parts.

This fix detects text starting with Thinking: or _Thinking:_ (markdown italic) and converts it to a reasoning part so it gets properly hidden by the UI's hideReasoning filter.

Changes

  • Added THINKING_PATTERN regex to detect thinking blocks sent as text
  • In text-end handler, if text matches the pattern, convert to reasoning part instead of text part

Test plan

  1. Start Kilo CLI with Kilo Gateway provider
  2. Select Claude model with max variant (enables thinking)
  3. Send a prompt that triggers thinking + tool use
  4. Verify thinking blocks are hidden after completion

Fixes Kilo-Org/kilocode#6320

OpenRouter/Kilo Gateway sometimes sends thinking content as text-delta
events instead of reasoning-* events. This detects text starting with
'Thinking:' and converts it to reasoning parts so they get properly
hidden after response completion.

Fixes #236
start: currentText.time?.start ?? Date.now(),
end: Date.now(),
},
metadata: currentText.metadata,
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: Provider metadata may be dropped when converting text → reasoning

In the thinking-conversion branch, value.providerMetadata (available on the text-end event) is not applied to the new reasoning part, so any final provider metadata can be lost.

Suggested change
metadata: currentText.metadata,
metadata: value.providerMetadata ?? currentText.metadata,

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 11, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/session/processor.ts 326 Provider metadata may be dropped when converting text → reasoning

Fix these issues in Kilo Cloud

Files Reviewed (1 files)

@Ashwinhegde19
Copy link
Author

Duplicate of #258

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thinking blocks remain visible after response completes when using Kilo Gateway provider

1 participant