Skip to content

fix(onboard): custom provider context window vs compaction floor (#79428) - #79911

Merged
steipete merged 2 commits into
openclaw:mainfrom
Jefsky:fix/79428-custom-provider-context
May 10, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
Jefsky:fix/79428-custom-provider-context

Conversation

@Jefsky

@Jefsky Jefsky commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Raise the generated non-Azure Custom Provider context window above the default compaction reserve floor so fresh onboarding no longer creates a first-turn compaction loop.
  • Heal legacy wizard-generated 4000 token custom model entries during reconfiguration.
  • Preserve explicit valid small model limits such as 8192, so local/proxy setups are not silently expanded past their real capacity.

Fixes #79428

Verification

  • pnpm test src/commands/onboard-custom-config.test.ts — 1 file, 37 tests passed.
  • env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_ID pnpm check:changed — passed core/core-test/docs lanes.
  • git diff --check — clean.

Real behavior proof

Behavior or issue addressed: Non-Azure Custom Provider onboarding no longer writes a generated contextWindow below the default compaction reserve floor, and re-onboarding heals legacy wizard-generated 4000 token entries without overwriting explicit valid smaller model limits.

Real environment tested: macOS source checkout of this PR branch, Node/pnpm repo runtime, OpenClaw onboarding config helper loaded through tsx from src/commands/onboard-custom-config.ts.

Exact steps or command run after this patch: Ran the patched OpenClaw config path with pnpm exec tsx to create three custom-provider configs: fresh model, legacy 4000 model, and explicit 8192 model, then printed the resulting contextWindow values.

Evidence after fix: Actual terminal output from the patched branch:

{
  "fresh": 128000,
  "legacy4000": 128000,
  "explicit8192": 8192
}

Observed result after fix: Fresh non-Azure custom models now get 128000; legacy wizard-generated 4000 entries are raised to 128000; explicit valid 8192 entries remain 8192, proving the fix avoids the compaction deadlock without broad-clamping small real model limits.

What was not tested: Full Windows 11 DashScope/Qwen gateway chat round-trip was not run in this maintainer patch; the changed behavior is the deterministic onboarding config write/merge path exercised above and by the focused regression test.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR raises non-Azure custom-provider onboarding context-window defaults and merge clamping from the 4,000-token hard minimum to 32,768 tokens, with focused onboarding tests.

Reproducibility: yes. by source inspection: current main creates non-Azure custom-provider models with a 4,000-token contextWindow while the runtime compaction reserve floor defaults to 20,000 tokens. I did not run the Windows/DashScope live path in this read-only review.

Real behavior proof
Needs stronger real behavior proof before merge: The supplied proof is a placeholder-style terminal narrative rather than actual after-fix output; please add redacted terminal output, logs, a terminal screenshot, or a recording showing the patched contextWindow and first turn without the compaction loop. Redact private details such as API keys, phone numbers, IPs, non-public endpoints, and local private paths; updating the PR body should trigger a fresh ClawSweeper review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Contributor action is needed for real-behavior proof, and current failing checks need maintainer/contributor follow-up rather than an automated replacement PR.

Security
Cleared: The diff only changes onboarding config defaults and a colocated test, with no new dependencies, workflows, secret handling, package metadata, or code-execution surfaces.

Review details

Best possible solution:

Keep the narrow onboarding/default-healing fix direction, then merge only after concrete runtime proof and CI are clean or clearly unrelated.

Do we have a high-confidence way to reproduce the issue?

Yes, by source inspection: current main creates non-Azure custom-provider models with a 4,000-token contextWindow while the runtime compaction reserve floor defaults to 20,000 tokens. I did not run the Windows/DashScope live path in this read-only review.

Is this the best way to solve the issue?

Yes for the code direction: changing custom-provider onboarding/default healing is the narrow maintainable fix, and it avoids changing global compaction policy or adding DashScope-specific behavior. The merge path still needs real proof and CI cleanup.

What I checked:

  • Current main writes the unsafe onboarding default: On current main, non-Azure custom-provider onboarding sets DEFAULT_CONTEXT_WINDOW to CONTEXT_WINDOW_HARD_MIN_TOKENS and writes that value into new custom model entries. (src/commands/onboard-custom-config.ts:16, 60cb2325a1ce)
  • Hard minimum is 4,000 tokens: CONTEXT_WINDOW_HARD_MIN_TOKENS is 4,000, matching the low contextWindow reported in the linked bug. (src/agents/context-window-guard.ts:5, 60cb2325a1ce)
  • Compaction floor default is 20,000 tokens: The runtime compaction reserve floor defaults to 20,000 tokens, so a 4,000-token contextWindow is source-backed as unsafe for the reported first-turn compaction behavior. (src/agents/pi-settings.ts:8, 60cb2325a1ce)
  • PR raises the custom-provider floor: The PR exports CUSTOM_PROVIDER_DEFAULT_CONTEXT_WINDOW_TOKENS as 32,768 and clamps existing lower custom-model values to at least that value. (src/commands/onboard-custom-config.ts:21, 3e457f2f58e7)
  • Focused tests updated: The PR updates applyCustomApiConfig tests for new custom models, below-minimum existing models, and the exact hard-minimum case. (src/commands/onboard-custom-config.test.ts:107, 3e457f2f58e7)
  • Real proof remains too weak: The PR body describes a macOS real run, but the transcript uses placeholders such as an elided contextWindow inspection and does not show actual first-turn gateway or compaction-loop output after the patch. (3e457f2f58e7)

Likely related people:

  • @steipete: GitHub path history shows recent onboard-custom-config and context-window guard maintenance, including custom-model image inference and guard export refactors. (role: recent maintainer; confidence: high; commits: 056c8eb48836, 59162379627b, c6ceb3e7724e; files: src/commands/onboard-custom-config.ts, src/agents/context-window-guard.ts)
  • @openperf: Recent pi-settings history includes adjacent embedded provider-turn and compaction behavior work in the same runtime area implicated by the report. (role: adjacent runtime maintainer; confidence: medium; commits: cc8a8f1df1cd; files: src/agents/pi-settings.ts)
  • @BunsDev: Recent merged history changed dynamic context-window guard thresholds in src/agents/context-window-guard.ts, which is part of the context-budget side of this bug. (role: adjacent context-window owner; confidence: medium; commits: 13e917e2923c; files: src/agents/context-window-guard.ts)
  • @bradhallett: Recent merged history touched pi-settings for Pi auto-compaction behavior, overlapping the compaction side of this fix. (role: adjacent compaction maintainer; confidence: medium; commits: 0bdba47a3e89; files: src/agents/pi-settings.ts)

Remaining risk / open question:

  • The PR body’s real-behavior proof does not show actual redacted contextWindow output or first-turn runtime logs after the patch.
  • The current PR head has failing check runs that need to be fixed or shown unrelated before merge.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 60cb2325a1ce.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
Jefsky and others added 2 commits May 10, 2026 09:43
Raise default/effective Custom Provider contextWindow above the compaction
reserveTokensFloor default so new onboard flows do not infinite-compact.

Co-authored-by: Cursor <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
@steipete
steipete merged commit faa1c6f into openclaw:main May 10, 2026
125 of 133 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Local proof: pnpm test src/commands/onboard-custom-config.test.ts; env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_ID pnpm check:changed; git diff --check
  • PR head before merge: 7045159
  • Land commit: faa1c6f

Thanks @Jefsky!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Infinite compacting loop for Custom Providers due to undersized contextWindow default #1

2 participants