[Feature] 用户识别标识的位置:内联前缀 vs 尾部 system_reminder

Abierto
#10,887 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
python
Área
ai, backend

Línea de trabajo

Read astrbot/core/config/default.py and astrbot/core/astr_main_agent.py to compare the identifier hint with where the reminder is added; then inspect openai_source.py and builtin_stars/astrbot/group_chat_context.py for the content-block and formatting context. This issue is explicitly for discussion, not a PR, and leaves the desired behavior undecided, so there is no implementation or test-defined completion criterion yet.

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

Descripción

enhancement
功能描述

功能描述

provider_settings.identifier(面板:配置 → AI → 用户识别)的 UI 文案与实现不一致,且实现位置对"让模型区分发言人"这个目标可能不是最优。想就此发起一次讨论。

文案(astrbot/core/config/default.py:4173,v4.29.3 与 master 一致):

"provider_settings.identifier": {
    "description": "用户识别",
    "type": "bool",
    "hint": "在用户提示词前带上用户 ID 信息。",
},

实现(astrbot/core/astr_main_agent.py → _append_system_reminders):

if cfg.get("identifier"):
    user_id = event.message_obj.sender.user_id
    user_nickname = event.message_obj.sender.nickname
    system_parts.append(f"User ID: {user_id}, Nickname: {user_nickname}")

system_parts 最终拼成 <system_reminder>...</system_reminder>,经 req.extra_user_content_parts 走 assemble_context() 追加到 content_blocks 末尾。openai_source.py 里对应位置也注明「用户原始发言在前,额外内容块在后」。

也就是说,实际位置在用户原话之后,与文案写的"前"相反。

(group_name_display 的 hint 同样写"前",实现同理,属于同一模式,可一并考虑。)

使用场景

群聊里希望模型准确判断"这句话是谁说的"。

两种位置的差异:

  • 尾部独立块:标识与消息内容在结构上分离(同一条 message 的不同 content block),模型需要做相邻关联。群里连续多条发言、交叉对话、互相引用时,存在错配的空间。
  • 内联前缀:标识与内容在同一字符串内,物理上不可分离,关联更直接。

补充一点实测数据,供讨论参考。若改为内联 f"{nickname}: {prompt}",昵称自带冒号会产生歧义。某 700 条真实群聊记录里,29 位发言人中有 4 位昵称含冒号(约 14%):

增强:123sdx53228
求崩:Cartethyia_Ni
增强🆔:doro994645(职业进度21
增强:芣婹説話,閉仩觜妑

拼出来是 增强:123sdx53228: 我来了,可被读作「'增强' 说:123sdx53228: 我来了」。

而群聊上下文注入用的 _format_message(builtin_stars/astrbot/group_chat_context.py)是 [昵称/时间]: 内容,方括号把昵称整体框住,恰好规避了这类歧义——同样是内联,包装方式值得对齐。

建议(供参考,不代表必须这么做)

  1. 最低成本:让文案与实现一致。要么改 hint 的"前",要么改实现位置。
  2. 若倾向内联,建议用 [昵称]: 内容,与注入块 [昵称/时间]: 保持同一套包装,避免昵称含冒号时的歧义。
  3. 无论选哪种,都可以考虑在 system prompt 补一句格式说明(例如「[昵称]: 前缀表示发言人,昵称可能重复」),让模型知道如何解读,收益比单纯换位置更大。
  4. 附带说明:位置不影响前缀缓存。两种做法都在当前 user message 内部,不改变历史前缀,只影响模型对发言人的归因。

声明

本 issue 由AI代写,仅为讨论与建议,不打算提交 PR。是否调整、怎么调整,交由维护者判断。

使用场景

No response

检查清单
  • 我已在 Issue 列表中搜索过相关功能,确认该功能想法从未被提出过。
  • 我建议的功能与 AstrBot 本体相关,而非在建议某一插件的功能。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助实现该功能。
Lenguaje dominante
Python
Estrellas
46.4k
Forks
3.4k
Merge medio
1 d 11 h
PR fusionados (30 d)
120

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

Todos los issues de AstrBotDevs/AstrBot

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.