Optimize native system prompt - 48% size reduction
Removed redundant and vague content from prompts/system/native.md: - Simplified intro from 17 lines to 3 lines - Reduced Code Search section to one line - Removed duplicate Plan Mode example (kept one) - Removed Action Envelope section (rarely used correctly) - Removed verbose Memory Format details (tool description covers it) - Removed Response Guidelines (obvious to modern LLMs) Size: 8,620 chars -> 4,498 chars Also updated: - G3_IDENTITY_LINE constant for agent mode compatibility - Test assertions to check for new prompt markers - System prompt validation to use new marker string
This commit is contained in:
@@ -438,12 +438,12 @@ impl<W: UiWriter> Agent<W> {
|
||||
|
||||
// Check for system prompt markers that are present in both standard and agent mode
|
||||
// Check for system prompt markers that are present in both native and non-native prompts
|
||||
// Both prompts contain "You have access to tools" as a common marker
|
||||
// Both prompts contain "Use tools to accomplish tasks" as a common marker
|
||||
let has_tool_instructions = first_message
|
||||
.content
|
||||
.contains("You have access to tools");
|
||||
.contains("Use tools to accomplish tasks");
|
||||
if !has_tool_instructions {
|
||||
panic!("FATAL: First system message does not contain the system prompt marker 'You have access to tools'. This likely means the README was added before the system prompt.");
|
||||
panic!("FATAL: First system message does not contain the system prompt marker 'Use tools to accomplish tasks'. This likely means the README was added before the system prompt.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ pub fn get_system_prompt_for_non_native_with_skills(skills: &[Skill]) -> String
|
||||
}
|
||||
|
||||
/// The G3 identity line that gets replaced in agent mode
|
||||
const G3_IDENTITY_LINE: &str = "You are G3, an AI programming agent of the same skill level as a seasoned engineer at a major technology company. You analyze given tasks and write code to achieve goals.";
|
||||
const G3_IDENTITY_LINE: &str = "You are G3, an AI programming agent.";
|
||||
|
||||
/// Generate a system prompt for agent mode by combining the agent's custom prompt
|
||||
/// with the full G3 system prompt (including plan tools, code search, webdriver, coding style, etc.)
|
||||
@@ -200,29 +200,29 @@ mod tests {
|
||||
#[test]
|
||||
fn test_native_prompt_contains_validation_string() {
|
||||
let prompt = get_system_prompt_for_native();
|
||||
assert!(prompt.contains("You have access to tools"),
|
||||
"Native prompt must contain validation string");
|
||||
assert!(prompt.contains("Use tools to accomplish tasks"),
|
||||
"Native prompt must contain tool usage instruction");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_native_prompt_contains_validation_string() {
|
||||
let prompt = get_system_prompt_for_non_native();
|
||||
assert!(prompt.contains("You have access to tools"),
|
||||
"Non-native prompt must contain validation string");
|
||||
assert!(prompt.contains("Use tools to accomplish tasks"),
|
||||
"Non-native prompt must contain tool usage instruction");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_native_prompt_contains_important_directive() {
|
||||
let prompt = get_system_prompt_for_native();
|
||||
assert!(prompt.contains("IMPORTANT: You must call tools to achieve goals"),
|
||||
"Native prompt must contain IMPORTANT directive");
|
||||
assert!(prompt.contains("# Task Management with Plan Mode"),
|
||||
"Native prompt must contain Plan Mode section");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_native_prompt_contains_important_directive() {
|
||||
let prompt = get_system_prompt_for_non_native();
|
||||
assert!(prompt.contains("IMPORTANT: You must call tools to achieve goals"),
|
||||
"Non-native prompt must contain IMPORTANT directive");
|
||||
assert!(prompt.contains("# Task Management with Plan Mode"),
|
||||
"Non-native prompt must contain Plan Mode section");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -40,7 +40,7 @@ async fn test_context_window_initial_structure() {
|
||||
|
||||
// First message should be system prompt
|
||||
let system_msg = &context.conversation_history[0];
|
||||
assert!(system_msg.content.contains("You have access to tools"),
|
||||
assert!(system_msg.content.contains("Use tools to accomplish tasks"),
|
||||
"First message should be system prompt with tool instructions");
|
||||
|
||||
// Second message should be README content
|
||||
@@ -285,7 +285,7 @@ async fn test_full_context_order() {
|
||||
|
||||
// Message 0: System prompt
|
||||
let system = &context.conversation_history[0].content;
|
||||
assert!(system.contains("You have access to tools"),
|
||||
assert!(system.contains("Use tools to accomplish tasks"),
|
||||
"Message 0 should be system prompt");
|
||||
|
||||
// Message 1: Combined content with project appended
|
||||
|
||||
Reference in New Issue
Block a user