wip: checkpoint 2026-03-29 runtime work
This commit is contained in:
26
third_party/zeroclaw/src/providers/compatible.rs
vendored
26
third_party/zeroclaw/src/providers/compatible.rs
vendored
@@ -229,6 +229,18 @@ impl OpenAiCompatibleProvider {
|
||||
self
|
||||
}
|
||||
|
||||
fn tool_choice_for_tools(&self, has_tools: bool) -> Option<String> {
|
||||
if !has_tools {
|
||||
return None;
|
||||
}
|
||||
|
||||
crate::agent::loop_::TOOL_CHOICE_OVERRIDE
|
||||
.try_with(Clone::clone)
|
||||
.ok()
|
||||
.flatten()
|
||||
.or_else(|| Some("auto".to_string()))
|
||||
}
|
||||
|
||||
/// Collect all `system` role messages, concatenate their content,
|
||||
/// and prepend to the first `user` message. Drop all system messages.
|
||||
/// Used for providers (e.g. MiniMax) that reject `role: system`.
|
||||
@@ -1829,11 +1841,7 @@ impl Provider for OpenAiCompatibleProvider {
|
||||
} else {
|
||||
Some(tools.to_vec())
|
||||
},
|
||||
tool_choice: if tools.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some("auto".to_string())
|
||||
},
|
||||
tool_choice: self.tool_choice_for_tools(!tools.is_empty()),
|
||||
max_tokens: self.max_tokens,
|
||||
};
|
||||
|
||||
@@ -1933,7 +1941,9 @@ impl Provider for OpenAiCompatibleProvider {
|
||||
reasoning_effort: self.reasoning_effort_for_model(model),
|
||||
tool_stream: self
|
||||
.tool_stream_for_tools(tools.as_ref().is_some_and(|tools| !tools.is_empty())),
|
||||
tool_choice: tools.as_ref().map(|_| "auto".to_string()),
|
||||
tool_choice: self.tool_choice_for_tools(
|
||||
tools.as_ref().is_some_and(|tools| !tools.is_empty()),
|
||||
),
|
||||
tools,
|
||||
max_tokens: self.max_tokens,
|
||||
};
|
||||
@@ -2087,7 +2097,9 @@ impl Provider for OpenAiCompatibleProvider {
|
||||
tool_stream: if options.enabled { Some(true) } else { None },
|
||||
stream: Some(options.enabled),
|
||||
tools: tools.clone(),
|
||||
tool_choice: tools.as_ref().map(|_| "auto".to_string()),
|
||||
tool_choice: self.tool_choice_for_tools(
|
||||
tools.as_ref().is_some_and(|tools| !tools.is_empty()),
|
||||
),
|
||||
max_tokens: self.max_tokens,
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user