Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions crates/goose/src/agents/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use tokio::sync::Mutex;
use tracing::{debug, instrument};

use super::extension::{ExtensionConfig, ExtensionError, ExtensionInfo, ExtensionResult};
use crate::config::Config;
use crate::prompt_template;
use crate::providers::base::{Provider, ProviderUsage};
use mcp_client::client::{ClientCapabilities, ClientInfo, McpClient, McpClientTrait};
Expand Down Expand Up @@ -325,19 +326,23 @@ impl Capabilities {
pub async fn get_system_prompt(&self) -> String {
let mut context: HashMap<&str, Value> = HashMap::new();

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();
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 current_date_time = Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();

context.insert("extensions", serde_json::to_value(extensions_info).unwrap());
context.insert("current_date_time", Value::String(current_date_time));

// Conditionally load the override prompt or the global system prompt
Expand Down
24 changes: 9 additions & 15 deletions crates/goose/src/agents/truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ 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
Expand Down Expand Up @@ -315,21 +323,7 @@ impl Agent for TruncateAgent {
},
"chat" => {
// Skip all tool calls in chat mode
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."
)]),
);
}
break;
},
_ => {
if mode != "auto" {
Expand Down
5 changes: 3 additions & 2 deletions crates/goose/src/prompts/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ You are a general-purpose AI agent called Goose, created by Block, the parent co

The current date is {{current_date_time}}.

Goose uses LLM providers with tool calling capability. You can be used with different language models (gpt-4o, claude-3.5-sonnet, o1, llama-3.2, deepseek-r1, etc).
Goose uses LLM providers with tool calling capability. You can be used with different language models (gpt-4o, claude-3.5-sonnet, o1, llama-3.2, deepseek-r1, etc).
These models have varying knowledge cut-off dates depending on when they were trained, but typically it's between 5-10 months prior to the current date.

{% if (extensions is defined) and extensions %}

# Extensions

Extensions allow other applications to provide context to Goose. Extensions connect Goose to different data sources and tools.
You are capable of dynamically plugging into new extensions and learning how to use them. You solve higher level problems using the tools in these extensions, and can interact with multiple at once.

{% if (extensions is defined) and extensions %}
Because you dynamically load extensions, your conversation history may refer
to interactions with extensions that are not currently active. The currently
active extensions are below. Each of these extensions provides tools that are
Expand Down
Loading