Skip to content

Commit

Permalink
Fix: Properly await agent.run() in README Hello World example (#5013
Browse files Browse the repository at this point in the history
)

* 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]>
  • Loading branch information
Programmer-RD-AI and ekzhu authored Jan 12, 2025
1 parent 9f351c5 commit 5e2a69a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from autogen_ext.models.openai import OpenAIChatCompletionClient

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

asyncio.run(main())
```
Expand Down
2 changes: 1 addition & 1 deletion python/packages/autogen-core/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ from autogen_ext.models.openai import OpenAIChatCompletionClient

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

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

0 comments on commit 5e2a69a

Please sign in to comment.