Skip to content

Conversation

qianl15
Copy link

@qianl15 qianl15 commented Aug 22, 2025

Summary

Closes #2629

This PR integrates DBOS with Agent.run and related methods to provide out-of-the-box durable execution and checkpointing.

Changes

  • Workflows:

    • Agent.run and Agent.run_sync are now decorated as DBOS workflows.
    • Users no longer need to manually wrap these functions in DBOS workflows.
  • Steps:

    • Model requests and MCP calls (get_tools, call_tool) are decorated as DBOS steps.
    • Outside DBOS, these remain ordinary functions.
    • Inside DBOS workflows, outputs are automatically checkpointed in Postgres.
  • Tooling:

    • Users may pass in DBOS-decorated functions (workflows, steps, transactions) as tools.
    • 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.

TODO

  • Add documentation
  • Update to V1 API.
  • Make human-in-the-loop work with DBOSAgent.

@qianl15
Copy link
Author

qianl15 commented Aug 28, 2025

All review comments addressed. Updates from last review:

  • Switched to use SQLite instead of Postgres for CI tests.
  • Made DBOS an optional dependency for pydantic-ai.
  • Added a full draft of the dbos.md docs.

Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qianl15 Thanks Qian, we're getting there :) If you could port the HITL tool approval test we have for Temporal, as you suggested in the description, that'd be great!

docs/dbos.md Outdated

## Observability with Logfire

DBOS emits OpenTelemetry traces and events for every workflow and step, and Pydantic AI generates events for each agent run, model request and tool call. These can be sent to [Pydantic Logfire](logfire.md) to get a complete picture of what's happening in your application.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they sent to Logfire automatically, assuming it is set up?

It would be great to see that in the span tree in the test_complex_agent_run_in_workflow test -- as you can see in the temporal test it has StartWorkflow events

Copy link
Author

@qianl15 qianl15 Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs and tests for this. Right now DBOS and Logfire generate overlapping spans since OpenTelemetry doesn't interoperate cleanly, so I changed the defaults/docs to disable DBOS OTLP traces.

Because DBOS runs workflows and steps as normal function calls, you won't see extra spans like "StartWorkflow" or "RunWorkflow" events.

@qianl15
Copy link
Author

qianl15 commented Sep 3, 2025

@qianl15 Thanks Qian, we're getting there :) If you could port the HITL tool approval test we have for Temporal, as you suggested in the description, that'd be great!

Thanks @DouweM for the review! I addressed all your comments and added the HITL tests (both async and sync work as expected).

@qianl15 qianl15 requested a review from DouweM September 3, 2025 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DBOS Support
2 participants