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

未关闭 适合新手
#74 0 条评论 0 个 reaction 已指派 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() 的调用。将当前消息作为历史记录的边界,保留四条消息的限制,并检查结果是否按时间顺序格式化,同时显式的回复引用上下文是否仍然可用。使用 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 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AOSSIE-Org/SkillBot 的其他 Issue

查看 AOSSIE-Org/SkillBot 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。