Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions crates/jcode-provider-core/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ pub fn context_limit_for_model_with_provider_and_cache(
return Some(1_000_000);
}

// DeepSeek's current generation (deepseek-v4 / deepseek-v4-flash and the
// deepseek-coder variants) advertises a 1M-token context window via the
// platform's published rate-limit metadata. Older models also accept up to
// 1M tokens through the same /v1/chat/completions endpoint, so it's safe
// to advertise as a default fallback. Cached/online catalog hits still
// override this via the cached_context_limit hook above.
if model.starts_with("deepseek") {
return Some(1_000_000);
}

None
}

Expand Down Expand Up @@ -257,6 +267,35 @@ mod tests {
);
}

#[test]
fn context_limit_falls_back_to_1m_for_deepseek_models() {
// Regression for issue #87: DeepSeek's current generation advertises a
// 1M-token context window. Without an explicit branch the function
// returned `None` and downstream callers had to either hard-code a
// smaller default or wait for a /models cache fill before showing
// accurate usage bars.
assert_eq!(
context_limit_for_model_with_provider("deepseek-v4", None),
Some(1_000_000)
);
assert_eq!(
context_limit_for_model_with_provider("deepseek-v4-flash", None),
Some(1_000_000)
);
assert_eq!(
context_limit_for_model_with_provider("deepseek-chat", None),
Some(1_000_000)
);
// Cached values must still take precedence so OAuth/online catalog
// hits can override the static fallback.
assert_eq!(
context_limit_for_model_with_provider_and_cache("deepseek-v4", None, |m| (m
== "deepseek-v4")
.then_some(64_000)),
Some(64_000)
);
}

#[test]
fn context_limit_uses_cache_for_unknown_models() {
assert_eq!(
Expand Down