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

オープン 初心者向け
#74 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@BLVCK-MAMBA-6 がすでに取り組んでいます。

2026年12月1日 から。

  • #75 @BLVCK-MAMBA-6 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai, backend

調査の方向性

bot.pyで_build_conversation_context()とthread.history()の呼び出しを調べます。現在のメッセージを履歴の境界として使い、4メッセージの上限を維持し、結果が時系列順に整形され、明示的な返信参照コンテキストも引き続き利用できることを確認します。issueで言及されている単独で実行可能な再現コードを使って再現します。メッセージ11より前にメッセージ7~10が選択されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
10
フォーク
12
平均マージ
3分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/SkillBot のほかの issue

AOSSIE-Org/SkillBot の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。