Skip to content

fix(cost): preserve healthy worker updates on rollout I/O errors - #2178

Merged
mldangelo-oai merged 31 commits into
openai:mainfrom
dipeshbabu:codex/fix-cost-poll-worker-isolation
Nov 4, 2026
Merged

mldangelo-oai merged 31 commits into
openai:mainfrom
dipeshbabu:codex/fix-cost-poll-worker-isolation

Conversation

@dipeshbabu

@dipeshbabu dipeshbabu commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Reproduced both open and read failures 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.
  • Extended the existing cost tests to cover uncapped and budget-capped scans and verify that an EIO during stat still stops the traversal immediately.
  • Ran the complete cost-tracking suite, strict TypeScript, Prettier, and the plugin source-compatibility checks.

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.
@github-actions github-actions Bot added the bug Something isn't working label Oct 31, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review

Check whether one unreadable worker log affects other workers, activity replay, or an explicit cost limit.

@mldangelo-oai
mldangelo-oai requested a balanced review from Copilot November 1, 2026 20:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T20:51:41.066231Z 8de63f0 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread sdk/typescript/src/cost.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

I’d keep the fix for #223 in #970 and hold this PR.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review

Please recheck the updated commit 02f8cc2137. Check whether one unreadable worker log affects other workers, activity replay, or an explicit cost limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A failed worker replay forwards queued activities before recovery resets deduplication state, causing the same messages or tool activities to be delivered twice to onActivity.

1 open issue

Review effort: Balanced

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 02f8cc2137

ℹ️ 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".

@dipeshbabu
dipeshbabu marked this pull request as draft November 1, 2026 21:05
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review

Please recheck the updated commit 9c3cb3b8d0. Check whether one unreadable worker log affects other workers, activity replay, or an explicit cost limit.

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread sdk/typescript/src/cost.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 9c3cb3b8d0

ℹ️ 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".

@dipeshbabu
dipeshbabu marked this pull request as ready for review November 1, 2026 21:25
@mldangelo-oai

Copy link
Copy Markdown
Collaborator

@codex review

Please recheck the updated commit 1abb35f30b. Please check delivery of healthy-worker activity and which error is reported when both a worker log and a later directory read fail, with and without an explicit budget.

@mldangelo-oai
mldangelo-oai requested a balanced review from Copilot November 1, 2026 21:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the SDK cost-tracking and read-failure handling changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@mldangelo-oai mldangelo-oai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread sdk/typescript/src/cost.ts Resolved
@mldangelo-oai mldangelo-oai changed the title fix(cost): preserve healthy worker observations and log diagnostics fix(cost): preserve healthy worker updates on rollout I/O errors Nov 4, 2026
@mldangelo-oai
mldangelo-oai merged commit 35ff82b into openai:main Nov 4, 2026
107 of 109 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants