Skip to content

Honor Codex OAuth contextTokens in native Codex harness #77858

@lilesjtu

Description

@lilesjtu

Summary

The native Codex route uses an openai/gpt-* model ref plus agents.defaults.agentRuntime.id: "codex", but the Codex OAuth/runtime context metadata and user overrides are exposed under the openai-codex provider.

That creates a confusing split for context configuration. A user can configure:

{
  models: {
    providers: {
      "openai-codex": {
        models: [
          {
            id: "gpt-5.5",
            contextWindow: 1050000,
            contextTokens: 1000000,
          },
        ],
      },
    },
  },
  agents: {
    defaults: {
      model: { primary: "openai/gpt-5.5" },
      agentRuntime: { id: "codex" },
    },
  },
}

but the native harness context calculation still resolves against provider openai, so it can keep the runtime model's default contextTokens value such as 272000. In practice, /status may show a larger configured/catalog window while agentMeta.contextTokens reports the smaller default runtime cap.

Expected behavior

For openai/gpt-* running through the codex harness, context-window resolution should use openai-codex as the context config provider. That lets models.providers.openai-codex.models[].contextTokens override the Codex runtime cap consistently for the actual run and for /status.

Impact

Users following the recommended native Codex route can otherwise see contradictory context numbers and have no obvious way to make their configured Codex OAuth context cap affect the actual run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions