Skip to content

Context window limit alternates between 128k and 272k for GPT-6 Luna #128

Open

Description

@miyabimm

What happened?

Bug description

The context-window limit in Pi Web intermittently switches between 128k and 272k within the same GPT-6 Luna session.

For example:

  • Incorrect: 145.9k / 128k (100%, red)
  • Expected: 145.9k / 272k (~54%)

Both Pi Code and Pi Web's /api/models endpoint correctly report a context window of 272,000 tokens.

Environment

  • Pi Web: @ygncode/pi-web@0.0.1-beta.38
  • Model: openai/gpt-6-luna
  • OS: WSL2 (Ubuntu on Windows)

Verification

Pi Code reports:

provider  model       context  max-out
openai    gpt-6-luna  272K     128K

Pi Web's /api/models endpoint returns:

{
  "provider": "openai",
  "id": "gpt-6-luna",
  "name": "GPT-6 Luna",
  "contextWindow": 272000
}

Suspected root cause

There appears to be an inconsistency between model display names and model IDs.

In chat-selectors.js, modelDisplayLabel() prefers model.name over model.id.

However, in context-usage.js, buildContextWindows() registers lookup keys using model.id, not model.name.

This produces different results:

const models = [{
  provider: "openai",
  id: "gpt-6-luna",
  name: "GPT-6 Luna",
  contextWindow: 272000
}];

const windows = buildContextWindows(models);

getModelContextLimit("GPT-6 Luna", "openai", windows);
// 128000 (incorrect)

getModelContextLimit("gpt-6-luna", "openai", windows);
// 272000 (correct)

The fallback logic does not explicitly recognize GPT-6 models and defaults to 128,000.

The model selector and worker-status polling can use different model labels, which may explain the intermittent switching.

Relevant source:

Relation to existing issue

This may be related to #110, fixed by #122.

However, #110 primarily addressed context-usage flickering caused by incomplete usage snapshots during streaming.

The issue reported here specifically concerns the context-window limit itself alternating between 128k and 272k.

Suggested fix

Use the canonical model ID rather than the display name when looking up context-window limits.

Alternatively, register both model IDs and display names as lookup keys.

A regression test for models whose display names differ from their IDs would also be helpful.

Thanks for maintaining Pi Web!

Steps to reproduce

Steps to reproduce

  1. Open a Pi Web session using GPT-6 Luna.
  2. Check the context-usage indicator.
  3. Observe that the displayed context-window limit sometimes switches between 128k and 272k.

The exact trigger for the switching has not yet been isolated.

pi-web version

v0.0.1-beta.38

OS & browser

WSL2 (Ubuntu on Windows)

Relevant logs

Privacy

  • I have not pasted private session content; logs and screenshots are scrubbed of sensitive data.

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions