bug: conversation context selects the oldest thread messages instead of recent replies
维护者通常 1 天内回复
评估
调研方向
在 bot.py 中检查 _build_conversation_context() 及其对 thread.history() 的调用。将当前消息作为历史记录的边界,保留四条消息的限制,并检查结果是否按时间顺序格式化,同时显式的回复引用上下文是否仍然可用。使用 issue 中提到的独立可执行复现程序进行复现;当它在消息 11 之前选中消息 7–10 时即为完成。
由索引模型根据 Issue 内容生成。
描述
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
- In an unmodified checkout, consider a thread containing messages 1-10 and a current message with ID 11.
- Call
_build_conversation_context(thread, author, query, current_msg)without an explicit reply reference. - 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AOSSIE-Org/SkillBot 的其他 Issue
-
[BUG]: Issue-creation intent is missed when the article is omitted (create issue for this)可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 82/100
AOSSIE-Org/SkillBot#65 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Non-Atomic Gap Log Writes Can Cause Data Loss After an Interrupted Save可能已有人在做 @sankalpmtellur 于 4 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 74/100
AOSSIE-Org/SkillBot#61 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG]: os.chdir() Changes the Process-Wide Working Directory During Repository Sync可能已有人在做 @aadityachhipa80-oss 于 12 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 75/100
AOSSIE-Org/SkillBot#59 · 3 条评论 ·
维护者通常 1 天内回复
-
[BUG]: wait_for_ollama() Retries Indefinitely When Ollama Is Unavailable可能重新可做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 22 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/SkillBot#56 · 4 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Backlog Messages Are Re-processed on Discord Reconnection可能重新可做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 22 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 4/5 3-5 天 新手友好度 55/100
AOSSIE-Org/SkillBot#58 · 2 条评论 ·
维护者通常 1 天内回复
查看 AOSSIE-Org/SkillBot 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
bad-antics/lateralus-lang#1438 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
area: control app
难度 2/5 1-3 小时 新手友好度 76/100
glossyio/traffic-monitor#415 ·
维护者通常 1 天内回复
-
apply_matrix_rect takes 6-9% of extract_text time可能已有人在做 @g4lb 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
pdfminer/pdfminer.six#1333 ·
维护者通常 1 天内回复
-
intake mcp-intake needs-human-review priority:high type:bug
难度 2/5 1-3 小时 新手友好度 77/100
Ikalus1988/MisakaNet#6081 · 2 条评论 ·
维护者通常 1 天内回复