From 81675e7dc86af3e09fb158b291f74b4fc6a9bdc4 Mon Sep 17 00:00:00 2001 From: Qian Li Date: Sun, 16 Nov 2025 20:03:03 -0800 Subject: [PATCH 1/2] Fix DBOS demos: wait for result --- durable-exec/deep_research_dbos.py | 10 ++++++---- durable-exec/twenty_questions_dbos.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/durable-exec/deep_research_dbos.py b/durable-exec/deep_research_dbos.py index de7959b..ac4b081 100644 --- a/durable-exec/deep_research_dbos.py +++ b/durable-exec/deep_research_dbos.py @@ -115,6 +115,7 @@ async def deep_research_durable(query: str): 'name': 'deep_research_durable', 'enable_otlp': True, 'conductor_key': os.environ.get('DBOS_CONDUCTOR_KEY', None), + "application_version": "0.1.0", } DBOS(config=config) DBOS.launch() @@ -122,12 +123,13 @@ async def deep_research_durable(query: str): wf_id = f'deep-research-{uuid.uuid4()}' if resume_id is not None: print('resuming existing workflow', resume_id) - wf_id = resume_id + # Get the workflow handle and wait for the result + wf_handle: WorkflowHandleAsync[str] = await DBOS.retrieve_workflow_async(resume_id) + summary = await wf_handle.get_result() else: print('starting new workflow', wf_id) - - with SetWorkflowID(wf_id): - summary = await deep_research(query) + with SetWorkflowID(wf_id): + summary = await deep_research(query) print(summary) diff --git a/durable-exec/twenty_questions_dbos.py b/durable-exec/twenty_questions_dbos.py index 8697187..7a1a5b4 100644 --- a/durable-exec/twenty_questions_dbos.py +++ b/durable-exec/twenty_questions_dbos.py @@ -5,7 +5,7 @@ from enum import StrEnum import logfire -from dbos import DBOS, DBOSConfig, SetWorkflowID +from dbos import DBOS, DBOSConfig, SetWorkflowID, WorkflowHandleAsync from pydantic_ai import Agent, AgentRunResult, RunContext, UsageLimits from pydantic_ai.durable_exec.dbos import DBOSAgent @@ -80,19 +80,21 @@ async def play(resume_id: str | None, answer: str) -> AgentRunResult[str]: # run the server with # docker run -e POSTGRES_HOST_AUTH_METHOD=trust --rm -it --name pg -p 5432:5432 -d postgres 'system_database_url': 'postgresql://postgres@localhost:5432/dbos', + "application_version": "0.1.0", } DBOS(config=config) DBOS.launch() if resume_id is not None: print('resuming existing workflow', resume_id) - wf_id = resume_id + # Get the workflow handle and wait for the result + wf_handle: WorkflowHandleAsync[AgentRunResult] = await DBOS.retrieve_workflow_async(resume_id) + result = await wf_handle.get_result() else: wf_id = f'twenty-questions-{uuid.uuid4()}' print('starting new workflow', wf_id) - - state = GameState(answer=answer) - with SetWorkflowID(wf_id): - result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25)) + state = GameState(answer=answer) + with SetWorkflowID(wf_id): + result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25)) print(f'After {len(result.all_messages()) / 2}, the answer is: {result.output}') From ff1380febc2f529a4426a86c9e963b39bc58ecab Mon Sep 17 00:00:00 2001 From: Qian Li Date: Sun, 16 Nov 2025 20:11:59 -0800 Subject: [PATCH 2/2] formatting --- durable-exec/deep_research_dbos.py | 2 +- durable-exec/twenty_questions_dbos.py | 2 +- pyproject.toml | 2 +- uv.lock | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/durable-exec/deep_research_dbos.py b/durable-exec/deep_research_dbos.py index ac4b081..52fcabc 100644 --- a/durable-exec/deep_research_dbos.py +++ b/durable-exec/deep_research_dbos.py @@ -115,7 +115,7 @@ async def deep_research_durable(query: str): 'name': 'deep_research_durable', 'enable_otlp': True, 'conductor_key': os.environ.get('DBOS_CONDUCTOR_KEY', None), - "application_version": "0.1.0", + 'application_version': '0.1.0', } DBOS(config=config) DBOS.launch() diff --git a/durable-exec/twenty_questions_dbos.py b/durable-exec/twenty_questions_dbos.py index 7a1a5b4..8f7cfbe 100644 --- a/durable-exec/twenty_questions_dbos.py +++ b/durable-exec/twenty_questions_dbos.py @@ -80,7 +80,7 @@ async def play(resume_id: str | None, answer: str) -> AgentRunResult[str]: # run the server with # docker run -e POSTGRES_HOST_AUTH_METHOD=trust --rm -it --name pg -p 5432:5432 -d postgres 'system_database_url': 'postgresql://postgres@localhost:5432/dbos', - "application_version": "0.1.0", + 'application_version': '0.1.0', } DBOS(config=config) DBOS.launch() diff --git a/pyproject.toml b/pyproject.toml index 93d71d1..fadbb66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "mcp>=1.15.0", "pydantic-ai>=1", "tavily-python>=0.7.12", - "dbos>=2", + "dbos>=2.4.0", ] [dependency-groups] diff --git a/uv.lock b/uv.lock index 46ad8bf..e2d3d2d 100644 --- a/uv.lock +++ b/uv.lock @@ -375,7 +375,7 @@ wheels = [ [[package]] name = "dbos" -version = "2.3.0" +version = "2.4.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "psycopg", extra = ["binary"] }, @@ -385,9 +385,9 @@ dependencies = [ { name = "typer-slim" }, { name = "websockets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/ec/fa/10e804fec5d5f064cbffbc1fd9144897b9e8251f8fa0cefa64255b3bffaa/dbos-2.3.0.tar.gz", hash = "sha256:298c53ac81b6b4811f81a4792c3887c3599f52de2fef96e176d76ded6dc01f19", size = 211419, upload-time = "2025-10-27T18:37:16.645Z" } +sdist = { url = "https://files.pythonhosted.org/packages/c3/85/5256e2a07ea03ade6d635807e6ee042131a3a82d5c834e5d7e8d81241288/dbos-2.4.0.tar.gz", hash = "sha256:39687ecc454a504346458a4388fcef6f582d105c5028e3bb2dc835a439dc74e1", size = 213057, upload-time = "2025-11-11T17:46:14.605Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/4b/36/e6c583cdd46825c6f6587631bb037c25da17fedb686bedea88664f34188b/dbos-2.3.0-py3-none-any.whl", hash = "sha256:723d0971d1e3ecc14222106b091f4d3cebd4854e287d396e05bfa8a33455af02", size = 135472, upload-time = "2025-10-27T18:37:13.599Z" }, + { url = "https://files.pythonhosted.org/packages/53/5d/e2175c0328f3a9a4e9755a20ef6dd1d6f580527ec88ff83a506ea8815c50/dbos-2.4.0-py3-none-any.whl", hash = "sha256:863cce027de4a5003a3885976ca66ceda44927844bfd374d6156c154eafb03eb", size = 136198, upload-time = "2025-11-11T17:46:12.593Z" }, ] [[package]] @@ -1693,7 +1693,7 @@ dev = [ [package.metadata] requires-dist = [ { name = "asyncpg", specifier = ">=0.30.0" }, - { name = "dbos", specifier = ">=2" }, + { name = "dbos", specifier = ">=2.4.0" }, { name = "devtools", specifier = ">=0.12.2" }, { name = "fastapi", specifier = ">=0.115.14" }, { name = "logfire", extras = ["asyncpg", "fastapi", "httpx"], specifier = ">=4.10" },