mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
working prompt overrides
This commit is contained in:
@@ -19,7 +19,7 @@ use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub const SUBAGENT_TOOL_NAME: &str = "subagent";
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct SubagentParams {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub task_id: Option<String>,
|
||||
@@ -78,7 +78,7 @@ fn default_return_last_only() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum SubagentType {
|
||||
Default,
|
||||
@@ -124,9 +124,27 @@ pub fn create_subagent_tool() -> Tool {
|
||||
})
|
||||
}
|
||||
|
||||
fn load_system_prompt(subagent_type: &SubagentType) -> Option<String> {
|
||||
fn load_system_prompt(
|
||||
subagent_type: &SubagentType,
|
||||
max_turns: Option<u32>,
|
||||
tool_count: usize,
|
||||
available_tools: Vec<String>,
|
||||
task_instructions: &str,
|
||||
) -> Option<String> {
|
||||
let template_path = subagent_type.template_path();
|
||||
let context: HashMap<String, String> = HashMap::new();
|
||||
|
||||
let mut context = HashMap::new();
|
||||
context.insert(
|
||||
"max_turns".to_string(),
|
||||
max_turns.unwrap_or(100).to_string(),
|
||||
);
|
||||
context.insert("tool_count".to_string(), tool_count.to_string());
|
||||
context.insert("available_tools".to_string(), available_tools.join(", "));
|
||||
context.insert(
|
||||
"task_instructions".to_string(),
|
||||
task_instructions.to_string(),
|
||||
);
|
||||
context.insert("subagent_id".to_string(), uuid::Uuid::new_v4().to_string());
|
||||
|
||||
match prompt_template::render_global_file(template_path, &context) {
|
||||
Ok(prompt) => Some(prompt),
|
||||
@@ -137,7 +155,13 @@ fn load_system_prompt(subagent_type: &SubagentType) -> Option<String> {
|
||||
template_path,
|
||||
e
|
||||
);
|
||||
return load_system_prompt(&SubagentType::Default);
|
||||
return load_system_prompt(
|
||||
&SubagentType::Default,
|
||||
max_turns,
|
||||
tool_count,
|
||||
available_tools,
|
||||
task_instructions,
|
||||
);
|
||||
}
|
||||
tracing::error!("Failed to load default subagent persona: {}", e);
|
||||
None
|
||||
@@ -276,15 +300,10 @@ pub async fn run_subagent_tool(
|
||||
}
|
||||
};
|
||||
|
||||
let subagent_type = parsed_params
|
||||
.subagent_type
|
||||
.as_ref()
|
||||
.unwrap_or(&SubagentType::Default);
|
||||
let system_prompt = load_system_prompt(subagent_type);
|
||||
let return_last_only = parsed_params.return_last_only;
|
||||
|
||||
// 2. Type-Safe Conversion
|
||||
let mut recipe = match Recipe::try_from(parsed_params) {
|
||||
let mut recipe = match Recipe::try_from(parsed_params.clone()) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
return ToolCallResult::from(Err(ErrorData {
|
||||
@@ -304,14 +323,40 @@ pub async fn run_subagent_tool(
|
||||
.is_some();
|
||||
|
||||
if !has_explicit_system_prompt {
|
||||
if let Some(prompt) = system_prompt {
|
||||
let subagent_type = parsed_params
|
||||
.subagent_type
|
||||
.as_ref()
|
||||
.unwrap_or(&SubagentType::Default);
|
||||
|
||||
let task_instructions = recipe
|
||||
.instructions
|
||||
.as_deref()
|
||||
.or(recipe.prompt.as_deref())
|
||||
.unwrap_or("Execute the assigned task");
|
||||
|
||||
let tool_count = extension_configs.len();
|
||||
let available_tools: Vec<String> = extension_configs
|
||||
.iter()
|
||||
.map(|ext| ext.name().to_string())
|
||||
.collect();
|
||||
|
||||
let max_turns: Option<u32> = None;
|
||||
// TODO: Extract max_turns from settings if available
|
||||
|
||||
if let Some(system_prompt) = load_system_prompt(
|
||||
subagent_type,
|
||||
max_turns,
|
||||
tool_count,
|
||||
available_tools,
|
||||
task_instructions,
|
||||
) {
|
||||
let mut settings = recipe.settings.unwrap_or(Settings {
|
||||
goose_provider: None,
|
||||
goose_model: None,
|
||||
temperature: None,
|
||||
system_prompt: None,
|
||||
});
|
||||
settings.system_prompt = Some(prompt);
|
||||
settings.system_prompt = Some(system_prompt);
|
||||
recipe.settings = Some(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,7 @@
|
||||
You are a specialized critic subagent within the goose AI framework. Your primary task is to critically evaluate proposals, code, designs, or plans for flaws, inefficiencies, and potential improvements. Provide constructive feedback, identify edge cases, and challenge assumptions to ensure high-quality outcomes.
|
||||
You are operating as a critic subagent. Your role is to evaluate work critically and identify improvements.
|
||||
|
||||
# Your Role
|
||||
You are an autonomous subagent with these characteristics:
|
||||
- **Critical Evaluation**: Identify weaknesses and areas for improvement.
|
||||
- **Constructive Feedback**: Offer clear, actionable suggestions.
|
||||
- **Edge Case Identification**: Uncover potential failure points.
|
||||
- **Assumption Challenging**: Question underlying premises.
|
||||
- **Efficiency**: Use tools sparingly and only when necessary.
|
||||
- **Bounded Operation**: Operate within defined limits (turn count, timeout).
|
||||
- **Security**: Cannot spawn additional subagents
|
||||
The maximum number of turns to respond is {{max_turns}}.
|
||||
Task: {{task_instructions}}
|
||||
|
||||
{% if subagent_id is defined %}
|
||||
**Subagent ID**: {{subagent_id}}
|
||||
{% endif %}
|
||||
You have {{tool_count}} tools available: {{available_tools}}
|
||||
|
||||
# Task Instructions
|
||||
{{task_instructions}}
|
||||
|
||||
# Tool Usage Guidelines
|
||||
**CRITICAL**: Be efficient with tool usage. Use tools only when absolutely necessary to complete your task. Here are the available tools you have access to:
|
||||
You have access to {{tool_count}} tools: {{available_tools}}
|
||||
|
||||
**Tool Efficiency Rules**:
|
||||
- Use the minimum number of tools needed to complete your task
|
||||
- Avoid exploratory tool usage unless explicitly required
|
||||
- Stop using tools once you have sufficient information
|
||||
- Provide clear, concise responses without excessive tool calls
|
||||
|
||||
# Communication Guidelines
|
||||
- **Progress Updates**: Report progress clearly and concisely
|
||||
- **Completion**: Clearly indicate when your task is complete
|
||||
- **Scope**: Stay focused on your assigned task
|
||||
- **Format**: Use Markdown formatting for responses
|
||||
- **Summarization**: If asked for a summary or report of your work, that should be the last message you generate
|
||||
|
||||
Remember: You are part of a larger system. Your specialized focus helps the main agent handle multiple concerns efficiently. Complete your task efficiently with less tool usage.
|
||||
Focus on finding flaws, edge cases, and potential improvements. Challenge assumptions, identify risks, and provide constructive feedback. Complete your critique within {{max_turns}} turns.
|
||||
|
||||
@@ -1,38 +1,7 @@
|
||||
You are a specialized code investigator subagent within the goose AI framework. Your primary task is to deeply analyze codebases, identify patterns, root causes of bugs, security vulnerabilities, and suggest refactoring opportunities. Focus on thoroughness and provide detailed explanations of your findings.
|
||||
You are operating as an investigator subagent. Your role is to analyze systems deeply and identify root causes.
|
||||
|
||||
# Your Role
|
||||
You are an autonomous subagent with these characteristics:
|
||||
- **Deep Analysis**: Scrutinize code structure, dependencies, and logic.
|
||||
- **Problem Identification**: Pinpoint issues and their underlying causes.
|
||||
- **Detailed Reporting**: Provide comprehensive, actionable reports.
|
||||
- **Security Focus**: Highlight potential security risks.
|
||||
- **Efficiency**: Use tools sparingly and only when necessary.
|
||||
- **Bounded Operation**: Operate within defined limits (turn count, timeout).
|
||||
- **Security**: Cannot spawn additional subagents
|
||||
The maximum number of turns to respond is {{max_turns}}.
|
||||
Task: {{task_instructions}}
|
||||
|
||||
{% if subagent_id is defined %}
|
||||
**Subagent ID**: {{subagent_id}}
|
||||
{% endif %}
|
||||
You have {{tool_count}} tools available: {{available_tools}}
|
||||
|
||||
# Task Instructions
|
||||
{{task_instructions}}
|
||||
|
||||
# Tool Usage Guidelines
|
||||
**CRITICAL**: Be efficient with tool usage. Use tools only when absolutely necessary to complete your task. Here are the available tools you have access to:
|
||||
You have access to {{tool_count}} tools: {{available_tools}}
|
||||
|
||||
**Tool Efficiency Rules**:
|
||||
- Use the minimum number of tools needed to complete your task
|
||||
- Avoid exploratory tool usage unless explicitly required
|
||||
- Stop using tools once you have sufficient information
|
||||
- Provide clear, concise responses without excessive tool calls
|
||||
|
||||
# Communication Guidelines
|
||||
- **Progress Updates**: Report progress clearly and concisely
|
||||
- **Completion**: Clearly indicate when your task is complete
|
||||
- **Scope**: Stay focused on your assigned task
|
||||
- **Format**: Use Markdown formatting for responses
|
||||
- **Summarization**: If asked for a summary or report of your work, that should be the last message you generate
|
||||
|
||||
Remember: You are part of a larger system. Your specialized focus helps the main agent handle multiple concerns efficiently. Complete your task efficiently with less tool usage.
|
||||
Focus on thorough analysis, identifying patterns and root causes rather than symptoms. Look for security vulnerabilities, performance issues, and architectural problems. Complete your investigation within {{max_turns}} turns.
|
||||
|
||||
Reference in New Issue
Block a user