You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/durable_execution/prefect.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -255,20 +255,23 @@ from prefect import flow
255
255
from pydantic_ai import Agent
256
256
from pydantic_ai.durable_exec.prefect import PrefectAgent
257
257
258
-
agent = Agent(
259
-
'openai:gpt-4o',
260
-
name='daily_report_agent',
261
-
instructions='Generate a daily summary report.',
262
-
)
263
-
264
-
prefect_agent = PrefectAgent(agent)
265
258
266
259
@flow
267
260
asyncdefdaily_report_flow(user_prompt: str):
268
261
"""Generate a daily report using the agent."""
262
+
agent = Agent( # (1)!
263
+
'openai:gpt-4o',
264
+
name='daily_report_agent',
265
+
instructions='Generate a daily summary report.',
266
+
)
267
+
268
+
prefect_agent = PrefectAgent(agent)
269
+
269
270
result =await prefect_agent.run(user_prompt)
270
271
return result.output
271
272
273
+
274
+
272
275
# Serve the flow with a daily schedule
273
276
if__name__=='__main__':
274
277
daily_report_flow.serve(
@@ -279,6 +282,8 @@ if __name__ == '__main__':
279
282
)
280
283
```
281
284
285
+
1. Each flow run executes in an isolated process, and all inputs and dependencies must be serializable. Because Agent instances cannot be serialized, instantiate the agent inside the flow rather than at the module level.
286
+
282
287
The `serve()` method accepts scheduling options:
283
288
284
289
-**`cron`**: Cron schedule string (e.g., `'0 9 * * *'` for daily at 9am)
f'Model token limit ({max_tokensifmax_tokensisnotNoneelse"provider default"}) exceeded while emitting a tool call, resulting in incomplete arguments. Increase max tokens or simplify tool call arguments to fit within limit.'
116
+
)
98
117
message=f'Exceeded maximum retries ({max_result_retries}) for output validation'
0 commit comments