Skip to content

Commit 6a3ef13

Browse files
committed
DBOS human-in-the-loop working
1 parent 67d454b commit 6a3ef13

File tree

4 files changed

+783
-2
lines changed

4 files changed

+783
-2
lines changed

pydantic_ai_slim/pydantic_ai/durable_exec/dbos/_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ async def main():
288288
user_prompt,
289289
output_type=output_type,
290290
message_history=message_history,
291+
deferred_tool_results=deferred_tool_results,
291292
model=model,
292293
deps=deps,
293294
model_settings=model_settings,
@@ -390,6 +391,7 @@ def run_sync(
390391
user_prompt,
391392
output_type=output_type,
392393
message_history=message_history,
394+
deferred_tool_results=deferred_tool_results,
393395
model=model,
394396
deps=deps,
395397
model_settings=model_settings,
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
interactions:
2+
- request:
3+
headers:
4+
accept:
5+
- application/json
6+
accept-encoding:
7+
- gzip, deflate
8+
connection:
9+
- keep-alive
10+
content-length:
11+
- '639'
12+
content-type:
13+
- application/json
14+
host:
15+
- api.openai.com
16+
method: POST
17+
parsed_body:
18+
messages:
19+
- content: Just call tools without asking for confirmation.
20+
role: system
21+
- content: Delete the file `.env` and create `test.txt`
22+
role: user
23+
model: gpt-4o
24+
stream: false
25+
tool_choice: auto
26+
tools:
27+
- function:
28+
description: ''
29+
name: create_file
30+
parameters:
31+
additionalProperties: false
32+
properties:
33+
path:
34+
type: string
35+
required:
36+
- path
37+
type: object
38+
strict: true
39+
type: function
40+
- function:
41+
description: ''
42+
name: delete_file
43+
parameters:
44+
additionalProperties: false
45+
properties:
46+
path:
47+
type: string
48+
required:
49+
- path
50+
type: object
51+
strict: true
52+
type: function
53+
uri: https://api.openai.com/v1/chat/completions
54+
response:
55+
headers:
56+
access-control-expose-headers:
57+
- X-Request-ID
58+
alt-svc:
59+
- h3=":443"; ma=86400
60+
connection:
61+
- keep-alive
62+
content-length:
63+
- '1319'
64+
content-type:
65+
- application/json
66+
openai-organization:
67+
- pydantic-28gund
68+
openai-processing-ms:
69+
- '737'
70+
openai-project:
71+
- proj_dKobscVY9YJxeEaDJen54e3d
72+
openai-version:
73+
- '2020-10-01'
74+
strict-transport-security:
75+
- max-age=31536000; includeSubDomains; preload
76+
transfer-encoding:
77+
- chunked
78+
parsed_body:
79+
choices:
80+
- finish_reason: tool_calls
81+
index: 0
82+
logprobs: null
83+
message:
84+
annotations: []
85+
content: null
86+
refusal: null
87+
role: assistant
88+
tool_calls:
89+
- function:
90+
arguments: '{"path": ".env"}'
91+
name: delete_file
92+
id: call_jYdIdRZHxZTn5bWCq5jlMrJi
93+
type: function
94+
- function:
95+
arguments: '{"path": "test.txt"}'
96+
name: create_file
97+
id: call_TmlTVWQbzrXCZ4jNsCVNbNqu
98+
type: function
99+
created: 1756419063
100+
id: chatcmpl-C9f7f1SbHRzcwlJwrYKdSonTRWPvV
101+
model: gpt-4o-2024-08-06
102+
object: chat.completion
103+
service_tier: default
104+
system_fingerprint: fp_df0f7b956c
105+
usage:
106+
completion_tokens: 46
107+
completion_tokens_details:
108+
accepted_prediction_tokens: 0
109+
audio_tokens: 0
110+
reasoning_tokens: 0
111+
rejected_prediction_tokens: 0
112+
prompt_tokens: 71
113+
prompt_tokens_details:
114+
audio_tokens: 0
115+
cached_tokens: 0
116+
total_tokens: 117
117+
status:
118+
code: 200
119+
message: OK
120+
- request:
121+
headers:
122+
accept:
123+
- application/json
124+
accept-encoding:
125+
- gzip, deflate
126+
connection:
127+
- keep-alive
128+
content-length:
129+
- '1109'
130+
content-type:
131+
- application/json
132+
cookie:
133+
- __cf_bm=mLR5rPRuew3fXXRgovBj3Ir6vRflwQucmAT8xYCnZaA-1756419064-1.0.1.1-HvvEmDcDOmavm0vBqLo_ZG_Bjh6B2CgT.etvrYCBiezHow_0xNZ64xqybhJl_NViSVDNXuaXviCcDgIZg13KgsWp0J_qNORRiVIHxO2UAO4;
134+
_cfuvid=536Zye1eyyVQS9C8BV6AAFwv4vaW.H4o2O4LK_228oc-1756419064420-0.0.1.1-604800000
135+
host:
136+
- api.openai.com
137+
method: POST
138+
parsed_body:
139+
messages:
140+
- content: Just call tools without asking for confirmation.
141+
role: system
142+
- content: Delete the file `.env` and create `test.txt`
143+
role: user
144+
- content: null
145+
role: assistant
146+
tool_calls:
147+
- function:
148+
arguments: '{"path": ".env"}'
149+
name: delete_file
150+
id: call_jYdIdRZHxZTn5bWCq5jlMrJi
151+
type: function
152+
- function:
153+
arguments: '{"path": "test.txt"}'
154+
name: create_file
155+
id: call_TmlTVWQbzrXCZ4jNsCVNbNqu
156+
type: function
157+
- content: 'true'
158+
role: tool
159+
tool_call_id: call_jYdIdRZHxZTn5bWCq5jlMrJi
160+
- content: Success
161+
role: tool
162+
tool_call_id: call_TmlTVWQbzrXCZ4jNsCVNbNqu
163+
model: gpt-4o
164+
stream: false
165+
tool_choice: auto
166+
tools:
167+
- function:
168+
description: ''
169+
name: create_file
170+
parameters:
171+
additionalProperties: false
172+
properties:
173+
path:
174+
type: string
175+
required:
176+
- path
177+
type: object
178+
strict: true
179+
type: function
180+
- function:
181+
description: ''
182+
name: delete_file
183+
parameters:
184+
additionalProperties: false
185+
properties:
186+
path:
187+
type: string
188+
required:
189+
- path
190+
type: object
191+
strict: true
192+
type: function
193+
uri: https://api.openai.com/v1/chat/completions
194+
response:
195+
headers:
196+
access-control-expose-headers:
197+
- X-Request-ID
198+
alt-svc:
199+
- h3=":443"; ma=86400
200+
connection:
201+
- keep-alive
202+
content-length:
203+
- '882'
204+
content-type:
205+
- application/json
206+
openai-organization:
207+
- pydantic-28gund
208+
openai-processing-ms:
209+
- '624'
210+
openai-project:
211+
- proj_dKobscVY9YJxeEaDJen54e3d
212+
openai-version:
213+
- '2020-10-01'
214+
strict-transport-security:
215+
- max-age=31536000; includeSubDomains; preload
216+
transfer-encoding:
217+
- chunked
218+
parsed_body:
219+
choices:
220+
- finish_reason: stop
221+
index: 0
222+
logprobs: null
223+
message:
224+
annotations: []
225+
content: The file `.env` has been deleted and `test.txt` has been created successfully.
226+
refusal: null
227+
role: assistant
228+
created: 1756419066
229+
id: chatcmpl-C9f7iBeeNNBazDCMa7RSx3EFtiZoR
230+
model: gpt-4o-2024-08-06
231+
object: chat.completion
232+
service_tier: default
233+
system_fingerprint: fp_80956533cb
234+
usage:
235+
completion_tokens: 19
236+
completion_tokens_details:
237+
accepted_prediction_tokens: 0
238+
audio_tokens: 0
239+
reasoning_tokens: 0
240+
rejected_prediction_tokens: 0
241+
prompt_tokens: 133
242+
prompt_tokens_details:
243+
audio_tokens: 0
244+
cached_tokens: 0
245+
total_tokens: 152
246+
status:
247+
code: 200
248+
message: OK
249+
version: 1

0 commit comments

Comments
 (0)