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:
Dhanji R. Prasanna
2026-02-05 22:16:34 +11:00
parent d978032044
commit 3823f8b5f3
4 changed files with 22 additions and 131 deletions

View File

@@ -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.");
}
}

View File

@@ -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]