a646e60d2f
Exception: ``` nid:ce829f66-14b0-4bd3-b748-791e46666cb6|-] Failed node execution ce829f66-14b0-4bd3-b748-791e46666cb6: Cannot release an unlocked lock {}\u001b[0m", Traceback (most recent call last):\n File \"/app/autogpt_platform/backend/backend/integrations/creds_manager.py\", line 145, in _locked\n yield\n File \"/app/autogpt_platform/backend/backend/integrations/creds_manager.py\", line 115, in acquire\n lock = self._acquire_lock(user_id, credentials_id)", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", File \"/app/autogpt_platform/backend/backend/integrations/creds_manager.py\", line 139, in _acquire_lock", return self._locks.acquire(key)", ^^^^^^^^^^^^^^^^^^^^^^^^", File \"/app/autogpt_platform/autogpt_libs/autogpt_libs/utils/synchronize.py\", line 44, in acquire", lock.acquire()", File \"/usr/local/lib/python3.11/site-packages/redis/lock.py\", line 218, in acquire", mod_time.sleep(sleep)", File \"/app/autogpt_platform/backend/backend/executor/manager.py\", line 471, in <lambda>", signal.SIGTERM, lambda _, __: cls.on_node_executor_sigterm()", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", File \"/app/autogpt_platform/backend/backend/executor/manager.py\", line 498, in on_node_executor_sigterm", sys.exit(0)", SystemExit: 0", During handling of the above exception, another exception occurred:", Traceback (most recent call last):\n File \"/app/autogpt_platform/backend/backend/executor/manager.py\", line 539, in _on_node_execution\n for execution in execute_node(\n File \"/app/autogpt_platform/backend/backend/executor/manager.py\", line 175, in execute_node\n credentials, creds_lock = creds_manager.acquire(user_id, credentials_meta.id)", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", File \"/app/autogpt_platform/backend/backend/integrations/creds_manager.py\", line 114, in acquire", with self._locked(user_id, credentials_id, \"!time_sensitive\"):", File \"/usr/local/lib/python3.11/contextlib.py\", line 158, in __exit__", self.gen.throw(typ, value, traceback)", File \"/app/autogpt_platform/backend/backend/integrations/creds_manager.py\", line 147, in _locked", lock.release()", File \"/usr/local/lib/python3.11/site-packages/redis/lock.py\", line 254, in release", raise LockError(\"Cannot release an unlocked lock\", lock_name=self.name)", redis.exceptions.LockError: Cannot release an unlocked lock", ``` ### Changes 🏗️ ``` try: lock.acquire() ... finally: lock.release() ``` pattern can cause an error where the lock is already released due to timeout. The scope of the change is to manually check the lock status before releasing. ### Checklist 📋 #### For code changes: - [ ] I have clearly listed my changes in the PR description - [ ] I have made a test plan - [ ] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [ ] ... <details> <summary>Example test plan</summary> - [ ] Create from scratch and execute an agent with at least 3 blocks - [ ] Import an agent from file upload, and confirm it executes correctly - [ ] Upload agent to marketplace - [ ] Import an agent from marketplace and confirm it executes correctly - [ ] Edit an agent from monitor, and confirm it executes correctly </details> #### For configuration changes: - [ ] `.env.example` is updated or already compatible with my changes - [ ] `docker-compose.yml` is updated or already compatible with my changes - [ ] I have included a list of my configuration changes in the PR description (under **Changes**) <details> <summary>Examples of configuration changes</summary> - Changing ports - Adding new services that need to communicate with each other - Secrets or environment variable changes - New or infrastructure changes such as databases </details> |
||
---|---|---|
.. | ||
backend | ||
migrations | ||
test | ||
.env.example | ||
.gitignore | ||
docker-compose.test.yaml | ||
Dockerfile | ||
linter.py | ||
poetry.lock | ||
pyproject.toml | ||
README.advanced.md | ||
README.md | ||
run_tests.py | ||
schema.prisma |
AutoGPT Agent Server
This is an initial project for creating the next generation of agent execution, which is an AutoGPT agent server. The agent server will enable the creation of composite multi-agent systems that utilize AutoGPT agents and other non-agent components as its primitives.
Docs
You can access the docs for the AutoGPT Agent Server here.
Setup
We use the Poetry to manage the dependencies. To set up the project, follow these steps inside this directory:
-
Install Poetry
pip install poetry
-
Configure Poetry to use .venv in your project directory
poetry config virtualenvs.in-project true
-
Enter the poetry shell
poetry shell
-
Install dependencies
poetry install
-
Copy .env.example to .env
cp .env.example .env
-
Generate the Prisma client
poetry run prisma generate
In case Prisma generates the client for the global Python installation instead of the virtual environment, the current mitigation is to just uninstall the global Prisma package:
pip uninstall prisma
Then run the generation again. The path should look something like this:
<some path>/pypoetry/virtualenvs/backend-TQIRSwR6-py3.12/bin/prisma
-
Migrate the database. Be careful because this deletes current data in the database.
docker compose up db -d poetry run prisma migrate deploy
Running The Server
Starting the server without Docker
Run the following command to run database in docker but the application locally:
docker compose --profile local up deps --build --detach
poetry run app
Starting the server with Docker
Run the following command to build the dockerfiles:
docker compose build
Run the following command to run the app:
docker compose up
Run the following to automatically rebuild when code changes, in another terminal:
docker compose watch
Run the following command to shut down:
docker compose down
If you run into issues with dangling orphans, try:
docker compose down --volumes --remove-orphans && docker-compose up --force-recreate --renew-anon-volumes --remove-orphans
Testing
To run the tests:
poetry run test
Development
Formatting & Linting
Auto formatter and linter are set up in the project. To run them:
Install:
poetry install --with dev
Format the code:
poetry run format
Lint the code:
poetry run lint
Project Outline
The current project has the following main modules:
blocks
This module stores all the Agent Blocks, which are reusable components to build a graph that represents the agent's behavior.
data
This module stores the logical model that is persisted in the database. It abstracts the database operations into functions that can be called by the service layer. Any code that interacts with Prisma objects or the database should reside in this module. The main models are:
block
: anything related to the block used in the graphexecution
: anything related to the execution graph executiongraph
: anything related to the graph, node, and its relations
execution
This module stores the business logic of executing the graph. It currently has the following main modules:
manager
: A service that consumes the queue of the graph execution and executes the graph. It contains both pieces of logic.scheduler
: A service that triggers scheduled graph execution based on a cron expression. It pushes an execution request to the manager.
server
This module stores the logic for the server API.
It contains all the logic used for the API that allows the client to create, execute, and monitor the graph and its execution.
This API service interacts with other services like those defined in manager
and scheduler
.
utils
This module stores utility functions that are used across the project. Currently, it has two main modules:
process
: A module that contains the logic to spawn a new process.service
: A module that serves as a parent class for all the services in the project.
Service Communication
Currently, there are only 3 active services:
- AgentServer (the API, defined in
server.py
) - ExecutionManager (the executor, defined in
manager.py
) - ExecutionScheduler (the scheduler, defined in
scheduler.py
)
The services run in independent Python processes and communicate through an IPC.
A communication layer (service.py
) is created to decouple the communication library from the implementation.
Currently, the IPC is done using Pyro5 and abstracted in a way that allows a function decorated with @expose
to be called from a different process.
By default the daemons run on the following ports:
Execution Manager Daemon: 8002 Execution Scheduler Daemon: 8003 Rest Server Daemon: 8004
Adding a New Agent Block
To add a new agent block, you need to create a new class that inherits from Block
and provides the following information:
- All the block code should live in the
blocks
(backend.blocks
) module. input_schema
: the schema of the input data, represented by a Pydantic object.output_schema
: the schema of the output data, represented by a Pydantic object.run
method: the main logic of the block.test_input
&test_output
: the sample input and output data for the block, which will be used to auto-test the block.- You can mock the functions declared in the block using the
test_mock
field for your unit tests. - Once you finish creating the block, you can test it by running
poetry run pytest -s test/block/test_block.py
.