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

fix(llm): handle_no_tool_calls 仍会落盘空 assistant 行——#168 的同族遗留通道

Đang mở
#196 0 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
68/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ệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Read src/run_core.rs around handle_no_tool_calls (lines 835–857) and compare its empty-content handling with the has_persistable_interrupt logic from issue #168. Add a test for a normal stop with empty content and no tool calls, then run cargo test --lib and cargo test --test invariants. Done means the transcript has no empty assistant row, with the predicate covered by an assertion or equivalent reasoning.

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

Mô tả

优先级 P3 · 依赖:无(同族于已修复的 #168)

基线 HEAD = e9e314ec

Summary

#168 修复了「中断在 tool_call 阶段落盘空 assistant 消息」的中断路径,但交付说明
(infra4agent#8)已指出:同族通道 run_core::handle_no_tool_calls 未被处理,
且当时标记为「超范围,故未动」——但没有开跟进单。本单补上这个跟踪项。

src/run_core.rs:835-857:

fn handle_no_tool_calls(&mut self, completion: &Completion, step: usize) -> Option<FinishReason> {
    if !completion.tool_calls.is_empty() { return None; }
    let mut msg = Message::assistant(completion.content.clone());   // ← content 可为空串
    msg.reasoning_content = completion.reasoning_content.clone();
    self.push_message(step, msg);                                    // ← 无条件落盘
    ...
}

即:正常停止(非中断)且 content 为空时,仍会落盘一条
{"role":"assistant","content":""} 的 transcript 行。

为什么目前危害低(但不该长期如此)

#168 的三层防线已把「空 assistant」在出网与读取两侧都拦住了,已实测确认:

  1. serialize_messages_anthropic / openai build_request 的 is_empty_assistant 过滤;
  2. SessionReader::load_messages 与 load_messages_with_orphan_results 的加载期过滤。

→ 不会污染线上请求,因此本单是 P3 而非 P2。

建议

两种方向,择一即可(建议 ①):

  1. 不落盘:handle_no_tool_calls 在 content 与 reasoning_content 均为空时
    不 push(与 #168 的 has_persistable_interrupt 判据保持一致的语义);
  2. 落盘但标记:保留行以便审计,明确标注其为「无内容终止」,
    并确保所有 serializer/loader 一致丢弃。

验收条件

  • 构造「模型返回 finish_reason=stop + 空 content + 无 tool_calls」的场景,
    断言 transcript 不含空的 assistant 行(或按方向 ② 断言其被一致丢弃);
  • 回归:cargo test --lib 0 failed;cargo test --test invariants 0 failed;
  • 若为 is_empty_assistant / has_persistable_interrupt 类判据,
    必须补断言或补等价性论证,不得使用 #[mutants::skip](#168 的既定纪律,
    已实测该门禁对本修复有效:撤销 skip 后变异可被杀死)。
Ngôn ngữ chính
Rust
Star
4
Fork
0
Merge trung bình
5 giờ 32 phút
Pull request đã merge (30 ngày)
7

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

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 jeffkit/recursive

Tất cả issue của jeffkit/recursive

Issue tương tự

Thêm issue về Rust

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.