AutoGPT
AutoGPT copied to clipboard
feat(agent): Draft of agent group feature
- Add
divider_and_conquer
strategy for use in agent members - Add
AgentMember
class - Add
AgentGroup
class - Add
hire_agent
andcreate_agent
andcreate_task
- Add
test_agent_group
as an integration test with VCR - Add
autogpt_multi_agent.sh
file to run autogpt in multi-agent mode
Background
In this PR we want to add AgentGroup feature as discussed in #6824.
The base of this PR is the AgentGroup
class. This class can create a group of agents like a company. The name of this agent will be AgentMember
and it will extend from Agent.
Each AgentGroup
has one leader
. leader
is kind of AgentMember
. Each AgentMember
can have several AgentMember
to do some task for its boss.
Main classes
AgentGroup
leader: AgentMember: This agent will be the head of this group
members: dict[str, AgentMember]: We need to have a list of all members in our tree to find an agent with the ID of that agent
AgentMember
id: str: Unique ID for each member
role: str: The role of the agent in the group
initial_prompt: str: The prompt for creating the agent
boss: Optional['AgentMember']: Boss of the agent
recruiter: Optional['AgentMember']: We can have a recruiter for agents to hire members for them
task_queue: list[Task]: A queue to store tasks for agent
members: list['AgentMember']: We need to have members to assign tasks to them
create_agent: bool: the ability to create an agent for an agent (if this was off and you need an agent, you should tell your boss)
db: AgentDB: For creating a task I need this one
group: 'AgentGroup': For run command, I need this one
Strategies
divide_and_conquer
This strategy is like one_shot strategy with some different. Every agent has a thread to check its task_queue
all the time. in each iterate AgentMember
loads tasks and its members and gives these values to llm_provider to get a list of commands that we want (unlike one_shot we will have a list of commands). We will have two more commands in the list of commands.
Commands
create_agent
If the create_agent
property of an agent is true this agent can create a new agent for an agent.
We need these properties for this action.
- prompt
- role
- boss_id After this one, we will have a member for an agent with boss_id id with prompt description.
hire_agent
If the create_agent
property of an agent is false and this agent wants a member, it should say to its boss or its recruiter to hire someone for it.
create_task
If they need to create a task for others, they can use this command. task (str): The description of that task agent_id (str): The id of the agent will be the owner of this task. father_task_id (str): The task id that is the cause of this task.
tests
test_agent_group
This test is an integration test that will support all code that we will write. The scenario is a create best shooter game in the world
. This test uses VCR for LLM responses. The VCR files have been changed (It is not the direct response of LLM). In this test we'll create an AgentGroup
with the CEO as leader
and the CEO will have an hr_lead as its member.
How we can run Autogpt in multi-agent mode
autogpt_multi_agent.sh
We can run Autogpt in multi-agent cli mode by this script. It is like autogpt.sh
. It has just one more argument and it is member-description
. The structure of member-description
will be like this. --member-description "{role_name}:{description of this member}:{boolean of can create new agent or no}:{boss_index}:{recruiter_index}"
. It's just for starting and it will need to get better. An example of running this command and creating a new agent group can be this:
./autogpt_multi_agent.sh --member-description "tech_lead:you will be tech lead of github.com/Significant-Gravitas/AutoGPT project and
you need to get this project better in github:False::1" --member-description "hr_lead:you will be hr of this team. you need to prepare agents for this work done.:True:0" --me
mber-description "senior_python_developer:you will be developer of this team and you will get issues to get them done:False:0"
Changes 🏗️
We didn't change something in here. We added some classes as we talked about in the Background part.
PR Quality Scorecard ✨
- [x] Have you used the PR description template?
+2 pts
- [x] Is your pull request atomic, focusing on a single charge?
+5 pts
- [x] Have you linked the GitHub issue(s) that this PR addresses?
+5 pts
- [x] Have you documented your changes clearly and comprehensively?
+5 pts
- [x] Have you changed or added a feature?
-4 pts
- [x] Have you added/updated corresponding documentation?
+4 pts
- [x] Have you added/updated corresponding integration tests?
+5 pts
- [x] Have you added/updated corresponding documentation?
- [ ] Have you changed the behavior of AutoGPT?
-5 pts
- [ ] Have you also run
agbenchmark
to verify that these changes do not regress performance?+10 pts
- [ ] Have you also run
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR.
Deploy Preview for auto-gpt-docs ready!
Name | Link |
---|---|
Latest commit | 571985a6dd6bd8ad94f142329e47e28108f6d2df |
Latest deploy log | https://app.netlify.com/sites/auto-gpt-docs/deploys/66251d94607b940008634ecd |
Deploy Preview | https://deploy-preview-6896--auto-gpt-docs.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
This PR needs to be changed. This was just for review.
I updated the pull request description. This is a just draft version and needs to be improved.
One problem I have right now is that we need to have a field as sub_tasks in the AgentTask
class. It will store details of sub-tasks created and the status of them. I am going to store sub-tasks in agent_task
One problem I have right now is that we need to have a field as sub_tasks in the
AgentTask
class. It will store details of sub-tasks created and the status of them. I am going to store sub-tasks inagent_task
Have you read the roadmap items in discussion? I think this mayyy be covered in one?
One problem I have right now is that we need to have a field as sub_tasks in the
AgentTask
class. It will store details of sub-tasks created and the status of them. I am going to store sub-tasks inagent_task
Have you read the roadmap items in discussion? I think this mayyy be covered in one?
Could you give me the link of discussion?
https://github.com/Significant-Gravitas/AutoGPT/discussions/6971
~~Are these commands enabled? Was trying to test but can't get the llm to execute them lol~~ Commands are not being inserted into the prompt
~~Are these commands enabled? Was trying to test but can't get the llm to execute them lol~~ Commands are not being inserted into the prompt
I wrote another sh file to run multi agent mode. But it's not over yet. I am working on it right now.
I change the proposed action of the agent member. I added autogpt_multi_agent.sh and a description for that in the pull request description. It's experimental. I can't get good results and commands in my tests. I will record a video if I can for my tests.
./autogpt_multi_agent.sh --member-description "tech_lead:you will be tech lead of github.com/Significant-Gravitas/AutoGPT project and
you need to get this project better in github:False::1" --member-description "hr_lead:you will be hr of this team. you need to prepare agents for this work done.:True:0" --me
mber-description "senior_python_developer:you will be developer of this team and you will get issues to get them done:False:0"
If I change llm response to xml, I will get better result? (I'm getting so non-json result in my tests) I think we have an issue for this one too. @ntindle @Pwuts
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
For support multi-agent, you commented this Does this have to be in the Forge DB? I suggest storing this kind of state in the AgentSettings (or subclass) object, which can be serialized and stored, together with the other state of the agent. and I try to not save tasks in DB
. But when I wanted to use benchmark over it, it seemed agbenchmark used uuid of that task to load it from DB. Do you have any advice for me about what should I do? @Pwuts
If I change llm response to xml, I will get better result? (I'm getting so non-json result in my tests)
This is out of scope for this PR and I doubt you will get better results at least on OpenAI which is optimized for json.
... But when I wanted to use benchmark over it, it seemed agbenchmark used uuid of that task to load it from DB. Do you have any advice for me about what should I do?
I wouldn't worry about DB for now; don't change it. Just make sure to store all data that the agent needs in AgentSettings
(see https://github.com/Significant-Gravitas/AutoGPT/pull/6896#discussion_r1573291633).
This is interesting and potentially worth merging!
We're working on Component-based Agents (this linked PR doesn't move code to the forge yet - it'll be done in a separate PR) which may be merged any day now. It's going to make the forge more effective and easier to build Agents. Given that, this PR will need a refactor (let me know if you need help, can be on Discord @kcze). I recommend you have a look at the Component Agents PR and linked docs.
Please use
black
,isort
,flake8
to fix linting (docs).
Thank you @kcze for your great review. I'll check them as soon as I can.
This is out of scope for this PR and I doubt you will get better results at least on OpenAI which is optimized for json.
Yes, you are right.
I wouldn't worry about DB for now; don't change it. Just make sure to store all data that the agent needs in AgentSettings (see https://github.com/Significant-Gravitas/AutoGPT/pull/6896#discussion_r1573291633).
Yeah. I found it recently. I will fix this one too for benchmark.
@CodiumAI-Agent /review
PR Review
⏱️ Estimated effort to review [1-5] |
4, because the PR introduces a complex new feature with multiple new classes and methods across several files. The changes involve intricate logic for agent management and task handling, which requires careful consideration to ensure correctness and maintainability. |
🧪 Relevant tests |
Yes |
🔍 Possible issues |
Possible Bug: The method |
Design Concern: The | |
🔒 Security concerns |
No |
Code feedback:
relevant file | autogpts/autogpt/autogpt/agents/agent_member.py |
suggestion |
Consider implementing exception handling in the |
relevant line | except Exception as e: |
relevant file | autogpts/autogpt/autogpt/agents/agent_group.py |
suggestion |
Refactor the |
relevant line | class AgentGroup: |
relevant file | autogpts/autogpt/autogpt/agents/agent_member.py |
suggestion |
Add validation for the |
relevant line | async def create_agent_member( |
relevant file | autogpts/autogpt/autogpt/agents/agent_member.py |
suggestion |
Optimize the |
relevant line | def get_list_of_all_your_team_members(self) -> list["AgentMember"]: |
✨ Review tool usage guide:
Overview:
The review
tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.
The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
- When commenting, to edit configurations related to the review tool (
pr_reviewer
section), use the following template:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
- With a configuration file, use the following template:
[pr_reviewer]
some_config1=...
some_config2=...
See the review usage page for a comprehensive guide on using this tool.
@MKdir98 I love what you did on this, however the project has changed a lot since you did this and I don't see a path for it being merged.
We are currently trying to implement a feature like this in an agent builder via the concept of subgraphs. If your'e interested maybe you could help there.
@MKdir98 I love what you did on this, however the project has changed a lot since you did this and I don't see a path for it being merged.
We are currently trying to implement a feature like this in an agent builder via the concept of subgraphs. If your'e interested maybe you could help there.
That will be great. I'll check it.
@MKdir98 Are you on the discord - If so reach out in the dev channel and we can discuss the details :)