feat(codex): enable embedded_context (@file mention) — phase 2#2219
Merged
Conversation
codex backend 第一个 Phase-2 Feature。方案 A:借 codex 原生 agentic 读取。 实测确认(codex 0.141,§6 探针矩阵): - codex 的 @path 不是 claude 式静态内联,而是靠 agentic shell 工具读取 (纯 text 含 @path → codex 解析并发 commandExecution 读文件)。 - 结构化 mention UserInput 在 0.141 下对内联无帮助(cwd/绝对/带 text_elements 三种探针全部未解析),故不发 mention 条目。 落地(最小正确改动,零协议码): - profile_codex.go: Features[embedded_context]=true + 诚实注释(agentic 读 vs 静态内联,取决于沙箱;dashboard 闸门只要求"从 prompt 读路径", codex 满足)。@path 已随 text 透传进 turn/start,WriteMessage 无需改。 - 测试: WriteMessage_AtMentionVerbatim(@path 逐字进 text UserInput) + profile_test 断言 embedded_context=true / askuser·passthrough 仍 false。 - docs/rfc/codex-backend-phase2-feasibility.md §6 记录探针矩阵+决策+ 与 claude 的诚实差异。 诚实差异:弱于 claude 静态内联保证(read-only 沙箱下读不到),但匹配 dashboard 契约且 naozhi 侧零文件读取/零新增安全面。 go build/vet/test ./internal/cli ./internal/cli/backend ./internal/server 全绿。
2 tasks
KevinZhao
added a commit
that referenced
this pull request
Jun 21, 2026
…2220) 并行深挖 passthrough + askuser 后,初判结论翻转(§7/§8): §7 passthrough → 推迟(实测否定): §2 只验了 clientUserMessageId round-trip + turn/steer 的 ACK,没验效果。 补做 3 组效果探针(Bedrock gpt-5.5):长文 pivot / 数数追加 / tool 占用中 steer —— turn/steer 全部 ACK 成功但模型不采纳 steered 输入(silent no-op)。开 passthrough 会让 /urgent/并发消息被 codex 静默丢弃,比现有 Collect 模式更差。决策:不 ship,保持 Collect。教训:协议 ACK≠语义生效。 §8 askuser → 可实现(schema 已 live 捕获): 方法名 item/tool/requestUserInput(需 --enable default_mode_request_user_input, 旧猜名 request_user_input 错误致 server 退出)。请求/响应 schema、阻塞性、 空答案致 re-ask 死循环全部实测确认。难点:codex 真阻塞,要加回 claude askuser RFC 删掉的 pending 表/TTL/RPC 回写(~2-3d,独立 PR)。 推荐顺序更新:embedded_context(已交付#2219) → askuser → ~~passthrough~~推迟。
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.
概述
codex backend 的第一个 Phase-2 Feature:
embedded_context(@filemention)。承接 PR #2216(codex backend Phase-1 已合并)。实现路线 方案 A:借 codex 原生 agentic 读取(用户确认)。
实测决策(codex 0.141,详见
docs/rfc/codex-backend-phase2-feasibility.md§6)初判"用结构化 mention UserInput"被探针推翻:
mention(cwd-相对 / 绝对 path)text+text_elements+mention(TUI 线格式)text含@path@path并发commandExecution读文件结论:codex 的
@path不是 claude 式静态内联,而是靠 agentic shell 工具读取;结构化 mention 在 0.141 对内联无帮助 → 不发 mention 条目(避免投机复杂度)。改动(最小正确,零协议码)
internal/cli/backend/profile_codex.go:Features["embedded_context"] = true+ 诚实注释。@path已随text透传进turn/start的 text UserInput,WriteMessage无需改。dashboard 闸门featureForCurrent('embedded_context')(dashboard.js:4136)只要求"后端能从 prompt 内读路径",codex 满足。TestCodexProtocol_WriteMessage_AtMentionVerbatim(@path逐字进 text UserInput,不被 strip/rewrite)+ profile_test 断言embedded_context=true、askuser/passthrough仍 false。docs/rfc/codex-backend-phase2-feasibility.md§6:探针矩阵 + 决策 + 与 claude 的诚实差异。与 claude 的诚实差异
弱于 claude 静态保证,但匹配 dashboard 契约。claude 式强保证需 naozhi 服务端内联(路径穿越/大小限制/workspace confine 安全面),留独立 RFC。
测试计划
go build ./...gofmt -l(无 diff)go test ./internal/cli/ ./internal/cli/backend/ ./internal/server/后续 Phase-2(不在本 PR)
🤖 Generated with Claude Code