openclaw - ✅(Solved) Fix [Bug]: Onboard hardcodes contextWindow to 128k for all copilot-proxy/LiteLLM models, ignoring actual model capabilities [1 pull requests, 2 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#51055Fetched 2026-04-08 01:04:54
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×2cross-referenced ×1

Fix Action

Fix

PR #50968 addresses this by probing /v1/model/info during onboard and using discovered values.

PR fix notes

PR #51238: fix(onboard): use model-reported context window for LiteLLM

Description (problem / solution / changelog)

Summary

  • LiteLLM onboarding hardcoded contextWindow to 128k, overwriting the model-reported value on every re-onboard
  • Added resolveLitellmContextWindow() that prefers the existing model config value and only falls back to the 128k default when none is available

Change Type

  • Bug fix

Linked Issue

  • Closes #51055

Changed files

  • src/commands/onboard-auth.config-litellm.ts (modified, +29/-5)
RAW_BUFFERClick to expand / collapse

Bug Description

During onboard, the copilot-proxy and LiteLLM provider plugins hardcode contextWindow: 128000 and maxTokens: 8192 for all discovered models, regardless of the actual model capabilities reported by the proxy.

This causes premature context compaction for models with larger context windows. For example, claude-opus-4.6-1m routed through LiteLLM has a 1M token context window (max_input_tokens: 1000000 in LiteLLM config), but openclaw treats it as 128k, triggering history truncation at ~100k tokens and wasting ~87% of available capacity.

Steps to Reproduce

  1. Configure LiteLLM with a 1M context model (e.g. claude-opus-4.6-1m via GitHub Copilot)
  2. Run openclaw onboard and select copilot-proxy or LiteLLM provider
  3. Check openclaw.json — all models have contextWindow: 128000, maxTokens: 8192
  4. Run gateway — /status shows tokens ?/128k instead of tokens ?/1000k
  5. Long sessions hit premature compaction at ~100k tokens

Expected Behavior

Onboard should query the proxy's /v1/model/info endpoint (LiteLLM-compatible) to discover actual max_input_tokens and max_output_tokens per model, and use those values for contextWindow and maxTokens in the config. Fall back to 128k/8192 defaults only when the endpoint is unavailable.

Affected Code

  • extensions/copilot-proxy/index.tsbuildModelDefinition() hardcodes 128k/8192
  • src/commands/onboard-auth.config-litellm.tsLITELLM_DEFAULT_CONTEXT_WINDOW = 128_000

Environment

  • openclaw v2026.3.14
  • LiteLLM proxy with model_info.max_input_tokens: 1000000 configured
  • Windows 11 / macOS

Fix

PR #50968 addresses this by probing /v1/model/info during onboard and using discovered values.

extent analysis

Fix Plan

To fix the issue of premature context compaction due to hardcoded contextWindow and maxTokens values, follow these steps:

  • Modify the buildModelDefinition() function in extensions/copilot-proxy/index.ts to query the proxy's /v1/model/info endpoint for actual model capabilities.
  • Update src/commands/onboard-auth.config-litellm.ts to use the discovered values for contextWindow and maxTokens instead of hardcoded defaults.

Example code changes:

// extensions/copilot-proxy/index.ts
import axios from 'axios';

async function buildModelDefinition(model) {
  try {
    const response = await axios.get(`/v1/model/info`, { params: { model } });
    const modelInfo = response.data;
    return {
      contextWindow: modelInfo.max_input_tokens,
      maxTokens: modelInfo.max_output_tokens,
    };
  } catch (error) {
    // Fall back to default values if endpoint is unavailable
    return {
      contextWindow: 128000,
      maxTokens: 8192,
    };
  }
}
// src/commands/onboard-auth.config-litellm.ts
import { buildModelDefinition } from '../extensions/copilot-proxy/index';

const LITELLM_DEFAULT_CONTEXT_WINDOW = async (model) => {
  const modelDefinition = await buildModelDefinition(model);
  return modelDefinition.contextWindow;
};

Verification

To verify the fix, run the following steps:

  • Configure LiteLLM with a 1M context model (e.g., claude-opus-4.6-1m via GitHub Copilot).
  • Run openclaw onboard and select copilot-proxy or LiteLLM provider.
  • Check openclaw.json — all models should have the correct contextWindow and maxTokens values.
  • Run the gateway — /status should show the correct token capacity (e.g., tokens ?/1000k).

Extra Tips

  • Ensure the LiteLLM proxy is properly configured with the correct model_info.max_input_tokens value.
  • Test the fix with different models and context window sizes to ensure the solution is robust.

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