fix(ai): harden MiniMax reasoning and tool replay
This commit is contained in:
1 parent
e4bd07c535
commit
e8fae013bd
2 files changed
+828
-101
No files matched your search
@@ -1020,6 +1020,12 @@ fn context_window_for_model(model: &str) -> u32 {
|
||||
if m.contains("gpt-4.1") {
|
||||
return 1_000_000;
|
||||
}
|
||||
if m.contains("minimax-m3") {
|
||||
return 1_000_000;
|
||||
}
|
||||
if m.contains("minimax-m2") {
|
||||
return 204_800;
|
||||
}
|
||||
if m.contains("claude") || m.contains("o1") || m.starts_with("o3") || m.starts_with("o4") {
|
||||
200_000
|
||||
} else if m.contains("gpt-4") {
|
||||
@@ -1031,6 +1037,10 @@ fn context_window_for_model(model: &str) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
fn effective_context_window(config: &AiConfig) -> u32 {
|
||||
config.context_window.unwrap_or_else(|| context_window_for_model(&config.model))
|
||||
}
|
||||
|
||||
fn prompt_budget(window: u32, max_tokens: Option<u32>) -> u32 {
|
||||
let output_reserve = max_tokens.unwrap_or(4096).min(window / 2);
|
||||
let safety_reserve = (window / 10).clamp(2048, 16_384).min(window / 2);
|
||||
@@ -1061,7 +1071,7 @@ async fn maybe_compact(
|
||||
cancelled: &Notify,
|
||||
force: bool,
|
||||
) -> CompactResult {
|
||||
let window = config.context_window.unwrap_or_else(|| context_window_for_model(&config.model));
|
||||
let window = effective_context_window(config);
|
||||
let budget = prompt_budget(window, max_tokens);
|
||||
let estimated_before = estimate_current_prompt_tokens(system_prompt, tools, messages);
|
||||
|
||||
@@ -1353,6 +1363,27 @@ mod tests {
|
||||
assert_eq!(clamp_max_agent_turns(u32::MAX), MAX_MAX_AGENT_TURNS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn minimax_context_windows_follow_official_model_families() {
|
||||
assert_eq!(context_window_for_model("MiniMax-M3"), 1_000_000);
|
||||
assert_eq!(context_window_for_model("vendor/MiniMax-M3.1"), 1_000_000);
|
||||
assert_eq!(context_window_for_model("MiniMax-M2.7"), 204_800);
|
||||
assert_eq!(context_window_for_model("MiniMax-M2.5-highspeed"), 204_800);
|
||||
assert_eq!(context_window_for_model("MiniMax-future"), 128_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_context_window_overrides_minimax_family_default() {
|
||||
let config: AiConfig = serde_json::from_value(serde_json::json!({
|
||||
"provider": "minimax",
|
||||
"model": "MiniMax-M3",
|
||||
"contextWindow": 65_536
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(effective_context_window(&config), 65_536);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identifies_explicit_tool_rejection_errors() {
|
||||
for error in [
|
||||
|
||||
+796
-100
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user