[Feature] 让模型参与分段:新增 segmented_reply.model_controlled,用标记/换行决定气泡边界
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
- 12/100
Línea de trabajo
Start with ResultDecorateStage in astrbot/core/result_decorate/stage.py (the early return on streaming results and the words_count_threshold skip near line 220), then RespondStage in astrbot/core/respond/stage.py where _calc_comp_interval and the per-segment asyncio.sleep(i) live. The config schema is in astrbot/core/config/default.py. This touches prompt injection and streaming, so it needs maintainer design agreement first. Done would mean the model-controlled markers and the streaming fallback are honored, with the old regex/words behavior unchanged when the option is off.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
现象
分段边界由程序决定,模型无法参与:
- 只有程序切分:
split_mode只有regex/words(astrbot/core/config/default.py:111-129),切分发生在result_decorate/stage.py:208-267,输入是最终纯文本。模型没有「这句单独发」「这两句连在一起」的表达方式;换行、空行、语义停顿都不影响切分,结果类型中也没有「分段意图」字段。 - 流式下配置也不生效:
streaming_response=true时ResultDecorateStage对流式结果直接return(stage.py:134-135、:137/191-193),实际按适配器硬编码的标点。?!~…和固定sleep(1.5)切分(platform/astr_message_event.py:342-353、sources/aiocqhttp/aiocqhttp_message_event.py:244-261),regex/interval无人读取。 - 长文本不分段:超过
words_count_threshold(默认 150)的Plain整段跳过(stage.py:220)。 - 首段也要等待:
respond/stage.py:355-356每段发送前asyncio.sleep(i),首段同样等待一个 interval(#9931 曾提出跳过,但未合并)。
期望行为
- 模型可控(可选,默认关闭):新增
segmented_reply.model_controlled,向 system prompt 注入约定「需要换气泡时用空行或<|seg|>分隔」;切分时优先按标记,模型未给标记则回退现有 regex/words,老用户行为不变。 - 流式复用配置(可选;若维护者认为 #8313 已覆盖,可只做第 1 点):
send_streaming的 fallback 接收split_mode/regex/split_words/interval,不再硬编码标点和 1.5s。 - 长文本语义:
words_count_threshold改为「超过则按更粗粒度再切」,而不是跳过切分。 - 首段延迟可配:增加「首段前是否 sleep」的开关(可复用 #9931 的思路)。
与已有 issue 的关系
- #8313(open)只要求流式 fallback 的分割字符可自定义;本 issue 的核心是模型参与分段,第 2 点只是附带。
- #10176(open PR)方向相反,要求工具调用后的最终答案不要乱切。
- #10722(open)是发送侧管控(刷屏、在途分段不可打断),与「边界由谁决定」不同层。
- #10916(open PR)是最大分段数;#9931(closed 未合并)是跳过首段延迟。
- 本 issue 不是以上任一条的重复。
复现(模型无法控制边界)
- 开启
segmented_reply(split_mode=regex,默认正则)。 - 要求模型「刚才那句单独发」「这三句连成一条发」,实际仍按
。?!~…切,模型意图不生效。 - 让模型用空行或换行表达换气泡,结果被忽略或并入同一段。
- 打开
streaming_response=true再试:连regex/interval也不生效,变成硬编码标点加固定 1.5s。
版本 / 环境
- AstrBot v4.29.4(
6133541,2026-10-31);master630d5cee(2026-11-14)核心分段逻辑未变 - Linux + aiocqhttp/NapCat,Python 3.12
streaming_response=true,segmented_reply.enable=true
建议实现
ResultDecorateStage:不要对流式结果一刀切return;把分段参数传给send_streaming,由 fallback 使用配置切句(同时消化 #8313)。RespondStage:流式分支复用_calc_comp_interval的节奏控制,而不是在适配器内部写死 1.5s。- system prompt:按
model_controlled开关注入分隔协议;切分函数优先按标记,其次 regex;兼容only_llm_result。
- Lenguaje dominante
- Python
- Estrellas
- 46.9k
- Forks
- 3.6k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 140
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de AstrBotDevs/AstrBot
-
[Bug] Sending a Telegram message chain twice duplicates mentionsPosiblemente ocupada @123XieC la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AstrBotDevs/AstrBot#11125 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Telegram album debounce exceeds the maximum waitPosiblemente ocupada @123XieC la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AstrBotDevs/AstrBot#11123 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
AstrBotDevs/AstrBot#11034 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug] OpenAI-compatible Gemini 工具 schema const 导致 400Posiblemente ocupada @arccat-114 la tomó hace 27 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
AstrBotDevs/AstrBot#10720 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug] Discord slash command sync aborts with KeyError when a plugin handler is defined in a submodulePosiblemente ocupada @yuexia5 la tomó hace 32 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
AstrBotDevs/AstrBot#10626 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de AstrBotDevs/AstrBot
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
abetlen/llama-cpp-python#2424 ·
Los mantenedores suelen responder en 1 día
-
Bug IronPython Python 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pyrevitlabs/pyRevit#4184 ·
Los mantenedores suelen responder en 1 día
-
CLAW (Agents & Orchestration)Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
jqueryscript/awesome-claude-code#1009 ·
-
tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día