Skip to content

Commit 5e2a69a

Browse files
Fix: Properly await agent.run() in README Hello World example (microsoft#5013)
* Fix: Properly await `agent.run()` in README `Hello World` example - Updated the `Hello World` code sample to use `asyncio` for proper coroutine handling. - Resolved `RuntimeWarning` caused by not awaiting the `agent.run()` method. - Ensures the example executes correctly without errors or warnings. * Add await to agent.run call in index.md * Fix hello world --------- Co-authored-by: Eric Zhu <[email protected]>
1 parent 9f351c5 commit 5e2a69a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ from autogen_ext.models.openai import OpenAIChatCompletionClient
3434

3535
async def main() -> None:
3636
agent = AssistantAgent("assistant", OpenAIChatCompletionClient(model="gpt-4o"))
37-
print(agent.run(task="Say 'Hello World!'"))
37+
print(await agent.run(task="Say 'Hello World!'"))
3838

3939
asyncio.run(main())
4040
```

python/packages/autogen-core/docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ from autogen_ext.models.openai import OpenAIChatCompletionClient
119119

120120
async def main() -> None:
121121
agent = AssistantAgent("assistant", OpenAIChatCompletionClient(model="gpt-4o"))
122-
print(agent.run(task="Say 'Hello World!'"))
122+
print(await agent.run(task="Say 'Hello World!'"))
123123

124124
asyncio.run(main())
125125
```

0 commit comments

Comments
 (0)