ai: Thinking Shows Twice When a reasoning.text Detail Repeats Streamed reasoning_content

Ouverte Adaptée aux débutants
#64,723 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript
Domaine
backend, testing

Piste de recherche

Commencez par packages/ai/src/protocols/openai-chat.ts, en particulier detailText et reasoningTextObserved, puis examinez les tests du fournisseur de chat OpenAI dans packages/ai/test/provider/openai-chat.test.ts. Reproduisez le flux où reasoning_content est suivi de détails correspondants reasoning.text. Le travail est terminé lorsque le bloc Thought contient le texte une seule fois et que le test de régression réussit.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area/providers platform/macos status/repro-simulated type/bug version/v2
Description

Claude's thinking shows twice in the Thought block when the model is reached through an OpenAI-compatible gateway that streams reasoning_content and then sends the signed thinking block as one reasoning.text entry in reasoning_details. I see it in OpenChamber. The doubled text is also in the stored session, so it does not depend on the interface.

The next request sends the doubled text back as reasoning_content. The signed entry itself is sent back correctly.

The cause is in packages/ai/src/protocols/openai-chat.ts. detailText returns the text of every reasoning.text entry, and OpenCode appends that text as another reasoning delta after the streamed chunks. reasoningTextObserved already stops this for Kimi's summary entries but has no effect on reasoning.text.

The code is the same in v2.2.7, v2.3.2 and dev (ae88eb6a7).

In my local database, 730 of 918 reasoning blocks from Claude Sonnet and 188 of 219 from Claude Haiku are exactly doubled. The GPT model I use (321 blocks) shows no doubling.

I have a two-line fix with a regression test, and it passes the related existing provider tests. I can open a PR if a maintainer wants one.

Plugins

Two local plugins (memory and environment setup). Neither mentions reasoning or thinking.

OpenCode version

2.2.7 (I also read the source of 2.3.2 and dev)

Steps to reproduce
  1. Use a Claude Sonnet or Haiku model through a gateway that streams the chunks below on /v1/chat/completions. OpenCodex does this. OpenRouter sends both fields in one frame and is not affected.

    {"delta":{"reasoning_content":"Think "}}
    {"delta":{"reasoning_content":"hard."}}
    {"delta":{"reasoning_details":[{"type":"reasoning.text","text":"Think hard.","signature":"...","format":"anthropic-claude-v1","index":0}]}}
    {"delta":{"content":"Done"},"finish_reason":"stop"}
    
  2. Ask a question that makes the model think.

  3. Open the Thought block. It reads "Think hard.Think hard." and should read "Think hard."

The same stream as a test in packages/ai/test/provider/openai-chat.test.ts fails with Received: "Think hard.Think hard.".

Screenshot

No response

Operating System

macOS 27.2

Terminal

OpenChamber (web UI)

Langage dominant
TypeScript
Étoiles
227k
Forks
30.7k
Merge moyen
5 h 14 min
PR mergées (30 j)
486

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de anomalyco/opencode

Toutes les issues de anomalyco/opencode

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.