Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

OpenAI Chat Completions: tool rounds drop the model's reasoning

Aperta
#326 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
swift
Ambito
api

Direzione di ricerca

Start in the Chat Completions tool loop of OpenAILanguageModel, where the next request's assistant message is rebuilt from content and tool calls only. Check the reference fork commit (gtokman/AnyLanguageModel@daf184b) for the nonstreaming change, then decide whether to store reasoning as Transcript.Reasoning entries as PR #290 does for Anthropic. Done means that a DeepSeek or gateway tool round sends back reasoning_content, reasoning and reasoning_details unchanged, with a test that inspects the request body.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

OpenAILanguageModel's Chat Completions tool loop drops the model's reasoning between tool rounds. Thinking models return it alongside their tool calls, in reasoning_content (DeepSeek's API) or reasoning and reasoning_details (OpenRouter, Vercel AI Gateway). The next request in the same response rebuilds the assistant message from the content and tool calls only, so the reasoning that planned those calls is lost.

Why it matters
Reproduction

Run a session with tools against deepseek/deepseek-v4.1-flash-fast or zai/glm-5.3-fast on the Vercel AI Gateway (https://ai-gateway.vercel.sh/v1), and record the request bodies. Each response's choices[0].message has reasoning and reasoning_details next to tool_calls. In the next request, the matching assistant message has only content and tool_calls. Across one 8-round response, 0 of the 8 assistant messages carried the reasoning back.

PR #290 added reasoning transcript entries and replay for Anthropic. Chat Completions doesn't read or send these fields yet (checked on main at 80d50b0).

A possible fix

In the tool loop, decode the three fields from the response message and send them back unchanged on that round's assistant message. Keeping them within the one response matches DeepSeek's rule, so the transcript doesn't need to change. I did this for the nonstreaming loop in a fork, with a test: gtokman/AnyLanguageModel@daf184b. The commit is on 0.16.0. The streaming loop would need the same change, gathering the reasoning deltas.

A fuller version would store the reasoning as Transcript.Reasoning entries, as #290 does for Anthropic, so it could also be replayed after a transcript is restored. I'm happy to open a PR for either approach.

Lingua principale
Swift
Stelle
948
Fork
99
Merge medio
18h 38m
PR unite (30g)
56

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di huggingface/AnyLanguageModel

Tutte le issue di huggingface/AnyLanguageModel

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.