Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

language_models: Fix GitHub Copilot thread summary by removing unnecessary noop tool logic (#37152)

Umesh Yadav0a32aa8db1c4
diff --git a/crates/language_models/src/provider/copilot_chat.rs b/crates/language_models/src/provider/copilot_chat.rs
index eb12c0056f8..d48c12aa4b5 100644
--- a/crates/language_models/src/provider/copilot_chat.rs
+++ b/crates/language_models/src/provider/copilot_chat.rs
@@ -475,7 +475,6 @@ fn into_copilot_chat(
}
}
- let mut tool_called = false;
let mut messages: Vec<ChatMessage> = Vec::new();
for message in request_messages {
match message.role {
@@ -545,7 +544,6 @@ fn into_copilot_chat(
let mut tool_calls = Vec::new();
for content in &message.content {
if let MessageContent::ToolUse(tool_use) = content {
- tool_called = true;
tool_calls.push(ToolCall {
id: tool_use.id.to_string(),
content: copilot::copilot_chat::ToolCallContent::Function {
@@ -590,7 +588,7 @@ fn into_copilot_chat(
}
}
- let mut tools = request
+ let tools = request
.tools
.iter()
.map(|tool| Tool::Function {
@@ -602,22 +600,6 @@ fn into_copilot_chat(
})
.collect::<Vec<_>>();
- // The API will return a Bad Request (with no error message) when tools
- // were used previously in the conversation but no tools are provided as
- // part of this request. Inserting a dummy tool seems to circumvent this
- // error.
- if tool_called && tools.is_empty() {
- tools.push(Tool::Function {
- function: copilot::copilot_chat::Function {
- name: "noop".to_string(),
- description: "No operation".to_string(),
- parameters: serde_json::json!({
- "type": "object"
- }),
- },
- });
- }
-
Ok(CopilotChatRequest {
intent: true,
n: 1,