Skip to content

fix(provider): default DeepSeek context limit to 1M tokens (#87)#181

Open
quangdang46 wants to merge 1 commit into
masterfrom
fix/deepseek-1m-context-fallback
Open

fix(provider): default DeepSeek context limit to 1M tokens (#87)#181
quangdang46 wants to merge 1 commit into
masterfrom
fix/deepseek-1m-context-fallback

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

DeepSeek's current generation (deepseek-v4 / deepseek-v4-flash and the deepseek-coder variants) advertises a 1M-token context window. context_limit_for_model_with_provider_and_cache in jcode-provider-core had no DeepSeek branch and returned None, making the usage overlay and compaction heuristics fall back to a smaller generic default until the dynamic /models cache happened to fill in.

This addresses issue #87: #87

Changes

  • crates/jcode-provider-core/src/models.rs: add a model.starts_with("deepseek") -> Some(1_000_000) branch right after the gemini one. Cached/online catalog hits continue to take precedence via the existing cached_context_limit hook.
  • Added context_limit_falls_back_to_1m_for_deepseek_models test covering deepseek-v4, deepseek-v4-flash, deepseek-chat, and the cache-precedence case.

Tests

$ cargo test -p jcode-provider-core context_limit
test result: ok. 4 passed; 0 failed

Notes / scope deviation from upstream

Upstream PR 1jehuang#102 also rewrites the OPENCODE_PROFILE / OPENCODE_GO_PROFILE setup_url from opencode.ai/docs/... to a jcode-docs URL. That hunk conflicts with issue #80 / upstream PR #91 (which also rewrites the same lines, with a different replacement URL). To keep this PR focused on a single concern, the opencode-setup-url change is intentionally NOT included here and will be ported separately for issue #80 with a fork-correct URL.

DeepSeek's current generation (deepseek-v4 / deepseek-v4-flash and the
deepseek-coder variants) advertises a 1M-token context window via its
published rate-limit metadata, but `context_limit_for_model_with_provider_and_cache`
in jcode-provider-core had no DeepSeek branch. Returning `None` made
the usage overlay and compaction heuristics fall back to a smaller
generic default until the dynamic /models cache happened to fill in.

Add an explicit branch returning `Some(1_000_000)` for any model id
starting with "deepseek". Cached/online catalog hits continue to take
precedence (see the cached_context_limit hook just above).

Test `context_limit_falls_back_to_1m_for_deepseek_models` covers
deepseek-v4, deepseek-v4-flash, deepseek-chat, and the cache-precedence
case.

Ports the `src/provider/models.rs` portion of upstream PR
1jehuang#102 (the opencode setup_url
hunk in the same upstream PR is NOT applied here — it conflicts with
issue #80 / upstream PR #91 and will be ported there with the right
fork-specific URL).
Closes #87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant