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

Aperta Adatta ai principianti
#74 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@BLVCK-MAMBA-6 ci sta già lavorando.

Dal 1/12/2026.

  • #75 di @BLVCK-MAMBA-6 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, backend

Direzione di ricerca

In bot.py, esamina _build_conversation_context() e la chiamata a thread.history(). Usa il messaggio corrente come limite della cronologia, mantieni il limite di quattro messaggi e verifica che il risultato sia ordinato cronologicamente e che il contesto esplicito dei riferimenti alle risposte resti disponibile. Riproduci il problema con la riproduzione eseguibile autonoma menzionata nell’issue; il lavoro è completato quando seleziona i messaggi da 7 a 10 prima del messaggio 11.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
10
Fork
12
Merge medio
3m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/SkillBot

Tutte le issue di AOSSIE-Org/SkillBot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.