Repository navigation
fix(cost): preserve healthy worker updates on rollout I/O errors - #2178
Conversation
Forward healthy sessions' activity, events, and progress before reporting a session's original read failure. Keep retries and incomplete cost subtotals so later recovery and explicit cost limits retain their existing semantics. Cover errors before thread discovery, known workers, event replay, and recovery with portable permission-error fixtures.
|
@codex review Check whether one unreadable worker log affects other workers, activity replay, or an explicit cost limit. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Failed replay still delivers queued worker activities, allowing a successful retry to deliver them again with fresh deduplication state; delivery must be deferred until recovery while preserving measured usage.
1 open issue
What changed in this PR
This PR updates SDK cost tracking so unreadable session logs do not prevent healthy workers from reporting activity and progress, addressing the observation failure described in #223.
Changes:
- Defer session-read and replay errors until healthy observations are delivered.
- Mark cost subtotals incomplete during accounting failures and restore complete totals after recovery.
- Add regressions for permission failures, replay failures, continued progress, event deduplication, and recovery.
| File | Description |
|---|---|
sdk/typescript/tests-ts/cost.test.ts |
Adds failure-isolation and recovery regressions. |
sdk/typescript/src/cost.ts |
Defers read errors and reports partial accounting alongside healthy observations. |
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4aa62cbdc1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
mldangelo-oai
left a comment
There was a problem hiding this comment.
I reproduced the replay issue in the existing review threads. With both activity and session events enabled, a worker that had written one message delivered it twice after its log became readable again.
The same four permission-failure cases passed on #970, and its recovery test delivered that message once. It also preserves the spending-limit behavior on main. With a limit set, this branch continued opening other logs after the first unidentified log became unreadable, delaying the accounting error that stops the scan.
|
@codex review Please recheck the updated commit |
…-worker-isolation
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review Please recheck the updated commit |
mldangelo-oai
left a comment
There was a problem hiding this comment.
Thanks for fixing both cases. I reran the same probes on 9c3cb3b8. The recovered worker delivered its message once, and a scan with an explicit budget stopped reading as soon as an unidentified worker log could not be opened.
I found one difference while checking the overlap with #970. In an uncapped poll, an unidentified worker log returned EACCES, then listing the next session directory returned EMFILE. This branch reported the later directory error and lost the original file diagnostic. On both main and #970 the poll returned the original EACCES. #970 also passed the healthy-worker and recovery cases, so I’d keep the fix for #223 there.
There was a problem hiding this comment.
🟡 Changes recommended
A later directory-read failure can bypass the catch in sessionFiles(), causing refresh() to discard healthy-worker observations and replace the first relevant accounting error.
1 open issue
1 resolved since last review
Review effort: Balanced
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review Please recheck the updated commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e566fb468
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
The warning-episode change works when a file stays secondary. With five unreadable logs, patch() now reported all five at the start of each failure period and only the primary on subsequent polls. I also verified the earlier directory diagnostic wins over a later replay error, all forty related histories fit under the 96 MiB heap limit, and an unrelated log failure leaves a capped scan’s accounting intact.
A recovered file can still fail silently when it changes roles. In a public SDK scan, A and B both failed to open with EACCES, then both opened successfully and the tracker reported complete usage. When B alone failed again, main reported B and this revision emitted no warning. The same happened when B’s error changed to EPERM. Reporting B as a secondary error puts its path in the scan-wide set used to suppress primary errors. Please keep that secondary report from silencing a later sole failure. The regression test also needs a controlled listing order. Returning B before A made it wait for a third A warning that never came.
Repeated opens are still costly when many histories stay unreadable. With 1,000 synthetic history entries and real permission-denied opens, subsequent refreshes took 304–321 ms here versus 1–5 ms on main. A 100 ms timer then starts the next pass immediately. Please keep healthy workers observable and allow inaccessible files to recover without reopening every persistently denied file on every poll. In a separate transient descriptor test, later workers really were readable in that same poll.
Both Ubuntu shard-6 jobs subsequently recorded the new warning-recovery test as their first failure. It timed out after 30 seconds in each run, and both jobs hit their 20-minute limit. I could reproduce the same stalled test by returning B before A locally. Source CI · PR edit CI
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 533228b644
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc97e1e3df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 247deae601
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58187c6819
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69d44a7209
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Summary
The broader worker-log recovery proposal in the earlier revisions of this PR was superseded by #970. That change preserves healthy worker observations when opening another rollout fails with a permission error.
One independent case remains. When opening or reading an unidentified rollout returns
EIO, the SDK stops reporting healthy sibling workers for that poll. This follow-up uses the same per-file handling as #970 so healthy workers can deliver progress and session events. The poll still reports the I/O failure and withholds incomplete costs. Scans with a spending cap still stop when their usage cannot be accounted for.Verification
openandreadfailures using a public SDK scan and synthetic local rollout files. After the fix, the healthy sibling delivered all four expected observations. Both capped runs stopped, and no partial cost was emitted.EIOduringstatstill stops the traversal immediately.