openclaw - ✅(Solved) Fix Docs: contextTokens placement in agents.defaults.model doesn't match schema [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#68768Fetched 2026-04-19 15:07:52
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #68775: docs(providers): fix contextTokens placement for openai-codex

Description (problem / solution / changelog)

Summary

  • Problem: Docs show contextTokens override at models.providers.openai-codex.models[], but for OAuth-configured providers the gateway validator requires baseUrl and model name — fields that don't apply to auto-configured providers. Users following the docs hit a startup failure.
  • Why it matters: Anyone raising GPT-5.4 from the 272K default to its native 1.05M context window can't follow the documented path.
  • What changed: Added agents.defaults.contextTokens as the primary override path in openai.md, model-providers.md, and configuration-reference.md. Added missing bullet point for contextTokens in the config reference.
  • What did NOT change (scope boundary): No code changes. Per-model contextTokens in models.providers is still documented for custom (non-OAuth) providers.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • None
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: Docs only showed the models.providers path for overriding contextTokens. That path requires a complete provider entry (baseUrl, model name), which doesn't apply to OAuth-backed auto-configured providers like openai-codex.
  • Missing detection / guardrail: N/A (docs-only)
  • Contributing context: The working path (agents.defaults.contextTokens) was present in the config reference example but had no descriptive bullet point.

Regression Test Plan (if applicable)

N/A

User-visible / Behavior Changes

None — docs only.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Ubuntu 24.04
  • Runtime/container: OpenClaw 2026.4.15 (041266a)
  • Model/provider: openai-codex/gpt-5.4

Steps

  1. Follow current docs: add models.providers.openai-codex.models: [{ id: "gpt-5.4", contextTokens: 1050000 }]
  2. Restart gateway
  3. Gateway refuses to start: models.providers.openai-codex.baseUrl: Invalid input: expected string, received undefined

Expected

  • Docs should point to a path that works for OAuth providers

Actual

  • Docs-only path requires fields that OAuth providers don't use

Evidence

  • Trace/log snippets: direct config validation error reproduced locally against the documented partial provider shape

Human Verification (required)

  • Verified scenarios: Confirmed agents.defaults.contextTokens: 1050000 starts cleanly on 2026.4.15. Confirmed models.providers.openai-codex path fails without baseUrl/name.
  • Edge cases checked: Verified the per-provider path still works when a complete provider entry is supplied (custom non-OAuth providers).
  • What you did not verify: Whether the gateway team intends to relax validation for partial provider entries under models.mode: "merge".

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

None

AI Disclosure

  • Mark as AI-assisted in the PR title or description
  • Fully tested — confirmed both the failing and working config paths on OpenClaw 2026.4.15
  • I understand what the changes do
  • Codex review: N/A
  • Resolve or reply to bot review conversations after addressing them

Claude Code hit this wall face-first, tried three wrong config paths, and eventually found the one that works. This PR is the scar tissue.

Changed files

  • docs/concepts/model-providers.md (modified, +1/-1)
  • docs/gateway/configuration-reference.md (modified, +1/-0)
  • docs/providers/openai.md (modified, +6/-6)

Code Example

{
  agents: {
    defaults: {
      model: {
        primary: "anthropic/claude-opus-4-6",
        contextTokens: 200000
      }
    }
  }
}

---

{
  agents: {
    defaults: {
      model: {
        primary: "openai-codex/gpt-5.4",
        fallbacks: []
      },
      contextTokens: 1050000
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

The configuration reference at /gateway/configuration-reference documents contextTokens as a field inside agents.defaults.model:

{
  agents: {
    defaults: {
      model: {
        primary: "anthropic/claude-opus-4-6",
        contextTokens: 200000
      }
    }
  }
}

The gateway rejects this with agents.defaults.model: Invalid input on startup (tested on 2026.4.15).

Correct placement

contextTokens is accepted as a sibling to model at the agents.defaults level:

{
  agents: {
    defaults: {
      model: {
        primary: "openai-codex/gpt-5.4",
        fallbacks: []
      },
      contextTokens: 1050000
    }
  }
}

This starts cleanly with no config warnings.

Impact

Anyone following the docs to override the default runtime context cap (e.g. raising openai-codex/gpt-5.4 from the 272K default to its native 1.05M) will hit a startup failure and have to guess the correct placement.

Versions

  • OpenClaw 2026.4.15 (041266a)
  • Config schema validation rejects contextTokens inside model object

extent analysis

TL;DR

Move the contextTokens field to be a sibling of model inside the agents.defaults object to resolve the configuration error.

Guidance

  • Verify that the contextTokens field is correctly placed outside of the model object, as shown in the corrected example.
  • Check the configuration reference at /gateway/configuration-reference for any updates or corrections to the agents.defaults.model structure.
  • Test the configuration with the corrected placement of contextTokens to ensure a clean startup without warnings.
  • If issues persist, review the config schema validation rules to ensure they align with the expected structure.

Example

{
  agents: {
    defaults: {
      model: {
        primary: "openai-codex/gpt-5.4",
        fallbacks: []
      },
      contextTokens: 1050000
    }
  }
}

Notes

The provided solution assumes that the configuration reference will be updated to reflect the correct placement of contextTokens. Until then, users will need to manually correct their configurations to match the expected structure.

Recommendation

Apply workaround: Move the contextTokens field to be a sibling of model inside the agents.defaults object, as this resolves the immediate configuration error and allows for a clean startup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Docs: contextTokens placement in agents.defaults.model doesn't match schema [1 pull requests, 1 comments, 2 participants]