Repository navigation
fix(agent): 重启后接管等待中的问题,并正确处理过期回答 - #1707
Merged
Merged
Conversation
ChrAlpha
marked this pull request as ready for review
October 28, 2026 15:16
2 of 6 tasks
chen-ran
force-pushed
the
fix/ask-user-restart-independent
branch
from
November 1, 2026 22:24
aec751c to
1b9001f
Compare
chen-ran
approved these changes
Nov 1, 2026
2 of 6 tasks
2 of 6 tasks
chen-ran
added a commit
that referenced
this pull request
Nov 22, 2026
…p dead tests and CI entries (#1831) Toolchain - go.mod, mise.toml and the three Go base images move from 1.26.10 to 1.27.4. CI reads the version from go.mod. - golangci-lint moves from 2.10.1 to 2.15.0 (mise.toml, go-ci.yml). 2.10.1 is built with Go 1.26 and cannot load a Go 1.27 module at all. Behavior change that comes with Go 1.27 - encoding/json is backed by the v2 implementation, and the Field of an UnmarshalTypeError is now the full path, with the index of an array element and the key of a map value. Two places pass that field on: - request.field_invalid from httpx.Binder: "items.1.count" where it was "items.count", "meta.k.count" where it was "meta.count". - the decode error a tool call returns to the model: "ids.2 must be an integer" where it was "ids must be an integer". Top-level and nested object fields are unchanged. docs/errors.md describes the field, and a test for each place pins it; both fail on Go 1.26.10. What the new linter reports on the existing code (0 findings on 2.10.1, 205 on 2.15.0, 193 of them in test files) - noctx (166): httptest.NewRequest becomes NewRequestWithContext. A request that was given a context right after takes that context directly. - errcheck (19): an error received from a channel and dropped. Tests log it or assert it; cmd/bridge reaps Xvnc after killing it and says so. - gosec G602 (7): loops that re-evaluated turns[i].Messages for every element index a named slice; two test helpers become slices.Equal. - govet nilness, staticcheck SA4023: a `case !existingReady` that follows `case existingReady` is the default, and a clipboard reader that only returns on failure is not checked for a nil error. - gofumpt (4), predeclared (1), and four findings kept with a stated reason. Lint job - golangci-lint ran with only-new-issues, so findings in code a PR did not touch were never reported; that is how the above accumulated behind a green check. The job lints the whole module now and no longer needs full history. Commit hook - .husky/checks.mjs decided whether it was the entry point by comparing argv[1] with its own real path. In a checkout reached through a symlink (macOS /tmp, a linked worktree directory) the two differ, so the hook ran nothing and exited 0, for an unknown check name too. It compares real paths. - scripts/hook-checks.test.mjs inherited the caller's MEMOH_* settings, so a commit that touches .husky/ and uses the documented MEMOH_CHECK_TIMEOUT_SECONDS override failed three of its own regression tests. The fixture drops them. Removed, not replaced - internal/channel/identities/service_integration_test.go: `//go:build ignore` since February; no build includes it. - internal/settings/default_agent_concurrency_postgres_integration_test.go: has not compiled since #1110 changed botagents.Service.Delete, and no CI step builds the integration tag for that package. - internal/audio/adapter/edge/ws_integration_test.go: calls the live Edge TTS service with no skip condition and writes mp3 files to the temp directory. - go-ci.yml: the RedisDecision alternative of a -run pattern, which has matched no test since #1707 renamed it (the new name is still selected). - eslint.yml: four path filters shadowed by "packages/**" in the same list. - eslint.config.mjs: an ignore entry for a file #1813 deleted. - .golangci.yml: `go: "1.25"` (the default reads go.mod) and settings for two linters that are not enabled.
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.
Author
Type
Summary
使用 Memory live backend 时,Server 重启会让等待
ask_user回答的 run 丢失接管路径;历史问题还可能保持可回答,但用户提交后无法续跑。重启接管后,丢失的内存视图也会使问题卡片消失。另一个标签页提交迟到答案时,Web 会保留未生效的乐观答案。本 PR 让 native parked decision 在 Memory 和 Redis 下都能交接、恢复 fence 并接续同一个 run;从持久化历史重建丢失的步骤和问题卡片,后续输出接在已有内容之后。异常结束的 run 同时关闭遗留的 ask_user 请求和工具审批;WebSocket 通过稳定的 expired code 回报未应用的回答,Web 撤回该乐观答案并显示过期提示。
已于 2026-11-02 rebase 到
main(e82c2ca5f),当前 head1b9001f3b。本 PR 尚未合入的清理迁移已从0170顺延为0172_close_decisions_of_ended_runs,避开 main 已合入的0170_history_checkpoints和0171_session_attention;不修改已发布迁移。迁移仍仅关闭已结束 run 遗留的 pending 请求,不变更 schema;down 保留清理后的数据。冲突处理中保留 main 的分叉历史决策只读处理及其测试,同时保留本 PR 的重启恢复能力。Related Issues
无自动关闭关联 issue。
Validation
2026-11-02 rebase verification (
1b9001f3b)e82c2ca5f;清理迁移顺延为0172。数据库查询接口保留两侧新增方法;HTTP 历史装饰保留 main 的分叉决策只读逻辑与测试。mise run sqlc-generate:通过,无额外生成差异;git diff --check:通过。golangci-lint 2.10.1(仓库 mise 固定版本):通过。诊断过程中曾直接调用系统 2.11.4,出现不同规则的报错;最终以仓库固定版本重跑通过。decisions.test.ts:12/12 通过;本 PR 的三个前端文件 ESLint 通过;UI contract guard 通过,保留仓库已有的 3 条 warning。memoh-pr1707-rebase,Webhttp://localhost:45082/bot/pr1707-rebase,Serverhttp://localhost:45080。使用仓库scripts/dev-compose.sh+ 仓库外隔离 override。Docker 一度出现容器 inspect 超时与 pgvector 恢复;经用户允许重启 Docker 后恢复。后端使用从当前干净 head 交叉编译的 Linux arm64 二进制挂载运行,容器内外 SHA-256 相同;Web 挂载当前源码,Server / Channel / PostgreSQL / pgvector / Connect-It 健康。验收结束后已停止该独立栈,保留数据卷。b78667c1-ad67-498c-8808-3a709d2fe8ab、turn283a5fc9-aa8f-4dc3-9ab5-6c0e22c379f4完成,fence10 → 11,问题为submitted。TestSRBASE001BaselineCompletesAndPersists、TestSRDEC001DecisionPersistsRunAndTurnAcrossRestart(graceful + SIGKILL):全部通过,单 Server + Memory + 真实 PostgreSQL。GitHub 当前 head 的检查为 21 项通过、1 项 publish 按条件跳过,无失败或待完成项;通过项包括 PostgreSQL migrations、Go / Web lint 与测试、Session Runtime Redis / Valkey / PostgreSQL fencing 和构建。Historical validation (
aec751c21)以下为旧 head
aec751c21的历史验证记录;不代表 rebase 后已重跑所有项目:mise run sqlc-generate:通过,生成结果仅包含本次 tool approval 查询。TestPostgresDecisionSurvivesGracefulShutdown:真实 PostgreSQL 18 + Memory / Valkey 两组通过,验证接管、回答与重复提交。TestSRBASE001BaselineCompletesAndPersists和TestSRDEC001DecisionPersistsRunAndTurnAcrossRestart:通过;单 Server + Memory,覆盖 graceful shutdown / SIGKILL,断言同一 run/turn、pending 请求、续跑完成及回执幂等。使用确定性 OpenAI-compatible fixture provider。0170down/up:通过;session_runs、user_input_requests、tool_approval_requests的 RLS 与 FORCE RLS 均保持启用。mise run lint的嵌套任务使用了环境里的 pnpm 11,因 lockfile 配置不匹配失败;切回仓库指定 pnpm 10 后逐项运行相同检查通过,lockfile 未修改。vue-tsc --noEmit:通过。Real provider / headed-browser E2E
2026-10-28,在同一 head
aec751c21、独立 dev compose stackmemoh-askuser-s2上,以真实mimo-v2.6-pro和有窗口的 Chromium 156.0.8078.4(headless=false,隔离 X11/Xvfb 桌面)完成以下三条用户流程。Web:http://localhost:44282/bot/pr1707-real-mimo;Server:http://localhost:44280;单 Server + Memory live backend,数据库 migration 170,无 checkpoint engine unit。通过实际聊天页面发送自然语言任务:生成 NAS 迁移草稿与执行日志 →
ask_user选择切换窗口 → 生成最终计划。发送消息、回答、刷新、关闭/重新打开标签页,以及点击最终文件链接,均在真实浏览器中操作;PostgreSQL、工具调用记录和工作区文件提供独立核对。11 → 13,选择“周六白天”后正常完成,最终文件使用该选择。14 → 15,选择“周日晚上”后正常生成最终计划。user_input.expired并显示过期提示;持久化答案和最终文件均保留“周六白天”。独立核对结果:三个 run 全部为
completed,三个问题均为submitted,已结束 run 遗留的 pending 问题数为 0。每个任务持久化的draft.md写入、final.md写入和ask_user调用各一次;草稿前后内容一致,实际activity.log中“草稿已生成”和“计划已确认”各一行。点击聊天中的final.md链接后,应用文件编辑器正常打开最终计划并显示正确的切换窗口。应用发出的 19 次真实模型请求全部返回 HTTP 200:provider usage 共报告 input 366,587 tokens、output 8,033 tokens,其中 cached input 339,968 tokens。这些数字仅统计应用请求,不含接入探测。模型 context window 配置为 200k,本轮验证范围是等待决策与重启续跑。
接入方式:临时代理在内存中注入认证并转发到真实网关;初始 Python User-Agent 探测被网关以 403 拒绝,改为
curl/8.14.1User-Agent 后,上述应用请求全部成功。真实密钥未写入配置、数据库、日志或仓库;验收结束后代理已停止,临时 provider 已禁用。覆盖边界:这三条代表性用户流程通过;Redis 双 Server 拓扑、其他频道及工具审批尚未使用本次真实 provider 重跑。上述自动化与 Agent 浏览器验收不等同于 Human QA。
Screenshots / Recordings
2026-11-02 current head (
1b9001f3b)当前版本真实聊天页面的待回答问题:
SIGKILL Server 后刷新原页面,问题卡片仍可回答:
在恢复后的卡片提交 Continue,随后显示 fixture 输出;同一 run/turn 完成由上面的数据库核对支持:
Real MiMo / headed Chromium
正常重启后,在原问题卡片提交回答,同一 run 完成并保留草稿、选择和最终文件。
SIGKILL 并重新打开标签页后,原问题仍可回答;截图包含完整 Chromium 窗口和地址栏。
在恢复后的问题中选择“周日晚上”,同一 run 完成并生成对应计划。
第二个标签页提交迟到的冲突答案时显示过期提示,并保留先前已生效的“周六白天”。
点击聊天中的最终文件链接,应用文件编辑器显示实际生成的 NAS 迁移计划和已确认窗口。
Deterministic fixture evidence
以下保留首次独立分支验收的确定性 fixture 截图:重启后原问题保持可回答、回答后同一 run 完成,以及迟到回答显示过期提示。
Human QA