feat(Phase4):提升终端诊断与 IDM 模式可用性#565
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
| for _, spec := range specs { | ||
| gotNames[spec.Name] = true | ||
| } | ||
| if len(specs) != 2 || !gotNames[ToolNameFilesystemReadFile] || !gotNames[ToolNameTodoWrite] { |
There was a problem hiding this comment.
medium This assertion only checks that todo_write is listed in read-only/plan mode. The execution path still maps todo_write to a write action and DefaultManager.Execute rejects all non-read actions when input.ReadOnly is true, so the model can see the tool but still cannot call it. This PR claims to restore plan-mode todo support, but with the current coverage it only restores visibility, not usability.
| s.leftover = nil | ||
|
|
||
| for index := 0; index < len(buffer); { | ||
| if hasPrefixAt(buffer, index, tmuxDCSOpen) { |
There was a problem hiding this comment.
medium Observe only keeps leftovers after it has already matched a full tmuxDCSOpen / ESC[ prefix. If a PTY read ends with a bare ESC or a partial \x1bPtmux;, those bytes are dropped here and the next chunk can no longer be recognized as an alt-screen transition. PTY reads can split anywhere, so chunked tmux/CSI prefixes will still leak false auto-diagnosis triggers despite the new guard.
| } | ||
|
|
||
| streamCtx, streamCancel := context.WithCancel(context.Background()) | ||
| streamCtx, streamCancel := context.WithTimeout(context.Background(), diagnoseCallTimeout) |
There was a problem hiding this comment.
medium Changing the stream context from WithCancel to WithTimeout(diagnoseCallTimeout) puts a hard 90s cap on every @ai run. After that deadline, waitRunStream returns and we cancel the run even if the model is still streaming normally. The bind/run RPCs already have their own 90s call timeouts, so this regresses any legitimately slow or long answer into a deterministic timeout rather than just fixing the stuck-ACK case.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Summary
本 PR 落地 Phase4 终端诊断可用性改进,重点解决三个问题:
@ai失败后可能卡死、等待提示不及时。本阶段保持主链路不变:诊断仍通过
gateway.executeSystemTool(diagnose),IDM 仍通过 Gateway 调 Runtime,不新增公共 Gateway RPC schema,也不修改现有诊断超时预算常量。Closes #532
Key Changes
1. Phase4 回滚开关
新增 Phase4 相关环境变量开关,方便线上快速回退:
NEOCODE_DIAG_ALTSCREEN_GUARD_DISABLED=1NEOCODE_IDM_PLAN_MODE_DISABLED=1NEOCODE_DIAG_FAST_RESPONSE_DISABLED=1NEOCODE_DIAG_CACHE_DISABLED=12. 全屏保护
新增备用屏幕状态追踪,识别终端进入/退出全屏程序的控制序列:
CSI ? 1049 h/lCSI ? 47 h/lCSI ? 1047 h/l自动诊断触发前会检查当前是否处于全屏状态:
3. IDM 防卡死与 plan 模式接入
IDM
@ai请求接入 Runtimeplan模式:gateway.run中传入Mode: "plan"。NEOCODE_IDM_PLAN_MODE_DISABLED=1回退。todo_write可见性。修复 IDM 卡死问题:
bind_streamACK / ERROR / 非预期帧。gateway.runACK / ERROR / 非预期帧。agent_done无 chunk 时,从 done payload 中兜底提取文本展示。permission_requested继续自动 reject,并保持状态清理。Ctrl+Ccancel 行为不回归。4. IDM 流式显示
此前 IDM 虽然收到 gateway 的
agent_chunk,但会先缓存,直到agent_done才统一 Markdown 渲染显示。本 PR 改为:
agent_chunk立即输出到终端。agent_done不再重复渲染完整答案。这能显著降低 IDM
@ai的等待感。5. 诊断响应提速
新增
diagnosisCoordinator,用于诊断请求调度与复用:新增快速首响:
Test Plan
已通过本地验证:
go test -count=1 ./internal/ptyproxy ./internal/tools ./internal/runtime覆盖重点:
bind_stream/gateway.run异常帧不会卡死。agent_donepayload fallback 可展示。agent_done前即可流式显示。todo_write保持可见。Risk & Rollback
风险主要集中在终端输出体验和诊断调度策略:
可通过以下环境变量逐项回滚: