[Bug] `<system_reminder>` 每轮写入对话历史且不被清理,导致上下文持续增长

Open Beginner friendly
#10,033 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai, backend

Research direction

Start in astr_main_agent.py at _append_system_reminders, comparing the current-time reminder with the knowledge-base injection around lines 310-314. Reproduce multiple requests in one session and inspect req.contexts through the on_llm_request hook; done means the reminder is temporary and no longer accumulates in conversation history.

Written by the indexing model from the issue text.

Description

bug
问题描述

_append_system_reminders 在追加"当前时间"提醒时没有调用 .mark_as_temp(),导致这条本应只对当前请求生效的临时内容被持久化进对话历史,并在之后每一轮请求中重复发送。

同一个文件里的知识库注入(astr_main_agent.py:310-314正确调用了 .mark_as_temp(),说明这是遗漏而非设计。

影响

  • 对话历史随轮次线性增长,每轮多一条时间提醒,且永不清理
  • 过期的时间信息对当前轮次无意义,属于无效上下文
  • 白占 token,并会更早触发上下文压缩;压缩会额外调用一次 LLM 做总结,增加成本与延迟
如何复现?

在同一会话中连续进行多轮对话
通过 on_llm_request 钩子抓取请求,观察 req.contexts

AstrBot 版本

null

操作系统

Windows

部署方式

null

使用的消息平台适配器

nc

错误日志
-
辅助信息

No response

检查清单
  • 我已在 Issue 列表中搜索过相关问题仍无法解决,或该问题从未被报告过。
  • 我已尝试过禁用所有插件,排除了可能是因插件导致的问题。
  • 我报告的问题与 AstrBot 本体相关,而非在报告某一插件的问题。
  • 我已阅读并同意本项目的贡献者行为准则
  • (可选)我愿意提交 PR 以帮助修复该问题。
Dominant language
Python
Stars
40.7k
Forks
2.9k
Avg merge
1d 5h
Merged PRs (30d)
112

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AstrBotDevs/AstrBot

All issues in AstrBotDevs/AstrBot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.