feat(gateway): 支持 NO_REPLY / SKIP 静默输出标记,抑制通道转发 - #514
Open
jerryliang122 wants to merge 1 commit into
Open
Conversation
Author
|
提请这个PR 是因为,在qqbot 群聊中有相关需求。 目前框架无法解决 当qqbot 可以获取全量消息并且无需at 回复时,agents 无法静默问题。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
新增「静默输出」机制:当 AI 的最终回复以
NO_REPLY或SKIP标记结尾时,该消息不再转发到会话绑定的通道,实现"无需回复时不打扰用户"。好的。NO_REPLY。、skip)。检测函数为纯函数is_silent_reply(),与strip_thinking同置于infra/utils/llm_text.py,不引入任何配置项。collapse_to_invoke_response()(默认 invoke 模式全量覆盖;HITL 恢复轮次走同一路径自动生效;静默时连同工具生成的媒体一并丢弃)Gateway.push_text_from_session()(agent与text两种任务类型均在 outbound 定型后统一检查)on_reply)保持原有流程不做拦截;response_mode: "stream"的通道(如企业微信实时流式)不经过 invoke 包装,天然绕过本机制、标记原样输出——以上两点已用代码注释与测试固化。experts/library/default/SOUL.md)在「行为铁律」中写入该约定,新建 Agent 开箱即知。Target branch
develop(feature / fix — default)main(release/*orhotfix/*only)Type of change
Test plan
新增/扩展测试:
tests/unit/utils/test_llm_text.py(新增):标记匹配/不匹配的参数化用例——末尾中英文标点、大小写、标记居中不触发、SKIPPER/NO_REPLYX/ 无分隔粘连不误判、空串tests/unit/gateway/test_response_mode.py:末尾NO_REPLY时只产出COMPLETED;SKIP+ 工具媒体全部静默;标记出现在文本中间时正常发送;stream 模式绕过(标记原样输出不抑制)tests/unit/gateway/test_gateway_push.py:cronagent任务与text任务的输出带静默标记时不调用channel_manager.push_text本地验证:
make lint、make typecheck(mypy --strict)通过make all:2750 passed, 14 skipped。仅tests/unit/infra/setup/test_service.py3 例失败,已通过git stash在未改动的 develop 基线上复现同样失败(本机 systemd 环境问题,与本 PR 无关;CI 的 Linux/Windows runner 上该组用例正常)Checklist
CHANGELOG.md(Unreleased → 新增)