Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#326 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
swift
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Swift
Star
948
Fork
99
Merge trung bình
19 giờ 50 phút
Pull request đã merge (30 ngày)
51

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của huggingface/AnyLanguageModel

Tất cả issue của huggingface/AnyLanguageModel

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.