-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Use command line to run sub agent and sub recipe (in sequence or parallel) #3190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| async fn execute_task(task: Task) -> Result<Value, String> { | ||
| println!("=======Executing task: {:?}", task); | ||
|
|
||
| let mut command = if task.task_type == "sub_recipe" { |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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,,,
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
| 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.", |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
* 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) ...
…llel) (block#3190) Signed-off-by: Adam Tarantino <[email protected]>
…llel) (block#3190) Signed-off-by: Soroosh <[email protected]>
…llel) (block#3190) Signed-off-by: Kyle Santiago <[email protected]>
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_tasktool to run a single task or multiple task in parallelTask can be 2 types
Sub recipe task. This task is created by sub recipe create task tool function and the task has attributes:
goose run recipecommand line)This task is executed as
goose run --recipe recipe_file --params name=valueSub 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?)
sub_agent__execute_tasktoolgoose run --recipe recipe_file --params name=valueto run sub-recipe taskgoose run --text text_instructionto run sub-agent taskTODO (won't be implemented in the PR)
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 tosub_agent...and add thesub agentin the description