Skip to content

Status display shows 200k context instead of 1M when context1m is enabled #26627

@hershey-g

Description

@hershey-g

Bug

When context1m: true is set in model params (e.g. agents.defaults.models["anthropic/claude-opus-4-6"].params.context1m), the /status command still displays Context: 17k/200k instead of Context: 17k/1024k.

Root Cause

In the reply pipeline, context tokens are resolved at the model selection stage using:

agentCfg?.contextTokens ?? lookupContextTokens(model) ?? DEFAULT_CONTEXT_TOKENS

This code path does not check for context1m in the configured model params. It falls back to lookupContextTokens() which returns the model catalog default (200k for Opus/Sonnet 4).

The proper context1m check exists in resolveContextTokensForModel(), but it never gets reached because:

  1. The initial resolution returns 200k
  2. That value gets passed as contextTokensOverride into buildStatusMessage
  3. resolveContextTokensForModel short-circuits on a positive contextTokensOverride

Affected

  • /status display shows wrong context window
  • All agents, all channels
  • Actual API calls correctly use 1M (the beta header is applied correctly)

Workaround

Set contextTokens: 1048576 explicitly in agents.defaults. This overrides the catalog lookup.

Suggested Fix

The context token resolution in the model selection stage should also check context1m:

// Before (broken):
agentCfg?.contextTokens ?? lookupContextTokens(model) ?? DEFAULT_CONTEXT_TOKENS

// After (fixed):
agentCfg?.contextTokens ?? resolveContextTokensForModel({ cfg, provider, model, fallbackContextTokens: DEFAULT_CONTEXT_TOKENS }) ?? DEFAULT_CONTEXT_TOKENS

Or equivalently, add the context1m check inline at that resolution point.

Environment

  • OpenClaw 2026.2.23 (b817600)
  • Model: anthropic/claude-opus-4-6 with context1m: true

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