Skip to content

Desktop: processed-media limit stops a tool-image turn below token compaction threshold. #54934

Open

Description

@aaaaaandrew

Environment

  • macOS, Apple Silicon.
  • Desktop-bundled native runtime: codex-cli 0.163.0-alpha.10.2.
  • Independently qualified standalone runtime: codex-cli 0.162.1.
  • Model in the observed failure: gpt-6.1-sol.
  • Third-party OpenAI-compatible Responses route through LiteLLM to Bedrock Runtime. This is not a reproduction against a first-party OpenAI endpoint.

Observed failure

An image-producing tool workflow failed after a successful compaction. The compacted context was approximately 24K estimated total tokens. Three subsequently produced JPEG screenshots, sent with detail: "original", accumulated before the next ordinary model request failed.

Each JPEG was approximately 3.2 MiB in encoded-file bytes (approximately 4.4 million Base64 data-URL characters). The last successful request used approximately 62K input tokens. The configured token compaction trigger was 240K, and successful requests observed elsewhere in this conversation remained below 233K input tokens.

The provider returned HTTP 400 with the following inner error, wrapped in a LiteLLM BadRequestError:

{
  "error": {
    "message": "media inputs total 61 MiB after processing (3 objects), above the 60 MiB this model accepts in one request; reduce the number or resolution of image inputs",
    "type": "invalid_request_error",
    "param": null,
    "code": "validation_error"
  }
}

The explicitly reported limit concerns media bytes after provider processing, not JPEG file bytes, Base64 wire bytes, or the token window. The error alone does not establish how that provider calculates the processed size. Compaction had succeeded; newly added tool images exhausted a separate budget.

Unpaid native-client qualification

A separate isolated loopback experiment used synthetic 1×1 PNGs, fake credentials, and each runtime's own model schema projected to the route's standard Responses/direct-tool compatibility configuration. The provider error was injected when three actual native view_image tool results were present. No private screenshots or history were used, and no paid inference calls were made.

Both runtimes produced the same outcomes:

Injected response Native outcome
Original JSON HTTP 400 envelope Ordinary turn failed with generic codexErrorInfo: "other"; no compaction occurred during that turn.
Equivalent size rejection normalized to HTTP 200 SSE response.failed, with response.error.code: "context_length_exceeded" Ordinary turn failed with contextWindowExceeded. Continuing the same thread triggered local compaction; its input shrank from three image objects to two, then ordinary sampling resumed with zero retained images.
Same normalized rejection for every recovery request, even after media was removed Local compaction reduced history to its irreducible input, then terminated with a failed turn. Recovery requests were bounded and did not resend identical history.

The successful normalized scenario used ten total inference requests, including five compaction attempts. The irreducible scenario used eleven total requests, including seven compaction attempts. These are synthetic lifecycle observations, not measurements of the live provider's media ceiling or evidence that every real oversized image set is recoverable.

This confirms an error-classification/recovery gap for the supplied provider response shape. It does not establish a failure in token compaction, a first-party service defect, or immediate same-turn recovery. A narrow proxy-side normalization is a workaround; it does not add native request-wide processed-media budgeting.

Expected behavior

  • Recognize explicit provider media-budget exhaustion independently of token-window exhaustion.
  • Provide a supported recovery path that can compact retained tool-image history without requiring an already oversized request to be replayed unchanged.
  • Preserve native image fidelity and coordinate-sensitive preprocessing; do not silently reduce image resolution to hide the error.
  • Clearly distinguish recoverable historical-media overflow from an irreducible current image set, and avoid retry loops.
  • Treat provider processed-media budgets separately from encoded request-size and token estimates.

Related open reports

Please consolidate if this belongs in an existing report.

Privacy and limits

Only reviewed technical versions, approximate structural measurements, a provider error excerpt, and synthetic qualification results are included. No private prompts, screenshots, source files, raw logs, local paths, credentials, account identifiers, repository links, or thread/turn IDs are attached. The original private image set is deliberately unavailable as a public reproducer. Billing was not audited.

Activity

  1. added
    bug
    app
    context
    custom-model
    aws-bedrock
    on Oct 17, 2026
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

    appaws-bedrockbugcontextcustom-model

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions