Files
Auto-GPT/docs/content/AutoGPT/component agent/agents.md
Krzysztof Czerwinski a74548d3cd feat(agent): Component-based Agents (#7054)
This incremental re-architecture unifies Agent code and plugins, so everything is component-based.

## Breaking changes

- Removed command categories and `DISABLED_COMMAND_CATEGORIES` environment variable. Use `DISABLED_COMMANDS` environment variable to disable individual commands.
- Changed `command` decorator; old-style commands are no longer supported. Implement `CommandProvider` on components instead.
- Removed `CommandRegistry`, now all commands are provided by components implementing `CommandProvider`.
- Removed `prompt_config` from `AgentSettings`.
- Removed plugin support: old plugins will no longer be loaded and executed.
- Removed `PromptScratchpad`, it was used by plugins and is no longer needed.
- Changed `ThoughtProcessOutput` from tuple to pydantic `BaseModel`.

## Other changes

- Created `AgentComponent`, protocols and logic to execute them.
- `BaseAgent` and `Agent` is now composed of components.
- Moved some logic from `BaseAgent` to `Agent`.
- Moved agent features and commands to components.
- Removed check if the same operation is about to be executed twice in a row.
- Removed file logging from `FileManagerComponent` (formerly `AgentFileManagerMixin`)
- Updated tests
- Added docs

See [Introduction](https://github.com/kcze/AutoGPT/blob/kpczerwinski/open-440-modular-agents/docs/content/AutoGPT/component%20agent/introduction.md) for more information.
2024-04-22 19:20:01 +02:00

1.9 KiB

🤖 Agents

Agent is composed of 🧩 Components and responsible for executing pipelines and some additional logic. The base class for all agents is BaseAgent, it has the necessary logic to collect components and execute protocols.

Important methods

BaseAgent provides two abstract methods needed for any agent to work properly:

  1. propose_action: This method is responsible for proposing an action based on the current state of the agent, it returns ThoughtProcessOutput.
  2. execute: This method is responsible for executing the proposed action, returns ActionResult.

AutoGPT Agent

Agent is the main agent provided by AutoGPT. It's a subclass of BaseAgent. It has all the Built-in Components. Agent implements the essential abstract methods from BaseAgent: propose_action and execute.

Building your own Agent

The easiest way to build your own agent is to extend the Agent class and add additional components. By doing this you can reuse the existing components and the default logic for executing ⚙️ Protocols.

class MyComponent(AgentComponent):
    pass

class MyAgent(Agent):
    def __init__(
        self,
        settings: AgentSettings,
        llm_provider: ChatModelProvider,
        file_storage: FileStorage,
        legacy_config: Config,
    ):
        # Call the parent constructor to bring in the default components
        super().__init__(settings, llm_provider, file_storage, legacy_config)
        # Add your custom component
        self.my_component = MyComponent()

For more customization, you can override the propose_action and execute or even subclass BaseAgent directly. This way you can have full control over the agent's components and behavior. Have a look at the implementation of Agent for more details.