Skip to content

Conversation

@lifeizhou-ap
Copy link
Collaborator

@lifeizhou-ap lifeizhou-ap commented Jul 1, 2025

This PR is using goose command line to run task in subagent or sub-recipe.

What

  • Change to sub-recipe tool to only create sub recipe task instead of run sub-recipes.

  • Create sub_agent__execute_task tool to run a single task or multiple task in parallel

  • Task can be 2 types

    • Sub recipe task. This task is created by sub recipe create task tool function and the task has attributes:

      • name (recipe name)
      • recipe_path (recipe file path)
      • command_parameters (param name and value pairs to be passed to the goose run recipe command line)
        This task is executed as goose run --recipe recipe_file --params name=value
    • Sub agent task. This task is created by the main agent and has attributes. At the moment it only has text_instruction, I think later on it will have more attributes similar to recipe. I would like to discuss the use cases especially the model, tools (maybe some smart way to work out the tool and model based on the task?)

      • text_instruction
  • sub_agent__execute_task tool

    • it uses goose run --recipe recipe_file --params name=value to run sub-recipe task
    • it uses goose run --text text_instruction to run sub-agent task
    • if it executes multiple tasks in parallel, it will create a worker pool and task queue to execute the tasks

    TODO (won't be implemented in the PR)

    • max turn
    • error handling
    • maybe some special logic for sub agent such as exclude some specific tools like platform tools.

Note

  • This PR defines the interfaces for the sub agent and sub recipe execution. The implementation of execute_task by Goose cli will be changed. We will use something like subagent.run(task) with a thread instead of a process.

  • Currently I use this sub agent execution tool name as sub_recipe... and with the description only for sub recipe. In this case we still can keep the same feature behaviour. When the subagent.run(task) is ready, we can rename the sub agent execution tool name back to sub_agent... and add the sub agent in the description

async fn execute_task(task: Task) -> Result<Value, String> {
println!("=======Executing task: {:?}", task);

let mut command = if task.task_type == "sub_recipe" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later on we could swap the implementation from use cmd to something sub_agent.run(task)

let input_schema = get_input_schema(sub_recipe).unwrap();
Tool::new(
format!("{}_{}", SUB_RECIPE_TASK_TOOL_NAME_PREFIX, sub_recipe.name),
"Before running this sub recipe, you should first create a task with this tool and then pass the task to the task executor".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add the recipe description into the tool description?

Copy link
Collaborator Author

@lifeizhou-ap lifeizhou-ap Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wendytang This is a good idea!

However, I will hold on this change because at this point, the subrecipe does not have the content of the sub recipe file, so it does not know the subrecipe description. Parsing sub recipe file logic is currently in the goose-cli, we are going to move it into the goose package or parsing it before running sub-agent, and then we can get the description.

At the moment, without the sub recipe description in the tool description, it works fine. But definitely we will add this in when the parsing recipe file logic moves to goose package


use crate::agents::{sub_agent_execution_tool::lib::execute_tasks, tool_execution::ToolCallResult};

pub const SUB_AGENT_EXECUTE_TASK_TOOL_NAME: &str = "sub_recipe__execute_task";
Copy link
Collaborator Author

@lifeizhou-ap lifeizhou-ap Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, only name with sub_recipe so that it does not conflict with the alpha feature. Later on, sub agent should be executed with this tool. so it will be renamed to sub_agent,,,

Copy link
Contributor

@wendytang wendytang Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we rename SUB_AGENT_EXECUTE_TASK_TOOL_NAME to SUB_RECIPE_EXECUTE_TASK_TOOL_NAME?

pub fn create_sub_agent_execute_task_tool() -> Tool {
Tool::new(
SUB_AGENT_EXECUTE_TASK_TOOL_NAME,
"Only use this tool when you want to execute sub recipe task. **DO NOT** use this tool when you want to execute sub agent task.
Copy link
Collaborator Author

@lifeizhou-ap lifeizhou-ap Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"DO NOT use this tool when you want to execute sub agent task. " => same reason as above

@lifeizhou-ap lifeizhou-ap marked this pull request as ready for review July 3, 2025 06:06
SUB_AGENT_EXECUTE_TASK_TOOL_NAME,
"Only use this tool when you want to execute sub recipe task. **DO NOT** use this tool when you want to execute sub agent task.
If the tasks are not specified to be executed in parallel, you should use this tool to run each task immediately by passing a single task to the tool for each run.
If you want to execute tasks in parallel, you should pass a list of tasks to the tool.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an example in the description

#[cfg(test)]
mod tests {
use super::*;
use crate::agents::sub_agent_execution_tool::types::Task;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename all the vars and files from sub_agent_execution_tool to sub_recipe_execution_tool?

Copy link
Collaborator Author

@lifeizhou-ap lifeizhou-ap Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we leave this PR as it is, and I'll address this in the following PRs based on the progress? I remember we agreed in our meeting that this tool will execute both sub-agent and sub recipe

I feel we are going to run the sub-agent/sub recipe as spawn thread soon instead of starting a goose cli process.

* main:
  feat(goose-cli): theme persistence & selection (#1693)
  chore(release): release version 1.0.32 (#3248)
  Add fuzzy file search functionality (#3240)
  update styling of user messages (#3247)
  Add support for escape key to dismiss settings menu (#3225)
  fix: Refactor string truncation logic into reusable utility function to avoid panic (#2818) (#2819)
  fix: Prevent modal from closing on text select. (#3127)
  fix: Add back lazy_static (#3243)
  chore: remove unused dependencies (#3049)
  feat: Add close button (X) to toast notifications (#3197)
  Adds json schema validation to goose recipe validate cli (#3234)
@lifeizhou-ap lifeizhou-ap merged commit 2e9a2a5 into main Jul 4, 2025
11 of 12 checks passed
@lifeizhou-ap lifeizhou-ap deleted the lifei/try-parallel branch July 4, 2025 03:13
dianed-square added a commit to dianed-square/goose that referenced this pull request Jul 8, 2025
* update-to-v1.0.35: (57 commits)
  chore(release): release version 1.0.35 (block#3292)
  docs: enhanced code editing topic (block#3287)
  fix cu (block#3291)
  feat: Add environment variables to override model context limits (block#3260)
  chore(release): release version 1.0.34 (block#3285)
  fix(devcontainer): install protoc to fix build (block#3267)
  Enabling npx command to install on Windows Desktop (block#3283)
  Fix: Allow native Cmd+Up/Down cursor movement when user has typed text (block#3246)
  chore(release): release version 1.0.33 (block#3284)
  fix Windows Env Vars (block#3282)
  feat: bedrock image content support (block#3266)
  Add support in goose configure for streaming http mcp tools (block#3256)
  docs: add Alby MCP tutorial (block#3217)
  refactor(tests): make logging test in goose-cli less flaky on macos (block#3273)
  feat: cli can work with gui generated recipes (block#3254)
  Goose projects docs (block#3272)
  feat: add support for 'cu' command in extension installation (block#3261)
  Docs: Add cloudinary mcp tutorial (block#3268)
  fix: Enable agent to see instruction to use final output tool when it wasn't called (block#3253)
  Use command line to run sub agent and sub recipe (in sequence or parallel) (block#3190)
  ...
atarantino pushed a commit to atarantino/goose that referenced this pull request Jul 14, 2025
s-soroosh pushed a commit to s-soroosh/goose that referenced this pull request Jul 18, 2025
kwsantiago pushed a commit to kwsantiago/goose that referenced this pull request Jul 19, 2025
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants