Skip to content

fix(conversation): retain the source behind concise replies - #5405

Merged
huangruiteng merged 1 commit into
mainfrom
codex/conversation-source-context-1001
Oct 1, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/conversation-source-context-1001

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

A short reply could reach the Agent without the message it referenced, even after the collector had fetched that parent to verify bot addressing. This lets unrelated recent material displace the actual question.

This retains the exact provider parent in the private inbox and supplies one shared TypeScript context projection to both manager and ordinary Goal Topic Turns. Parent/conversation joins are checked; omitted, unsupported or truncated content stays explicit. Visible post/card text is decoded without callback payloads. Quoted content grants no instruction or approval, and delivery retries reuse the captured event.

The compact stream now retains optional parent/root identifiers; an addressed message with a parent also performs source lookup. Unquoted Turns and existing admission/authorization rules remain unchanged. Roadmap R3 and the golden follow-up “Where is the card?” now name the source-context requirement and remaining live interpretation/return gate.

Validation: reproduced the missing-parent failure on the base; 195 focused Python tests, 8 TypeScript context/trigger/scope tests, control-plane typecheck, configured mypy, Ruff, vocabulary drift and I/O manifest checks passed. Real private inbox → Chat store → protocol subprocess → verified synthetic reply/ACK/replay was exercised for both prompt consumers. Standard risk-based premerge passed: 18 selected checks, no failures or required skips; quality receipt cqr_2ed9b8776dad8091d6a9 verifies the final 14-file scope. No live model evaluation was run.

Provider/model fixtures are synthetic: this qualifies source delivery, not deployed model reasoning, group adoption or the complete autonomous handoff. No App UI change is required because its existing conversation history is untouched; this does not claim packaged App validation. A maintainer must merge this runtime change before installed acceptance.

Signed-off-by: huangruiteng <huangrt01@163.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

未发现阻塞性问题。评审 head:1570627f1281e5b6a1071ba9f80dac0dfc2840bb。结论针对来源上下文交付,不代表完整自主委派或线上回答质量已验收。

动机

用户回复某条消息时,管家必须知道追问的是哪件事。主干虽已查询父消息来判断是否回复机器人,却没有把正文保留到收件箱和实际模型请求。核验了相同请求在两版的真实 Chat 存储:基线的两个消费者都缺少父消息,当前版本都保留了它。这是 R3 的必要增量,减少用户重述背景的负担。

改动思路

复用已有 provider 查询、私有收件箱、Chat 控制器和回复账本。Lark 适配器只提取可见正文,通用 TS 负责父消息与会话的精确关联、长度限制及缺失状态,管家和普通 Goal Topic 共用这个结果。与只改管家提示相比,这个边界避免了两个调用者复制同一规则;与扫描更多历史相比,它直接保留已知来源,也没有新增调度器、意图正则或授权来源。

具体改动

关键代码讲解

  • enrich_lark_event_reply_context 清除来信自带的来源快照,再通过现有查询保存同一群里的实际父消息。可见内容提取复用了卡片 normalizer;回调参数和不支持的媒体不会作为正文交给模型。compact stream 现在保留可选 parent/root,带父消息的明确提及也会查询来源。
  • projectConversationReplyContext 校验父消息 ID 与会话 ID,排除自引用,把不匹配、缺失、空正文与截断区分开。正文采用 JSON 字符串表达,最多进入 4000 个 UTF-16 单元;上下文标注明确不授予指令或审批权。
  • _process_lark_goal_topic_event 从已经捕获的收件箱条目读取来源,重试时不改用后来传入的内容。answer_lark_goal_topic 将同一投影放入两条现有提示路径;没有父消息时不增加该 RPC。

测试覆盖可见文本、卡片参数排除、关联错误、正文省略和实际存储/协议/回复/ACK/重复投递。RFC、roadmap 与 golden query 也明确把来源交付和后续解释验收分开;App 历史和布局未改动,没有冒称已验证安装包。

对主干的风险

最强反例是:转发测试全部通过,但模型仍把旧消息当成审批或答错追问。当前 patch 只保证有界来源交付,模型 fixture 的固定回答不能证明智能解释;提示标注也不等于完整的 prompt injection 防护。实际权限仍由原有入口决定。错误会话、父消息不符、自引用或空来源不会投影错误正文;过长内容显示不完整,不能冒称已经完整读取。旧收件箱没有此可选字段仍可读取。

语义与 CI 对齐

新增状态是 TS 本地读投影结果,不是新的 Agent 生命周期、核心完成状态或工作义务。共享核心文本保持领域中立,Python 中的格式标签属于 provider 解码。该修改不是默认关闭能力,默认变化已在文档和改名后的测试披露。来源标注是模型指导,精确关联是程序校验,两者没有混称。语义扫描对 TS union 的支持有边界;注册词汇与 I/O manifest 校验通过,未用扫描结果代替人工调用链核验。

195 个 Python 用例、8 个 TS 用例、控制面 typecheck、配置内 19 个 mypy 文件、Ruff、词汇漂移及 I/O 清单通过;标准 premerge 的 18 个检查全部通过,无必需跳过,最终范围质量回执有效。另用同一个不可变测试 harness 在基线和 head 执行:来源交付基线两处明确失败、head 两处通过;已有提及、无效权限与历史恢复的四项断言两版均通过。外部 provider/model 为合成数据;真实收件箱、Chat store 和协议子进程均已执行。未查询或等待远端 CI,也未运行付费模型评测。

我的整体评价

长期连续性与用户体验均有可证实的增量:已知来源进入持久记录,重复事件仍不会产生第二条用户消息,用户没有新增确认或重述步骤。14 个文件的改动围绕同一入口缺陷,通用规则只有一个 TS owner,没有额外兼容分支或框架;相邻重构已采取复用和删除无关格式变动。仍需由既有 R3 负责人在 maintainer 合入后的安装版本中验证真实追问解释、接收方采用和原入口结果回传,不能用本 PR 替代这部分验收。运行时改动留给维护者合入,本评审不授予自合并权限。

English verdict: APPROVE - head 1570627. Exact reply-source context reaches both real Chat consumers; paired base/head regression and parity, 195 Python tests, 8 TS tests and 18 premerge checks pass. Live referent reasoning and deployed adoption remain outside this bounded ingress change.

@huangruiteng
huangruiteng merged commit 3a35ec1 into main Oct 1, 2026
13 of 15 checks passed
@huangruiteng
huangruiteng deleted the codex/conversation-source-context-1001 branch October 1, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant