Skip to content

Avoid repeated cost-poll failures for unreadable session logs #223

Closed

Description

@rohanpoudel2

Summary

ScanCostTracker remembers some unreadable-session failures but does not mark a session when opening its file fails. An inaccessible session can therefore fail each subsequent poll, including before its thread ID is known and it can be filtered out as unrelated.

Current status

The current cost reader still rethrows non-missing-file open failures without setting the session's unreadable state. Optional cost-tracking isolation in #331 reduced the impact on unbudgeted callers, so the original claim that every otherwise successful unbudgeted scan becomes a failure is no longer accurate.

#970 is an open proposal for permission-denied session files. It does not cover every failure first encountered during the final refresh.

Deterministic reproduction

The original test used the exported ScanCostTracker with a synthetic session file made unreadable using chmod 000; no model request or credentials were needed. Equivalent permission-error injection can make the test independent of the executing user's privileges.

Relevant flow:

if (session.unreadable) return;
try {
  file = await open(path, "r");
} catch (error) {
  if (isMissingFile(error)) return;
  throw error; // no session state records this failure
}

An oversized event, by contrast, sets the unreadable flag before throwing. If opening fails before session_meta is read, the session has no thread ID, so the normal unrelated-thread filtering cannot classify it.

Remaining cases

  1. Repeated polling: a known unreadable file should not cause the same open failure on every poll.
  2. Budgeted scans: preserve explicit-budget behavior and clearly report unavailable accounting; do not silently claim complete usage or weaken the cost guard.
  3. Final refresh: stop(fallbackUsage) awaits refresh before using its fallback. A first failure at that point can still prevent the caller's available usage from being used as intended.

Regression coverage should distinguish optional tracking, explicit budgets, unrelated sessions, and a failure first appearing at finalization. Directory-enumeration permission errors have a related but separate lifecycle and were not part of the original file-level fix.

Activity

  1. added
    area:cost
    bug
    priority:p1
    on Aug 15, 2026
  2. mldangelo-oai commented on Aug 15, 2026

    @mldangelo-oai
    Collaborator

    #331 prevents optional tracking errors from aborting scans without an explicit budget. Unreadable sessions can still disrupt budgeted scans or repeatedly fail polling, so this remains open; #224 is the related fix.

  3. changed the title [-]An unreadable Codex session log fails every cost poll for the rest of the scan, and can fail a scan that succeeded[/-] [+]Avoid repeated cost-poll failures for unreadable session logs[/+] on Oct 19, 2026
  4. added
    priority:p2
    and removed
    priority:p1
    on Oct 19, 2026
  5. mldangelo-oai commented on Oct 25, 2026

    @mldangelo-oai
    Collaborator

    #977 stopped optional tracking from printing the same permission warning on every poll. Retrying the read is intentional: a worker log can become accessible later. On main, I could still get one unreadable log to suppress activity from healthy workers until access returned.

    #970 tackles repeated open failures. #1841 covers the separate final-refresh case, where some usage is already known; #465 covers verification when a budget was requested. A fix here needs to let healthy activity through without treating the missing usage as zero.

  6. mldangelo-oai commented on Nov 15, 2026

    @mldangelo-oai
    Collaborator

    I rechecked the case from the last comment. With one worker log unreadable, an uncapped scan still delivered both events from a healthy sibling. The first poll after access returned picked up the missing usage. Repeated polls produced one warning for the unreadable path.

    That covers the behavior we wanted from #970. Budgeted scans still treat missing usage as partial when checking the cap. Thanks for flagging this. Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:costbugpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions