fix: get tool def back to chat mode (#1538)
This commit is contained in:
@@ -326,21 +326,16 @@ impl Capabilities {
|
||||
pub async fn get_system_prompt(&self) -> String {
|
||||
let mut context: HashMap<&str, Value> = HashMap::new();
|
||||
|
||||
let config = Config::global();
|
||||
let goose_mode = config.get("GOOSE_MODE").unwrap_or("auto".to_string());
|
||||
// In chat mode, we don't need to have the extensions to confuse LLM and it can help save cost as well.
|
||||
if goose_mode != "chat" {
|
||||
let extensions_info: Vec<ExtensionInfo> = self
|
||||
.clients
|
||||
.keys()
|
||||
.map(|name| {
|
||||
let instructions = self.instructions.get(name).cloned().unwrap_or_default();
|
||||
let has_resources = self.resource_capable_extensions.contains(name);
|
||||
ExtensionInfo::new(name, &instructions, has_resources)
|
||||
})
|
||||
.collect();
|
||||
context.insert("extensions", serde_json::to_value(extensions_info).unwrap());
|
||||
}
|
||||
let extensions_info: Vec<ExtensionInfo> = self
|
||||
.clients
|
||||
.keys()
|
||||
.map(|name| {
|
||||
let instructions = self.instructions.get(name).cloned().unwrap_or_default();
|
||||
let has_resources = self.resource_capable_extensions.contains(name);
|
||||
ExtensionInfo::new(name, &instructions, has_resources)
|
||||
})
|
||||
.collect();
|
||||
context.insert("extensions", serde_json::to_value(extensions_info).unwrap());
|
||||
|
||||
let current_date_time = Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
|
||||
context.insert("current_date_time", Value::String(current_date_time));
|
||||
@@ -354,13 +349,26 @@ impl Capabilities {
|
||||
.expect("Prompt should render")
|
||||
};
|
||||
|
||||
if self.system_prompt_extensions.is_empty() {
|
||||
let mut system_prompt_extensions = self.system_prompt_extensions.clone();
|
||||
let config = Config::global();
|
||||
let goose_mode = config.get("GOOSE_MODE").unwrap_or("auto".to_string());
|
||||
if goose_mode == "chat" {
|
||||
system_prompt_extensions.push(
|
||||
"Right now you are in the chat only mode, no access to any tool use and system."
|
||||
.to_string(),
|
||||
);
|
||||
} else {
|
||||
system_prompt_extensions
|
||||
.push("Right now you are *NOT* in the chat only mode and have access to tool use and system.".to_string());
|
||||
}
|
||||
|
||||
if system_prompt_extensions.is_empty() {
|
||||
base_prompt
|
||||
} else {
|
||||
format!(
|
||||
"{}\n\n# Additional Instructions:\n\n{}",
|
||||
base_prompt,
|
||||
self.system_prompt_extensions.join("\n\n")
|
||||
system_prompt_extensions.join("\n\n")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,14 +206,6 @@ impl Agent for TruncateAgent {
|
||||
tools.push(list_resources_tool);
|
||||
}
|
||||
|
||||
if goose_mode == "chat" {
|
||||
tools.clear();
|
||||
capabilities.add_system_prompt_extension(
|
||||
"Right now you are in the chat only mode, no access to any tool use and system."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
let system_prompt = capabilities.get_system_prompt().await;
|
||||
|
||||
// Set the user_message field in the span instead of creating a new event
|
||||
@@ -323,7 +315,21 @@ impl Agent for TruncateAgent {
|
||||
},
|
||||
"chat" => {
|
||||
// Skip all tool calls in chat mode
|
||||
break;
|
||||
for request in &tool_requests {
|
||||
message_tool_response = message_tool_response.with_tool_response(
|
||||
request.id.clone(),
|
||||
Ok(vec![Content::text(
|
||||
"Let the user know the tool call was skipped in Goose chat mode. \
|
||||
DO NOT apologize for skipping the tool call. DO NOT say sorry. \
|
||||
Provide an explanation of what the tool call would do, structured as a \
|
||||
plan for the user. Again, DO NOT apologize. \
|
||||
**Example Plan:**\n \
|
||||
1. **Identify Task Scope** - Determine the purpose and expected outcome.\n \
|
||||
2. **Outline Steps** - Break down the steps.\n \
|
||||
If needed, adjust the explanation based on user preferences or questions."
|
||||
)]),
|
||||
);
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
if mode != "auto" {
|
||||
|
||||
Reference in New Issue
Block a user