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

Display reasoning for supported openrouter models - #563

Merged
mrubens merged 3 commits into
RooCodeInc:mainfrom
Szpadel:r1-display-reason
Jan 26, 2025
Merged

Display reasoning for supported openrouter models#563
mrubens merged 3 commits into
RooCodeInc:mainfrom
Szpadel:r1-display-reason

Conversation

@Szpadel

@SzpadelSzpadel commented Jan 26, 2025

Copy link
Copy Markdown
Contributor

Description

Introduced way to display model reasoning for compatible models. For now only openrouter is implemented.
It displays current reasoning, and hides it when content response is available.
Block is limited in height and auto scrolls.
Because reasoning might take long time, it provides better user feedback and allows better insights into model pitfalls.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  1. configure openrouter provider
  2. Select deepseek-r1 model
  3. ask any question.

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

image

Related Issues

Reviewers


Important

Adds reasoning display for OpenRouter models, including backend handling and UI components for reasoning data.

  • Behavior:
    • Adds include_reasoning parameter to OpenRouterChatCompletionParams in openrouter.ts to include reasoning in responses.
    • Updates createMessage() in openrouter.ts to yield reasoning chunks.
    • Implements reasoning display in Cline.ts by handling reasoning chunks in attemptApiRequest().
  • UI:
    • Adds ReasoningBlock component in ReasoningBlock.tsx to display reasoning with auto-scroll and collapse functionality.
    • Updates ChatRow.tsx to include ReasoningBlock for reasoning messages.
  • Types:
    • Adds ApiStreamReasoningChunk to stream.ts for handling reasoning data.
    • Updates ClineMessage in ExtensionMessage.ts to include reasoning field.

This description was created by Ellipsis for c660706. It will automatically update as commits are pushed.

@changeset-bot

changeset-botBot commented Jan 26, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6074923

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrubens

Copy link
Copy Markdown
Collaborator

Awesome! Will try this out.

@mrubens

Copy link
Copy Markdown
Collaborator

This is awesome! Just so I'm clear - this reasoning is currently only to make it visible to the end user and doesn't actually make it into the context, right? Is that because it's too big and would blow away everything else?

@mrubens
mrubens merged commit 1101992 into RooCodeInc:mainJan 26, 2025
@Szpadel

Copy link
Copy Markdown
ContributorAuthor

AFAIK thinking tokens were not designed to be included in context. They could even degrade model performance. I believe those tokens have some special place in model context, as this is metric from one particularly complex request:

135 prompt 8192 completion,
16015 reasoning

This is from DeepInfra where they provide 16K of context, so as you can see this should normally overflow if model would output it internally into context space.

While testing it I noticed that some request were missing cost in the UI. I'm not sure of this is regression from some of my changes or coincidence.
To he honest I do not see how any of my change could affect this but maybe second pair of eyes is needed.

@sagarspatil

Copy link
Copy Markdown

AFAIK thinking tokens were not designed to be included in context. They could even degrade model performance. I believe those tokens have some special place in model context, as this is metric from one particularly complex request:

135 prompt 8192 completion,
16015 reasoning

This is from DeepInfra where they provide 16K of context, so as you can see this should normally overflow if model would output it internally into context space.

While testing it I noticed that some request were missing cost in the UI. I'm not sure of this is regression from some of my changes or coincidence. To he honest I do not see how any of my change could affect this but maybe second pair of eyes is needed.

You are correct. You are not supposed to use R1’s thinking context with other models.

Benchmark here: https://aider.chat/2025/01/24/r1-sonnet.html

@mrubens

Copy link
Copy Markdown
Collaborator

Thank you both for explaining!

Sign up for freeto 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.

3 participants

@Szpadel@mrubens@sagarspatil