bug: conversation context selects the oldest thread messages instead of recent replies

Đang mở Phù hợp với người mới
#74 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

@BLVCK-MAMBA-6 đang làm issue này rồi.

Từ ngày 1/12/2026.

  • #75 của @BLVCK-MAMBA-6 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/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ệ
python
Lĩnh vực
ai, backend

Hướng nghiên cứu

Trong bot.py, kiểm tra _build_conversation_context() và lời gọi thread.history(). Dùng tin nhắn hiện tại làm mốc giới hạn lịch sử, giữ giới hạn bốn tin nhắn và kiểm tra kết quả được sắp xếp theo trình tự thời gian, đồng thời ngữ cảnh tham chiếu trả lời tường minh vẫn khả dụng. Tái hiện bằng bản tái hiện độc lập có thể thực thi được đề cập trong issue; hoàn tất khi chọn các tin nhắn 7–10 trước tin nhắn 11.

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

Mô tả

bug enhancement
Bug Description

Summary

_build_conversation_context() fetches the oldest four thread messages and labels them as the immediately preceding discussion. Recent corrections are absent from the context used for answers, repository routing, and issue drafting.

Root cause

In bot.py:203, thread.history(limit=THREAD_HISTORY_LIMIT, oldest_first=True) has no before/after cursor. With discord.py 2.7.1 this starts at after=0, selecting the thread's first four messages. Slicing the resulting context later cannot recover messages that were never fetched.

Expected vs. actual behavior

Expected: for current message 11, select messages 7-10 in chronological order and exclude the current message and later messages.
Actual: select messages 1-4. Explicit reply-reference context should remain available independently.

Proposed fix

Fetch newest-first with before=current_msg, then reverse the bounded result before formatting it. Keep the existing four-message limit, formatting, and explicit reply-reference handling.

Duplicate check

Checked all 10 open issues and 7 open PRs on 28 November 2026. No matching report was found. #58 concerns reconnect/backlog processing; #24 concerns repository document size. The public patches for PRs #60, #70 and #71 do not change this history request.

AI assistance

N/A

Steps to Reproduce
  1. In an unmodified checkout, consider a thread containing messages 1-10 and a current message with ID 11.
  2. Call _build_conversation_context(thread, author, query, current_msg) without an explicit reply reference.
  3. Inspect the context passed to the model: the history request starts at after=0 and contains messages 1-4 instead of 7-10.
    This was reproduced offline with discord.py's real history iterator and a fixture replacing its HTTP boundary. A standalone executable reproduction is available for this report.
Logs and Screenshots
History arguments: [{'limit': 4, 'before': None, 'after': 0}]
Immediate preceding context (last 3-4 messages & reply target):
Contributor: message-1
Contributor: message-2
Contributor: message-3
Contributor: message-4

PRIMARY TAGGED QUESTION (from Contributor): please explain the fix
AssertionError: Expected immediately preceding messages 7-10; got the thread's oldest messages

The unmodified checkout exits 1. The patched checkout selects messages 7-10 and exits 0.

Environment Details

Linux; Python 3.12.14; discord.py 2.7.1. Tested commit: a03e0dbac0f9a74a1231c161b40372d420fd8018.

Impact

Medium - Feature works but has issues

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Ngôn ngữ chính
Python
Star
10
Fork
12
Merge trung bình
3 phút
Pull request đã merge (30 ngày)
1

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

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 AOSSIE-Org/SkillBot

Tất cả issue của AOSSIE-Org/SkillBot

Issue tương tự

Thêm issue về Python

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.