Remove the temporary copy when saving a Bot's browser control fails - #653
Merged
davidmckayv merged 2 commits intoSep 28, 2026
Merged
Conversation
The control store wrote its state to a temporary file and renamed it over the real one, but a write or rename that threw left the temporary behind. It is now removed in a finally, as the other atomic writers do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 28, 2026 09:59
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
davidmckayv
previously approved these changes
Sep 28, 2026
Move the unchanged changelog entry to its own existing anchor.
davidmckayv
approved these changes
Sep 28, 2026
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.
What this changes
createControlStorekeeps who holds a Bot's browser, and its handoff requests, in.control/<bot>.jsonunder the profiles volume.savewrites the state to<bot>.json.<uuid>.tmpand renames it over the real file. When the write or the rename threw (disk full, a file that cannot be replaced), the temporary file was left where it was: a second, readable copy of the control state, and one more for every later failure. The existing test already holds that a save leaves.controlwith onlybot-1.jsonin it; that held only while every save succeeded.savenow removes the temporary in afinally, whether or not the rename happened, the same shapescripts/setup-learning.ts(saveEnvironment) andserver/src/provider-oauth.tsuse for their atomic writes. After a successful rename the path no longer exists, andrmSyncwithforcedoes nothing. The error from the write or rename still propagates unchanged.Where it runs
OpenBot is deployed as several server processes behind a load balancer, serving a whole company.
Consecutive requests from the same person reach different processes, and the process that answered a
WebSocket upgrade is rarely the one that answers the next call on that conversation.
State that outlives a single request therefore has to be shared, or the change works on one machine
and stops working the moment there are two, without saying so. That failure is worse than not
shipping the feature: it passes review, passes CI, passes a local demo, and only surfaces as a Bot
that forgets, a question nobody can answer, or a boundary that never fires.
Answer these even when the answer is "none":
Boundary and audit
Changelog
CHANGELOG.mdunderUnreleased.Proof
New test in
agent-computer/tests/control-store.test.ts: a directory wherebot-1.jsongoes, so the rename fails, then.controlis listed. On unmodifiedmain:After the fix:
bun test tests/control-store.test.tsinagent-computer→ 7 pass, 0 fail.tsc --noEmitinagent-computerexits 0. Biome check clean on the changed files.🤖 Generated with Claude Code