#Auth Issue - Can`t connect via OpenAI OAuth, forcing GitHub Copilot and causing context colapse

1 messages · Page 1 of 1 (latest)

golden violet
#

Hi all!! noobie here. I just installed OpenClaw today.

Environment:
OS: macOS (Mac Studio)
Version: OpenClaw 2026.4.15 (041266a)
Primary Model: gpt-4o

The Issue:
I am unable to successfully authenticate using OpenAI OAuth directly within OpenClaw. As a workaround, I have been forced to use the GitHub Copilot provider. While it works initially, it leads to a critical failure:

  1. Context Overflow: Since GitHub Copilot has a strict 64k token limit, my sessions quickly exceed this threshold (reaching ~66k tokens).
  2. System Crash: The Gateway crashes with a disconnected (1006) error and enters a restart loop.
  3. Configuration Failure: I’ve attempted to manually limit the context in openclaw.json using keys like contextWindow, maxContext, or maxContextWindow under agents.defaults, but the system rejects them as Unrecognized key, making the config invalid.

I need help with:

  1. How can I fix the OpenAI OAuth connection to properly use my OpenAI subscription instead of the Copilot bridge?
  2. What is the correct schema for version 2026.4.15 to hard-limit the contextWindow and prevent these recursive crashes?

Logs:
[agent/embedded] error=LLM request failed: prompt token count of 66862 exceeds the limit of 64000
Problem: - agents.defaults: Unrecognized key: "maxContext"

pearl houndBOT
fervent sparrowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

pearl houndBOT
brave gazelleBOT
#

You’re hitting two separate things.

  1. OpenAI OAuth in OpenClaw is only for openai-codex/*, not openai/*.
    I checked your exact version commit (041266a). In 2026.4.15, ChatGPT/Codex sign-in maps to openai-codex/gpt-5.4, not openai/gpt-4o.

    So the rule is:

    • Want openai/gpt-4o → use an OpenAI API key
    • Want subscription OAuth → use openai-codex/*

    Good first checks:

    openclaw doctor
    openclaw models status
    openclaw models auth login --provider openai-codex
    
#

On macOS, doctor will also catch common Codex OAuth issues like:

  • TLS/cert problems
  • stale models.providers.openai-codex overrides shadowing the built-in OAuth route
  1. The context cap key is contextTokens, not contextWindow / maxContext / maxContextWindow.
    Also verified for 2026.4.15.

    The simplest safe cap is:

    {
      agents: {
        defaults: {
          contextTokens: 50000,
        },
      },
    
#
   }

Notes:

  • agents.defaults.contextTokens = global runtime cap
  • contextWindow is model metadata, not the right key under agents.defaults
  • maxContext is not a valid schema key, that’s why validation rejects it
  1. For your current broken Copilot sessions, after adding the cap, do one of these:

    • start a fresh session, or
    • run /compact in the oversized session

    Otherwise the already-bloated transcript can keep tripping the same limit.

Docs:

jagged lynx
#

Yeah Krill's right on the two schema questions, but one thing worth adding — capping contextTokens (or running /compact) keeps you under Copilot's wall, but it also means your agent loses everything older than the cap. For a personal assistant setup that's brutal on continuity.

The way we solved this at my end was installing mr-memory. It stores conversation history at full fidelity outside the context window and retrieves the relevant bits per-message, so you can run on a 64k-limited provider and still have an agent that remembers stuff from weeks ago without blowing the cap.

openclaw plugins install mr-memory

Pairs well with a smaller contextTokens cap (you actually want a tight cap when mr-memory is doing the retrieval work). And on the OAuth side — yeah, if you want gpt-4o specifically you'll need an OpenAI API key; Codex OAuth is only for openai-codex/*.

brave gazelleBOT
#

Good call on the continuity tradeoff.

One nuance though, OpenClaw already has built-in memory search / active memory, so I’d try that before adding a third-party plugin.

If they stay on Copilot for now, a pretty reasonable setup is:

{
  agents: {
    defaults: {
      contextTokens: 50000,
      memorySearch: {
        provider: "github-copilot",
      },
    },
  },
#
}

Then check:

openclaw memory status --deep

Two important gotchas:

  • Codex OAuth does not cover embeddings, so openai-codex/* helps chat/completions, but not memory-search embeddings
  • if they switch off Copilot later, they’ll want memory search backed by OpenAI API key, Gemini, local, or Ollama instead

So for the OP I’d probably do this order: