Repository navigation
fix(agent): let one unreadable worker watch not stop the Bot's other wakes - #6624
Conversation
…wakes The wake pass read every stored worker watch and failed the whole pass on the first record it could not decode, so the Bot was never woken for any worker again. The Bot's own demo data hit this after a build changed a type embedded in the stored route: eighteen old watches could not be read, and the worker created afterwards was never reported. An unreadable watch is now skipped and reported once, and left in place. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
I reviewed all three changed files at b3196d8c861f1ba3e15130b928e551a756f8f0c3. I found no confirmed P0–P2 issue in this change.
The failure mechanism is present in the previous code: watches() decoded the entire scan before returning any watches, and propagated the first decode error, so even valid records encountered earlier never reached wake_bot_pass(). The change catches individual decode failures while preserving scan failures, stored revisions and the existing notification admission/deduplication path. It neither deletes unreadable records nor marks their workers as notified. The warning suppression is in memory and resets with the Host.
I read the actual logs for CI 41793338194: the new unreadable-record case passed in 13.711 seconds; the existing ordinary wake and busy-Bot cases passed in 11.303 and 16.516 seconds. The fixture puts an invalid watch before a real worker and checks both the resulting wake and the absence of a second wake. This supports isolation of decode failures; its deliberately incomplete record does not demonstrate decoding or migration of a genuine historical AcceptedModel record. The author's reported reversal test and real-model observation remain the author's evidence, not tests I reran.
The actual Git merge against rust-preview at 5986e21ecba0ad3c33edc2366e66be8a55406bd4 completed without conflicts. I did not run Rust or a native desktop locally. Old unreadable watches still need a separate recovery/migration decision; this fix restores progress for readable workers, not notifications for the skipped workers.
P3: the body attributes substantive work to Claude Code, but the current commit has a Co-Authored-By line and no Generated-by: Claude Code trailer. Please preserve the required Generated-by attribution in the final commit. This has no runtime impact.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
M4n5ter
left a comment
There was a problem hiding this comment.
English
Isolating a single unreadable watch record so it does not block wakes for other healthy workers is a reasonable goal, but the current implementation—swallowing and skipping the error inside watches(), leaving the corrupt record in place, and adding a Mutex<HashSet> for deduplication—is incomplete and not clean enough:
- The write path cannot overwrite and heal a corrupt record:
Bot::watchstill callsself.read::<Watch>(&key), which fails immediately when the existing record cannot be deserialized. Leaving the corrupt record in place causes subsequentSessionSendcalls that refresh the watch to keep failing, leaving that worker permanently unable to wake the Bot. - The GC cleanup path is bypassed:
wake_bot_passnormally callsforget(&worker, revision)when a worker session has been archived or deleted (which does not require decodingWatch). Dropping unreadable records early inwatches()causes corrupt records for archived or deleted sessions to remain in the database forever and fail deserialization on every poll. - Redundant deduplication state: The outer loop in
start_bot_wakealready deduplicates errors viaprevious_error, so there is no need to maintain an append-onlyunreadable: Mutex<HashSet<String>>onBot.
Please converge the implementation following the tick_goals pattern in #6616 (without adding any legacy data-format compatibility branches):
- Have
watches()return(worker, revision, Result<Watch, StoreError>); inwake_bot_pass, check session liveness first so archived or missing sessions still go throughforget, then collect decode errors for live sessions while continuing to process healthy workers, and finally return the combinedErrsostart_bot_wake's existingprevious_errorhandles deduplication. - Have
Bot::watchread the underlying record'srevisiondirectly, treating an unreadable existing value asnotified: Noneand overwriting it cleanly with the new record. - Further, consider decoupling
WatchfromReturnRoute/AcceptedModel(similar toScheduledTask) by persisting onlyModelSelection,thinking_level,workspace,binding, andnotified, and resolving the current model viaSource::selecton wake. That eliminates the root cause where internal execution-snapshot changes invalidate stored watches (legacy local data can be handled via an offline migration/cleanup script while keeping a single current format in the runtime).
Also, please follow CONTRIBUTING.md when updating: fix the truncated commit subject, include the ## AI use disclosure in the PR description, carry a Generated-by: <tool> trailer on materially AI-authored commits, and have automated comments identify themselves.
简体中文
隔离单条不可读 watch 记录、避免阻塞其他正常 worker 唤醒的目标是合理的,但目前“在 watches() 内直接吞错跳过、原地保留坏记录并新增 Mutex<HashSet> 去重”的实现不完整也不够干净:
- 写入路径无法覆盖修复:
Bot::watch仍调用self.read::<Watch>(&key),旧记录反序列化失败会直接报错退出。坏记录留在原地会导致后续SessionSend刷新 watch 时持续失败,该 worker 永久无法恢复唤醒。 - 绕过了 GC 回收路径:
wake_bot_pass原本会在 worker 会话已归档或删除时调用forget(&worker, revision)清理记录(此步骤不依赖解码Watch)。在watches()中提前丢弃坏记录后,已归档/删除会话的损坏记录将永久残留在数据库中并在每次轮询时重复解码失败。 - 重复造了去重状态:
start_bot_wake外层循环本身已有previous_error去重机制,无需在Bot上额外维护只增不减的unreadable: Mutex<HashSet<String>>。
建议参照 #6616 中 tick_goals 的模式收敛实现(不增加任何旧数据格式兼容分支):
watches()返回(worker, revision, Result<Watch, StoreError>);wake_bot_pass先检查会话存活并在归档/不存在时照常forget清理,再对存活但解码失败的记录收集错误并继续处理其余正常 worker,最后汇总返回Err交由start_bot_wake现有的previous_error去重。Bot::watch直接读取底层记录的revision,旧值解码失败时按notified: None直接用新记录覆盖修复。- 更进一步,建议顺手将
Watch从ReturnRoute/AcceptedModel解耦(参考ScheduledTask),只持久化ModelSelection、thinking_level、workspace、binding与notified,唤醒时走Source::select解析当前模型,从根源上避免内部执行快照变动破坏存储记录(旧本地数据附离线迁移/清理脚本即可,运行时只保留单一新格式)。
另外,更新时请遵循 CONTRIBUTING.md:修复被截断的 commit 标题,补充 PR 描述中的 ## AI use 声明,在实质由 AI 编写的提交中携带 Generated-by: <tool> trailer,并在自动化评论中标明自动化身份。
English@liugddx Looks like this was merged just before my review above went out—no worries at all! Whenever you get a chance, could you take a look at the points above (closing the overwrite and GC cleanup paths, dropping the extra 简体中文@liugddx 刚发完才看到几分钟前已经合并了,没关系!有空的话麻烦看一下上面提到的几点(补齐覆盖写入与 GC 回收闭环、去掉多余的 |
…h, store only what a wake needs Follow-up to #6624, following the review there. - watches() returns each record's decode result. wake_bot_pass checks that the worker is alive first, so a watch of an archived or missing worker is retired without being decoded; for a live worker it collects the error, keeps waking the healthy ones and returns the combined error, which start_bot_wake already de-duplicates. The in-memory set of reported workers is removed. - Bot::watch reads the record itself, so a value that no longer decodes is replaced by the refresh with notified unset instead of failing every send. - A watch no longer embeds ReturnRoute and AcceptedModel. It keeps the model selection, thinking level, workspace, binding and notified, and the model is resolved with Source::select when the Bot is woken, so a later change to an accepted model cannot make stored watches unreadable. Generated-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a wake needs (#6627) Follow-up to #6624: - `watches()` returns each record's decode result, and `wake_bot_pass` checks worker liveness first so watches of archived, missing, or replaced-Bot workers are retired without decoding; decode and model-resolution errors on live workers are collected and returned once for `start_bot_wake`'s existing error deduplication, removing `Bot.unreadable`. - `Bot::watch` reads raw storage directly so refreshing a worker whose old watch no longer decodes replaces it cleanly with `notified` unset. - `Watch` stores `ModelSelection`, `thinking_level`, `workspace`, `binding`, and `notified` instead of embedding `ReturnRoute` / `AcceptedModel`, resolving the model via `Source::select` only after confirming the Bot Session is idle and not parked. Generated-by: Claude Code Generated-by: Antigravity Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Wang <[email protected]>
Summary
The wake pass that reports a finished worker to the Bot read every stored worker watch and failed the whole pass on the first record it could not decode. One unreadable record therefore stopped the Bot from being woken for any worker.
I hit this in the Bot's demo data on a build after #6584: eighteen watches written by an earlier build embed
ReturnRoute, which embedsAcceptedModel, and a field was removed from that type, so they no longer decode (unknown field 'context'). A worker the Bot created afterwards finished, but the Bot was never told, and the same error was logged on every poll.An unreadable watch is now skipped and reported once per worker, and left in place. Nothing else changes.
Why not more
I did not add a conversion for the old records. The underlying coupling remains: a stored watch embeds a type owned by another module, so any later change to
AcceptedModelcan make existing watches unreadable again. Storing only what a wake needs (the connection, model and workspace) would remove that. I left it out of this fix to keep it small; I can do it as a follow-up if you want it.Verification
a_watch_this_build_cannot_read_does_not_stop_other_workers_waking_the_bot: an unreadable watch that sorts before any worker is stored, then a worker is created and finishes. With the skip, the Bot is woken. With the previous code the same test fails because the wake never happens (checked by reverting the change).-D warningsand nightlyrustfmtare clean.🤖 Generated with Claude Code