Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async def main():
)
)

travel_planner.start()
runner = AgentRunner()

try:
Expand All @@ -79,8 +78,7 @@ async def main():
)
print(itinerary)
finally:
travel_planner.stop()
runner.shutdown()
runner.shutdown(travel_planner)

```
This example demonstrates creating a workflow-backed agent that runs autonomously in the background. The `AgentRunner` schedules the workflow for you, waits for completion, and ensures the agent can be triggered once yet continue execution across restarts.
Expand Down Expand Up @@ -267,15 +265,14 @@ travel_planner = DurableAgent(
],
tools=[search_flights],
)
travel_planner.start()
runner = AgentRunner()
```

The snippets below reuse this `travel_planner` instance to illustrate each mode.

#### 1. Ad-hoc execution with `runner.run(...)`

Use `run` when you want to trigger a durable workflow directly from Python code (tests, CLIs, notebooks, etc.). The runner locates the agent's `@workflow_entry`, schedules it, and optionally waits for completion. Call `travel_planner.start()` first so the workflow runtime is registered.
Use `run` when you want to trigger a durable workflow directly from Python code (tests, CLIs, notebooks, etc.). The runner locates the agent's `@workflow_entry`, schedules it, and optionally waits for completion.

```python
result = await runner.run(
Expand Down Expand Up @@ -520,16 +517,14 @@ frodo = DurableAgent(
)
),
)
frodo.start()

async def main():
runner = AgentRunner()
try:
runner.subscribe(frodo)
await wait_for_shutdown()
finally:
runner.shutdown()
frodo.stop()
runner.shutdown(frodo)

asyncio.run(main())
```
Expand Down Expand Up @@ -570,7 +565,6 @@ llm_orchestrator = LLMOrchestrator(
execution=AgentExecutionConfig(max_iterations=3),
runtime=wf.WorkflowRuntime(),
)
llm_orchestrator.start()

runner = AgentRunner()
runner.serve(llm_orchestrator, port=8004)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ travel_planner = DurableAgent(
)

async def main():
travel_planner.start()
runner = AgentRunner()
try:
result = await runner.run(
Expand All @@ -417,8 +416,7 @@ async def main():
)
print(result)
finally:
runner.shutdown()
travel_planner.stop()
runner.shutdown(travel_planner)

asyncio.run(main())
```
Expand Down