HTTP 400 missing messages[N].reasoning_content after context compaction (long sessions)

Đang mở
#1,121 1 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ai-infra-agents, typescript
Lĩnh vực
ai-infra-agents, backend

Hướng nghiên cứu

Start by locating the harness message serializer and the compaction/history rebuild path; the issue does not name specific files or tests. Reproduce with a model that requires reasoning_content, then inspect assistant messages after compaction. Done means serialized history retains required reasoning on every assistant message, with a regression test covering compacted turns.

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

Mô tả

Summary

After a long multi-turn session with auto-compaction, sending the next message fails with HTTP 400:

Missing required parameter: 'messages[50].reasoning_content'. This model needs the reasoning of every earlier assistant message...

The turn is blocked. continue sometimes works for 1–2 turns, but the error recurs. Two trace IDs from the same session are included below.

Expected Behavior

The harness should replay reasoning_content for every earlier assistant message when the selected model requires it. If context compaction drops reasoning, the compacted history should replace old assistant turns with a summary entry that does not require reasoning, rather than leaving assistant entries without the field.

Actual Behavior

After compaction, the rebuilt request omits reasoning_content on older assistant messages. The provider rejects the whole request at messages[50]. No tool call or assistant response executes; the user must retry or start a new session.

Steps to reproduce the issue
  1. Use a model that requires reasoning_content on all assistant history.
  2. Run a long session (40+ assistant turns with tool calls).
  3. Trigger auto-compaction (or /compact).
  4. Send the next user message.
  5. Observe HTTP 400 at messages[N].reasoning_content.
Command Code Version

0.1.60 (desktop, macOS; bundled @commandcode/harness 0.1.0)

Operating System

macOS

Terminal/IDE

Command Code desktop app (macOS)

Shell

zsh

Session file (optional)

Not attached — the session contains project files. Trace IDs from the two occurrences:

  • c36659e1be4cb4330a058117255da812
  • df284ce38687a51028ea4de40acfdd48
Fix prompt (optional)

In the harness message serializer, when rebuilding history after compaction, preserve reasoning_content on every role: assistant message that originally had it. If a message is summarized away, replace it with a system/summary entry instead of an assistant entry lacking reasoning. Add a regression test: build 60 assistant turns with reasoning, compact, serialize, assert every assistant message still has reasoning_content. Include message_index, message_role, provider, and model in the 400 error payload.

Additional context

Exact error text:

Error: 400 Missing required parameter: 'messages[50].reasoning_content'. This model needs the reasoning of every earlier assistant message: send back the 'reasoning_content' returned with that message. If r...

Type "continue" to try again. If the issue persists, contact support: https://commandcode.ai/discord
Trace ID: c36659e1be4cb4330a058117255da812

Second occurrence in the same session:

Error: 400 Missing required parameter: 'messages[50].reasoning_content'. This model needs the reasoning of every earlier assistant message: send back the 'reasoning_content' returned with that message. If r...

Type "continue" to try again. If the issue persists, contact support: https://commandcode.ai/discord
Trace ID: df284ce38687a51028ea4de40acfdd48

Suspected cause: compaction/history rebuild keeps {role, content, tool_calls} but drops reasoning_content; the provider validates every assistant message, not just the last one.

Workaround: type continue, or start a new session with a summary.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4.2k
Fork
377
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
6

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 CommandCodeAI/command-code

Tất cả issue của CommandCodeAI/command-code

Issue tương tự

Thêm issue về AI Infra & Agents

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.