Skip to main content

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: define StepConfig for configurable step retries.
    • Tests are under tests/test_dbos_agent.py.
  • Workflows:

    • DBOSAgentExecutor.invoke is 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 the code from the test:

from crewai import Agent, Task
from crewai.tools import tool
from dbos_crewai import DBOSAgent

@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.",
)

# 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)
assert output == "12"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbos_crewai-0.0.2a1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbos_crewai-0.0.2a1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file dbos_crewai-0.0.2a1.tar.gz.

File metadata

  • Download URL: dbos_crewai-0.0.2a1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dbos_crewai-0.0.2a1.tar.gz
Algorithm Hash digest
SHA256 e677bcd038510dfbc0ed2eef30d1e46e9e8b9754f8112c6698e96f3d4e177e37
MD5 ad33ae621c5011f473af9cd3342a81b6
BLAKE2b-256 b63a9e7ec2e2780ed8ac67bbb42fbec2add0d054fd95d333c2672a56da032b2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbos_crewai-0.0.2a1.tar.gz:

Publisher: publish.yml on dbos-inc/dbos-crewai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbos_crewai-0.0.2a1-py3-none-any.whl.

File metadata

  • Download URL: dbos_crewai-0.0.2a1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dbos_crewai-0.0.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3f672af060c4d1efe99a9bb0c3e62648b3f47e4e87d9f734f19651bc0bac5ef
MD5 013c84dc1403ad416add039e9c974f31
BLAKE2b-256 53915b06e56cadd9bf3720ff9ad380d1edb566e49e1a9632b30f48694d22db17

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbos_crewai-0.0.2a1-py3-none-any.whl:

Publisher: publish.yml on dbos-inc/dbos-crewai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page