CrewAI DBOS durable agent
Project description
CrewAI DBOS durable agent
[!NOTE] This repo is work-in-progress. Don't use it in production yet :)
This repo demonstrates how to add durable execution support into CrewAI agents.
It integrates DBOS with CrewAgentExecutor.invoke and related methods to provide out-of-the-box durable execution and checkpointing.
This is based on PR: https://github.com/crewAIInc/crewAI/pull/3526
Overview
-
File Structure:
- The
dbos_crewai/folder contains all the relevant files.dbos_agent.py: the main entrypoint for using DBOS agents.dbos_agent_executor.py: executor for managing the agent main loop.dbos_llm.py: wrapping llm calls as DBOS steps.dbos_util.py: defineStepConfigfor configurable step retries.
- Tests are under
tests/test_dbos_agent.py.
- The
-
Workflows:
DBOSAgentExecutor.invokeis automatically decorated a DBOS workflow.
-
Steps:
- LLM requests are automatically decorated as DBOS steps.
- Outside DBOS, these remain ordinary functions.
- Inside DBOS workflows, step outputs are automatically checkpointed in Postgres.
-
Tooling:
- Users may pass in DBOS-decorated functions (workflows, steps, transactions) as tools or event handlers.
- The integration does not automatically wrap tools in DBOS decorators, so users retain full control. For example, they can pass in a workflow which will be invoked as a child workflow; or they can pass in a step.
- Tools behave as normal functions when not used with DBOS.
Example
To use the integration, users only need to add a few lines of DBOS code on top of their existing agent code. Here is an example of using CrewAI with DBOS (this example is complete, it can be run "as is").
from crewai import Agent, Task
from crewai.tools import tool
from dbos_crewai import DBOSAgent
from dbos import DBOS, SetWorkflowID, DBOSConfig
import os
config: DBOSConfig = {
"name": "dbos-crewai-starter",
"system_database_url": os.environ.get("DBOS_SYSTEM_DATABASE_URL"),
"conductor_key": os.environ.get("DBOS_CONDUCTOR_KEY"),
}
DBOS(config=config)
@tool
@DBOS.step() # Decorate this function as a DBOS step
def multiplier(first_number: int, second_number: int) -> float:
"""Useful for when you need to multiply two numbers together."""
return first_number * second_number
# Agent declaration remains the same
orig_agent = Agent(
role="test role",
goal="test goal",
backstory="test backstory",
tools=[multiplier],
allow_delegation=False,
)
# Wrap the original agent in a DBOS agent
dbos_agent = DBOSAgent(
agent_name="test_agent_execution_with_tools",
orig_agent=orig_agent,
)
task = Task(
description="What is 3 times 4?",
agent=dbos_agent,
expected_output="The result of the multiplication.",
)
def main():
# Launch DBOS before running workflows
DBOS.launch()
# Optionally set a workflow ID for tracking progress. If unspecified, a UUID will be generated as the ID.
with SetWorkflowID("test_execution"):
# The main agent execution loop is automatically a DBOS workflow, and the LLM calls are DBOS steps. Tools that are annotated with DBOS.step() are also DBOS steps.
output = dbos_agent.execute_task(task)
print(output)
if __name__ == "__main__":
main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbos_crewai-0.0.2.tar.gz.
File metadata
- Download URL: dbos_crewai-0.0.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057080337310a9231c8c0a58cea54ade2820e976cca355a4c6b683d825c88744
|
|
| MD5 |
18cf46b642720709d33a80d49e90367c
|
|
| BLAKE2b-256 |
bd0ba8c0a5f7145a68ca311fb6020b703bd7be513755dde5897a0d44df78a99f
|
Provenance
The following attestation bundles were made for dbos_crewai-0.0.2.tar.gz:
Publisher:
publish.yml on dbos-inc/dbos-crewai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbos_crewai-0.0.2.tar.gz -
Subject digest:
057080337310a9231c8c0a58cea54ade2820e976cca355a4c6b683d825c88744 - Sigstore transparency entry: 664480424
- Sigstore integration time:
-
Permalink:
dbos-inc/dbos-crewai@67f84a58e9b1016516615af4d2ddc1f80c8e8258 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/dbos-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67f84a58e9b1016516615af4d2ddc1f80c8e8258 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dbos_crewai-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dbos_crewai-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fce0d10715111ba9764339d966dfb848e08398088f2d9e6d0c579eca2b04ad8f
|
|
| MD5 |
1ace0d9cb67898a57fafc62ca055439d
|
|
| BLAKE2b-256 |
0b710a380ff93b1d5159d46be990493a2cfde8b36abd8ced6076dfc9d3cebd52
|
Provenance
The following attestation bundles were made for dbos_crewai-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on dbos-inc/dbos-crewai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbos_crewai-0.0.2-py3-none-any.whl -
Subject digest:
fce0d10715111ba9764339d966dfb848e08398088f2d9e6d0c579eca2b04ad8f - Sigstore transparency entry: 664480452
- Sigstore integration time:
-
Permalink:
dbos-inc/dbos-crewai@67f84a58e9b1016516615af4d2ddc1f80c8e8258 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/dbos-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67f84a58e9b1016516615af4d2ddc1f80c8e8258 -
Trigger Event:
workflow_dispatch
-
Statement type: