From 943192351a583fd09dd63dcdb8c0f6e747500a5c Mon Sep 17 00:00:00 2001 From: only-cli Date: Wed, 19 Aug 2026 08:34:27 -0400 Subject: [PATCH] warn when a session can't be saved, instead of failing silently Found while chasing an anomalous benchmark rerun: under a sandbox that blocks writes outside its workspace (codex exec's default), 'oc open' still renders fine but its session save throws, and the bare catch {} swallowed it completely. The next 'oc do' then resolves against whatever session last saved successfully, silently, with no sign the state is stale. In one repro this served a Hacker News agent a Yahoo Finance page under 'oc do 5' and it answered from that instead of erroring, which is how a multi-step task ballooned to 250k tokens without a single wrong tool call visible in the log. This does not fix the staleness itself, that needs a design for detecting a save failure across separate 'oc open' and 'oc do' invocations. It makes the failure visible on stderr instead of invisible, which is the cheap half of 'fail loud and cheap' and better than nothing while the real fix gets designed. Verified manually against an unwritable OC_HOME; cli.js's main() always calls the network fetcher, so an automated test here would need fetch-mocking infrastructure this project has none of yet, and none of cli.js has test coverage today. --- src/cli.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 1ae49d9..402633a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -41,11 +41,17 @@ budget left behind without fetching it again. State lives in ~/.only-cli // A rendered page has to be remembered or its [3] means nothing to the next // command. Saving state must never break a render, so a home directory that -// cannot be written costs the agent `do`, `read`, and `next`, and nothing else. +// cannot be written costs the agent `do`, `read`, and `next`, and nothing +// else, but silently: a sandbox that blocks the write leaves `do` resolving +// against whatever session last saved successfully, possibly from an +// unrelated page, with no sign anything is wrong. So the failure still prints, +// on stderr where it costs nothing until something breaks. const remember = (page, name, cursor) => { try { saveSession(name, sessionFromPage(page, loadSession(name), { cursor })); - } catch {} + } catch (err) { + console.error(`oc: warning: could not save session '${name}' (${err.message}), 'do'/'read'/'next' may act on stale state`); + } }; // What browsing costs without this tool is the raw page HTML in context.