[Bug] 「本地执行不可联网」提示按发言人权限 system prompt 中段,群聊共享会话里如果联网权限不同则会导致整轮缓存失效

Aperta
#11,054 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pcbeingused333 ci sta già lavorando.

Dal 8/11/2026.

  • #11055 di @pcbeingused333 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Start by reading astr_main_agent.py's build_main_agent in v4.29.3, or astr_main_agent/computer_use.py's ## Execution policy in master, and trace where LOCAL_NETWORK_POLICY_NOTICE enters the prompt. The issue proposes moving speaker-dependent text to the current user message as temporary content or keeping the session prompt consistent. Done means alternating speakers in a shared group session no longer invalidates the prompt prefix cache; an open linked pull request indicates work is already underway.

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

Descrizione

bug
问题描述

环境:computer_use_runtime = local,管理员可联网、普通成员不可联网(默认)。群聊不开隔离对话(整个群共用一个会话),模型走 OpenAI 兼容接口(DeepSeek,自动前缀缓存)。

LOCAL_NETWORK_POLICY_NOTICE 只在「当前发言人可执行、不可联网」时追加到 system_prompt(v4.29.3 在 astr_main_agent.py build_main_agent 末尾;master 在 astr_main_agent/computer_use.py 的 ## Execution policy)。它的位置在 system prompt 中段,后面还有工具使用提示、workspace 说明等。

于是同一个群里管理员和普通成员交替发言时,system prompt 会在这句话处时有时无,从这里往后的 system 内容和全部历史都无法命中前缀缓存。

实测(同一群、同一会话,30 轮主模型请求):

  • system prompt 只有两种:8326 字 / 8600 字,差的正好是这句提示;
  • 同一类人连续发言、间隔较短时,缓存命中 96%~99%;
  • 管理员与成员每切换一次,那一轮约 10 万 token 全部未命中,耗时从约 20 秒变为 30~150 秒。

相关:#10134 把这条提示从工具结果移进了 system prompt。私聊里发言人固定,所以不受影响;只有多人共用一个会话时才会出现。

建议:按发言人变化的内容不要放进 system prompt。例如放到当前用户消息末尾作为临时内容(mark_as_temp),这样不影响前面的缓存;或者对同一会话保持一致。

如何复现?
  1. computer_use_runtime 设为 local,保持普通成员不可联网(默认)。
  2. 群聊中不开启隔离对话。
  3. 管理员和普通成员交替 @ 机器人,对比两次请求的 system prompt,或查看服务商返回的缓存命中 token。
AstrBot 版本

4.29.3

操作系统

Linux

部署方式

Docker

使用的消息平台适配器

aiocqhttp

错误日志
无报错,表现为缓存命中率下降、响应变慢。
辅助信息

No response

检查清单
  • 我已在 Issue 列表中搜索过相关问题仍无法解决,或该问题从未被报告过。
  • 我已尝试过禁用所有插件,排除了可能是因插件导致的问题。
  • 我报告的问题与 AstrBot 本体相关,而非在报告某一插件的问题。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助修复该问题。
Lingua principale
Python
Stelle
46.4k
Fork
3.4k
Merge medio
1g 11h
PR unite (30g)
120

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 AstrBotDevs/AstrBot

Tutte le issue di AstrBotDevs/AstrBot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.