Skip to content

A session event larger than 1 MiB aborts the scan, even after the scan work succeeded #291

Closed

Description

@robin-liquidium

Summary

ScanCostTracker throws when a single JSONL event in a Codex session rollout file exceeds 1 MiB. The throw propagates out of the cost tracker and aborts the entire scan — in my case after a deep scan had already completed its full discovery workflow, which meant hours of completed scan work never produced sealed artifacts.

Environment

  • @openai/codex-security 0.1.6 (verified still present in 0.1.7, tag npm-v0.1.7)
  • Linux x86_64, Docker (locally built image), Node 22
  • Deep scan of a large repository

Root cause

readSessionChunk in sdk/typescript/src/cost.ts:

const lineBytes = session.pendingLineBytes + fragment.length;
if (lineBytes > MAX_SESSION_EVENT_BYTES) {
  throw new Error("Codex session event exceeds the 1 MiB safety limit.");
}

The throw propagates through readSessionUsage → #readSessions, which rethrows for any session included in the scanned thread tree. A legitimate large event (mine was ~1.1 MB, e.g. a big tool output in the rollout) therefore kills the scan at any point — including after the deep workflow has finished but before the CLI writes the canonical draft artifacts.

The cost tracker is telemetry for progress/cost display. Aborting a completed multi-hour scan over an unparseable-for-telemetry event is a disproportionate failure mode.

Suggested fix

Skip (or quarantine) oversized events instead of throwing: discard the pending line, resume at the next newline, and count the skip. In practice the oversized lines are large tool outputs, not token_count events, so cost accounting is unaffected. This complements the quarantine approach discussed in #223/#224.

I have a minimal local patch along these lines (skip + discard flag for lines spanning read chunks) and can contribute it if useful.

Related

Activity

  1. createsomethingtoday commented on Aug 12, 2026

    @createsomethingtoday
    Contributor

    Release verification: the reported oversized-session-event abort is fixed in @openai/[email protected].

    • Published source tag npm-v0.1.10 resolves to bf0184d05c7dce5ce86bbb91adc47ecd776b656c and includes PR fix: remove session event limits and keep scans running #331 (cd23a23f25644728145301a56b97de11e8d732ed).
    • Against that released source, the focused reads session events larger than 16 MiB|handles a session-tracking failure cost/API test selection passed: 3 passed, 132 filtered, 0 failed.
    • pnpm run types also passed.

    I did not repeat a paid scan: the released source-level regression directly covers the event-size trigger, and the supporting cases cover non-fatal optional tracking failures.

    Would maintainers consider #291 ready to close? Broader unreadable-session quarantine and bounded telemetry work appears to belong with #224/#278 rather than this now-removed size abort.

  2. added
    bug
    on Aug 15, 2026
  3. mldangelo-oai commented on Aug 15, 2026

    @mldangelo-oai
    Collaborator

    Thanks for reporting this. #331 removed the 1 MiB session-event limit, and the current regression test accepts events larger than 16 MiB. The fix shipped in 0.1.10.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions