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

Abierto Apto para principiantes
#74 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@BLVCK-MAMBA-6 ya está trabajando en esto.

Desde el 1/12/2026.

  • #75 de @BLVCK-MAMBA-6 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
ai, backend

Línea de trabajo

En bot.py, inspecciona _build_conversation_context() y su llamada a thread.history(). Usa el mensaje actual como límite del historial, conserva el límite de cuatro mensajes y comprueba que el resultado esté ordenado cronológicamente y que el contexto explícito de las referencias a respuestas siga estando disponible. Reprodúcelo con la reproducción ejecutable independiente mencionada en el issue; estará listo cuando seleccione los mensajes 7–10 antes del mensaje 11.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
10
Forks
12
Merge medio
3 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AOSSIE-Org/SkillBot

Todos los issues de AOSSIE-Org/SkillBot

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.