Introduce a system prompt for the new assistant (#26536)

This should be less eager in terms of invoking tools. But we should keep
iterating on it as we add more tools.

Also, this disables the Lua interpreter by default (it can still be
enabled manually from the tools icon).

Release Notes:

- N/A

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
Antonio Scandurra 2025-03-12 14:48:53 +01:00 committed by GitHub
parent 47a89ad243
commit 6bcfc4014b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 2 deletions

View file

@ -0,0 +1,12 @@
You are an AI assistant integrated into a text editor. Your goal is to do one of the following two things:
1. Help users answer questions and perform tasks related to their codebase.
2. Answer general-purpose questions unrelated to their particular codebase.
It will be up to you to decide which of these you are doing based on what the user has told you. When unclear, ask clarifying questions to understand the user's intent before proceeding.
You should only perform actions that modify the users system if explicitly requested by the user:
- If the user asks a question about how to accomplish a task, provide guidance or information, and use read-only tools (e.g., search) to assist. You may suggest potential actions, but do not directly modify the users system without explicit instruction.
- If the user clearly requests that you perform an action, carry out the action directly without explaining why you are doing so.
Be concise and direct in your responses.

View file

@ -376,7 +376,13 @@ impl Thread {
_cx: &App, _cx: &App,
) -> LanguageModelRequest { ) -> LanguageModelRequest {
let mut request = LanguageModelRequest { let mut request = LanguageModelRequest {
messages: vec![], messages: vec![LanguageModelRequestMessage {
role: Role::System,
content: vec![MessageContent::Text(
include_str!("./system_prompt.md").to_string(),
)],
cache: true,
}],
tools: Vec::new(), tools: Vec::new(),
stop: Vec::new(), stop: Vec::new(),
temperature: None, temperature: None,

View file

@ -15,7 +15,6 @@ pub struct ToolWorkingSet {
state: Mutex<WorkingSetState>, state: Mutex<WorkingSetState>,
} }
#[derive(Default)]
struct WorkingSetState { struct WorkingSetState {
context_server_tools_by_id: HashMap<ToolId, Arc<dyn Tool>>, context_server_tools_by_id: HashMap<ToolId, Arc<dyn Tool>>,
context_server_tools_by_name: HashMap<String, Arc<dyn Tool>>, context_server_tools_by_name: HashMap<String, Arc<dyn Tool>>,
@ -24,6 +23,18 @@ struct WorkingSetState {
next_tool_id: ToolId, next_tool_id: ToolId,
} }
impl Default for WorkingSetState {
fn default() -> Self {
Self {
context_server_tools_by_id: Default::default(),
context_server_tools_by_name: Default::default(),
disabled_tools_by_source: Default::default(),
is_scripting_tool_disabled: true,
next_tool_id: Default::default(),
}
}
}
impl ToolWorkingSet { impl ToolWorkingSet {
pub fn tool(&self, name: &str, cx: &App) -> Option<Arc<dyn Tool>> { pub fn tool(&self, name: &str, cx: &App) -> Option<Arc<dyn Tool>> {
self.state self.state