Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#326 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
swift
Área
api

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Swift
Estrellas
948
Forks
99
Merge medio
19 h 50 min
PR fusionados (30 d)
51

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de huggingface/AnyLanguageModel

Todos los issues de huggingface/AnyLanguageModel

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.