openclaw - ✅(Solved) Fix [Bug]: deepseek extension missing provider-policy-api.ts — contextWindow and cost default to wrong values [2 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#74245Fetched 2026-04-30 06:26:46
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
2
Timeline (top)
cross-referenced ×3referenced ×2closed ×1commented ×1

Deepseek models have no provider-policy-api.ts, so materializeRuntimeConfig fills contextWindow with DEFAULT_CONTEXT_TOKENS (200k) and cost with zeros. v4-flash/v4-pro should be 1M with correct cost like other providers.

Root Cause

Root cause: normalizeProviderConfigForConfigDefaults calls resolveBundledProviderPolicySurface("deepseek") which returns null because extensions/deepseek/ has no provider-policy-api.ts. Compare with extensions/anthropic/, extensions/google/, and extensions/openai/ which all have this file.

Fix Action

Fix / Workaround

Workaround: manually created extensions/deepseek/provider-policy-api.js with a normalizeConfig that fills contextWindow and cost from the provider catalog. Verified working — runtimeConfig now shows correct 1M contextWindow and non-zero cost for v4 models.

PR fix notes

PR #74256: Add deepseek provider-policy-api.ts

Description (problem / solution / changelog)

Summary

  • Problem: DeepSeek extension has no provider-policy-api.ts; config materialization fills missing contextWindow with 200k and cost with zeros for v4 models.
  • Why it matters: v4-flash/v4-pro support 1M context but get 200k, causing premature session compaction and zero-cost display.
  • What changed: Added extensions/deepseek/provider-policy-api.ts with normalizeConfig() filling contextWindow (1M for v4, 200k for reasoner) and cost.
  • What did NOT change: No changes to other extensions, config schema, or runtime logic.

Change Type

  • Bug fix

Scope

  • Integrations

Linked Issue/PR

  • Closes #74245
  • This PR fixes a bug or regression

Root Cause

  • Root cause: normalizeProviderConfigForConfigDefaults calls resolveBundledProviderPolicySurface("deepseek") which returns null because extensions/deepseek/ has no provider-policy-api.ts. Then applyModelDefaults fills missing fields with DEFAULT_CONTEXT_TOKENS=200000 and DEFAULT_MODEL_COST=0.
  • Missing guardrail: No check that every provider extension ships provider-policy-api.ts. anthropic, google, openai all have one; deepseek was omitted.

Regression Test Plan

  • Unit test
  • Target: extensions/deepseek/provider-policy-api.test.ts
  • Scenario: After normalizeConfig, v4-flash has contextWindow=1000000 and non-zero cost.

User-visible / Behavior Changes

DeepSeek v4 models now show correct contextWindow (1M) and non-zero cost in runtimeConfig. Compaction uses full 1M window.

Diagram (if applicable)

For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write N/A.

Before: [SQLite sync] -> [openclaw.json: id/name/api only] -> [materialize] -> [cw=200k, cost=0]
After:  [SQLite sync] -> [openclaw.json: id/name/api only] -> [provider-policy normalizeConfig] -> [cw=1M, cost correct] -> [materialize]

Security Impact

All No.

Repro + Verification

  • OS: Windows 11, OpenClaw 2026.4.14
  • Model: deepseek/v4-pro, deepseek/v4-flash
  • Steps:
    1. Configure deepseek models in openclaw.json
    2. Restart OpenClaw
    3. gateway config get path=models.providers.deepseek.models
  • Expected: v4-flash: cw=1M, cost={1,2,0.02,0}; v4-pro: cw=1M, cost={3,6,0.025,0}; reasoner: cw=200k, cost={2,3,0.2,0}
  • Actual (before): All cw=200k, cost={0,0,0,0}

Human Verification

  • Verified: runtimeConfig correct for all 3 deepseek models after cold restart
  • Edge cases: Two cold restarts, values persist
  • Not verified: Other providers (no code changes to them)

Compatibility / Migration

All Yes/No/No. Backward compatible, no config or migration needed.

Risks and Mitigations

  • Risk: Hardcoded cost may go stale (v4-pro discount ends 2026/05/31)
    • Mitigation: Values match current pricing; future PR can read from catalog dynamically

Changed files

  • extensions/deepseek/provider-policy-api.ts (added, +69/-0)

PR #74326: fix(deepseek): add provider-policy-api to hydrate contextWindow and cost from catalog

Description (problem / solution / changelog)

Summary

DeepSeek models had no provider-policy-api.ts, so resolveBundledProviderPolicySurface("deepseek") returned null during config materialization. This caused applyModelDefaults to fill missing fields with generic defaults — 200k context window (instead of 1M for V4 models) and zero cost — leading to premature session compaction and incorrect cost tracking for all DeepSeek users.

Changes

Add a normalizeConfig provider-policy surface for the DeepSeek extension that hydrates missing contextWindow, maxTokens, and cost from the bundled DEEPSEEK_MODEL_CATALOG for matching model IDs. Explicit user overrides are preserved — the catalog values are only used as backfill when the configured model row is missing metadata.

This follows the same pattern used by other providers (anthropic, google, openai, deepinfra, ollama) that already ship a provider-policy-api.ts.

Fixes #74245

Changed files

  • extensions/deepseek/provider-policy-api.test.ts (added, +235/-0)
  • extensions/deepseek/provider-policy-api.ts (added, +97/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Deepseek models have no provider-policy-api.ts, so materializeRuntimeConfig fills contextWindow with DEFAULT_CONTEXT_TOKENS (200k) and cost with zeros. v4-flash/v4-pro should be 1M with correct cost like other providers.

Steps to reproduce

  1. Configure deepseek-v4-flash as a model provider in openclaw.json
  2. Restart OpenClaw
  3. Run gateway config get path=models.providers.deepseek.models
  4. Observe runtimeConfig shows contextWindow=200000 and cost={input:0, output:0, cacheRead:0, cacheWrite:0} for v4 models

Expected behavior

deepseek-v4-flash and deepseek-v4-pro should have contextWindow=1000000 and correct cost values (e.g. 1/2/0.02/0 for v4-flash) in runtimeConfig, matching their provider catalog definitions. deepseek-reasoner should have contextWindow=200000. This works correctly for anthropic, google, and openai models.

Actual behavior

All deepseek models show contextWindow=200000 (default) and cost={0,0,0,0} in runtimeConfig. This causes incorrect context window tracking and zero-cost display for v4-flash and v4-pro, which both support 1M context.

OpenClaw version

2026.4.14 (323493f)

Operating system

Windows 11

Install method

LobsterAI desktop app (bundled OpenClaw runtime)

Model

deepseek/deepseek-v4-pro, deepseek/deepseek-v4-flash

Provider / routing chain

openclaw -> deepseek (direct API)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: all deepseek v4 users Severity: Medium (incorrect context window causes premature compaction; costs display as $0) Frequency: 100% reproducible on every startup Consequence: Sessions compact ~125k instead of using full 1M window; cost tracking shows zero

Additional information

Root cause: normalizeProviderConfigForConfigDefaults calls resolveBundledProviderPolicySurface("deepseek") which returns null because extensions/deepseek/ has no provider-policy-api.ts. Compare with extensions/anthropic/, extensions/google/, and extensions/openai/ which all have this file.

Workaround: manually created extensions/deepseek/provider-policy-api.js with a normalizeConfig that fills contextWindow and cost from the provider catalog. Verified working — runtimeConfig now shows correct 1M contextWindow and non-zero cost for v4 models.

Fix should add provider-policy-api.ts to extensions/deepseek/ reading contextWindow and cost from the existing provider catalog.

extent analysis

TL;DR

Add a provider-policy-api.ts file to the extensions/deepseek/ directory to correctly configure the context window and cost for deepseek models.

Guidance

  • The issue is caused by the absence of a provider-policy-api.ts file in the extensions/deepseek/ directory, which is required to configure the context window and cost for deepseek models.
  • To verify the issue, check the runtimeConfig for deepseek models and confirm that the contextWindow is set to the default value of 200000 and the cost is set to zeros.
  • A temporary workaround is to manually create a provider-policy-api.js file in the extensions/deepseek/ directory with a normalizeConfig function that fills the contextWindow and cost from the provider catalog.
  • The fix should involve adding a provider-policy-api.ts file to the extensions/deepseek/ directory, which reads the contextWindow and cost from the existing provider catalog.

Example

// extensions/deepseek/provider-policy-api.ts
import { ProviderCatalog } from '../provider-catalog';

export function normalizeConfig(config: any) {
  const providerCatalog = ProviderCatalog.get('deepseek');
  config.contextWindow = providerCatalog.contextWindow;
  config.cost = providerCatalog.cost;
  return config;
}

Notes

The provided workaround has been verified to work, but a permanent fix should involve adding the provider-policy-api.ts file to the extensions/deepseek/ directory.

Recommendation

Apply the workaround by adding a provider-policy-api.ts file to the extensions/deepseek/ directory, as this has been verified to work and provides a correct configuration for deepseek models.

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…

FAQ

Expected behavior

deepseek-v4-flash and deepseek-v4-pro should have contextWindow=1000000 and correct cost values (e.g. 1/2/0.02/0 for v4-flash) in runtimeConfig, matching their provider catalog definitions. deepseek-reasoner should have contextWindow=200000. This works correctly for anthropic, google, and openai models.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING