Skip to content

[Bug] OpenAI OAuth sessions show API context limits and silently stop at Codex capacity #298

@Astro-Han

Description

@Astro-Han

What happened?

OpenAI OAuth sessions can show misleading context capacity for GPT-5.5. PawWork displays openai/gpt-5.5 with API model limits from the local models cache: context: 1,050,000, input: 922,000, and output: 128,000. However, the OAuth plugin rewrites OpenAI requests to the ChatGPT Codex endpoint, where GPT-5.5 is documented as having a smaller Codex context window. In the attached exported session, the context indicator showed about 271,863 tokens used, which looks safe against the displayed 1.05M context limit, but the session then produced empty assistant turns with finish: "length".

The user-facing result is that PawWork looks like it has plenty of context left, then the conversation appears to interrupt or stall after reading an image. There is no explicit warning that the session hit a context or output budget boundary, and there is no recovery guidance such as compacting, starting a new session, or removing large media.

Steps to reproduce

  1. Sign in to OpenAI through the ChatGPT Pro/Plus OAuth path.
  2. Use openai/gpt-5.5 in a long PawWork session.
  3. Let the session reach roughly the 270K token range shown by the context indicator.
  4. Ask PawWork to read an image file, for example /Users/yuhan/Downloads/Pawwork-chrome-icon-imagegen-v2/imagegen-chrome-icons-worktree.png.
  5. Continue the conversation.
  6. Observe that the assistant message can finish with finish: "length", output: 0, and no visible user-facing explanation.

What did you expect to happen?

PawWork should use the effective model capacity for the actual request path. When the provider is OpenAI OAuth/Codex, the UI and compaction logic should not rely on the API model limit if the Codex endpoint has a smaller effective window. When a request returns finish: "length" with no visible output, PawWork should show a clear recovery message instead of silently ending the assistant turn.

PawWork version

local prod build, exported at 2026-04-28 12:36:50 UTC from pawwork-session-gentle-squid-2026-04-28-12-36-50.json

OS version

darwin 25.3.0, timezone Asia/Shanghai

Can you reproduce it again?

Only once so far

Screenshots, recordings, or extra context

Evidence from the exported session: runtime_context.model_refs resolved openai/gpt-5.5. The read tool completed successfully with an image/png attachment, size 731368 bytes. The next assistant message msg_dd41617760016HqB3C4feJZ6P0 had finish: "length", tokens.total: 271863, tokens.input: 2375, tokens.output: 0, tokens.reasoning: 176, and tokens.cache.read: 269312. A manual 继续 produced another assistant message msg_dd416dd6d001poAhnAfB75vA87 with finish: "length", output: 0, and no visible answer.

Code pointers: packages/opencode/src/plugin/codex.ts rewrites /v1/responses and /chat/completions requests to the Codex backend for OpenAI OAuth. packages/app/src/components/session/session-context-metrics.ts computes context usage from the latest assistant token usage and divides by model.limit.context. packages/opencode/src/session/overflow.ts uses model.limit.input ?? context for overflow and compaction thresholds. packages/opencode/src/session/prompt.ts exits the loop for non-tool-calls finishes, so finish: "length" can become a silent stop.

External reference: OpenAI API docs list gpt-5.5 with a 1,050,000 context window, but the GPT-5.5 release announcement says GPT-5.5 in Codex is available with a 400K context window. PawWork currently appears to use API metadata while sending OAuth requests through the Codex path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High prioritybugSomething isn't workingharnessModel harness, prompts, tool descriptions, and session mechanics

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions