agent: Improve compatibility when using MCP servers with Gemini models (#28700)
WIP Release Notes: - agent: Improve compatibility when using MCPs with Gemini models
This commit is contained in:
parent
6c93d107c2
commit
2603f36737
27 changed files with 307 additions and 103 deletions
|
@ -844,13 +844,20 @@ impl Thread {
|
|||
if model.supports_tools() {
|
||||
request.tools = {
|
||||
let mut tools = Vec::new();
|
||||
tools.extend(self.tools().enabled_tools(cx).into_iter().map(|tool| {
|
||||
LanguageModelRequestTool {
|
||||
name: tool.name(),
|
||||
description: tool.description(),
|
||||
input_schema: tool.input_schema(model.tool_input_format()),
|
||||
}
|
||||
}));
|
||||
tools.extend(
|
||||
self.tools()
|
||||
.enabled_tools(cx)
|
||||
.into_iter()
|
||||
.filter_map(|tool| {
|
||||
// Skip tools that cannot be supported
|
||||
let input_schema = tool.input_schema(model.tool_input_format()).ok()?;
|
||||
Some(LanguageModelRequestTool {
|
||||
name: tool.name(),
|
||||
description: tool.description(),
|
||||
input_schema,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
tools
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue