fix: correct tool support detection in Tetrate provider model fetching (#6808)

Signed-off-by: Yelsin Sepulveda <yelsinsepulveda@gmail.com>
This commit is contained in:
Yelsin Sepulveda
2026-01-29 11:11:46 -05:00
committed by GitHub
parent ec789475d9
commit 58a1353bb0
+24 -12
View File
@@ -271,9 +271,13 @@ impl Provider for TetrateProvider {
// The response format from /v1/models is expected to be OpenAI-compatible
// It should have a "data" field with an array of model objects
let data = json.get("data").and_then(|v| v.as_array()).ok_or_else(|| {
ProviderError::UsageError("Missing data field in JSON response".into())
})?;
let data = match json.get("data").and_then(|v| v.as_array()) {
Some(data) => data,
None => {
tracing::warn!("Tetrate Agent Router Service API response missing 'data' field, falling back to manual model entry");
return Ok(None);
}
};
let mut models: Vec<String> = data
.iter()
@@ -283,18 +287,26 @@ impl Provider for TetrateProvider {
// Check if the model supports computer_use (which indicates tool/function support)
// The Tetrate API uses "supports_computer_use" instead of "supported_parameters"
let supports_computer_use = model
.get("supports_computer_use")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let supported_params =
match model.get("supported_parameters").and_then(|v| v.as_array()) {
Some(params) => params,
None => {
tracing::debug!(
"Model '{}' missing supported_parameters field, skipping",
id
);
return None;
}
};
if supports_computer_use {
let has_tool_support = supported_params
.iter()
.any(|param| param.as_str() == Some("tools"));
if has_tool_support {
Some(id.to_string())
} else {
tracing::debug!(
"Model '{}' does not support computer_use (tool support), skipping",
id
);
tracing::debug!("Model '{}' does not support tools, skipping", id);
None
}
})