From d60c78d30f3281b1be4614f696428506d7e97dc8 Mon Sep 17 00:00:00 2001 From: mutahirshah11 Date: Thu, 10 Jul 2025 21:14:51 +0500 Subject: [PATCH 1/2] fix(docs): add missing await in streaming example --- docs/streaming.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/streaming.md b/docs/streaming.md index b2c7c095d..41f6c9032 100644 --- a/docs/streaming.md +++ b/docs/streaming.md @@ -21,7 +21,7 @@ async def main(): instructions="You are a helpful assistant.", ) - result = Runner.run_streamed(agent, input="Please tell me 5 jokes.") + result = await Runner.run_streamed(agent, input="Please tell me 5 jokes.") async for event in result.stream_events(): if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): print(event.data.delta, end="", flush=True) @@ -54,7 +54,7 @@ async def main(): tools=[how_many_jokes], ) - result = Runner.run_streamed( + result = await Runner.run_streamed( agent, input="Hello", ) From e327a6a8fcee68e6cf3e1da732400ce6562f067b Mon Sep 17 00:00:00 2001 From: mutahirshah11 Date: Fri, 11 Jul 2025 19:53:30 +0500 Subject: [PATCH 2/2] Improved example function for better clarity and realism. --- docs/tools.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tools.md b/docs/tools.md index 6dba1a853..16ab3ce1d 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -191,8 +191,8 @@ from agents import RunContextWrapper, FunctionTool -def do_some_work(data: str) -> str: - return "done" +def process_user_data(username: str, age: int) -> str: + return f"{username} is {age} years old ." class FunctionArgs(BaseModel): @@ -202,7 +202,7 @@ class FunctionArgs(BaseModel): async def run_function(ctx: RunContextWrapper[Any], args: str) -> str: parsed = FunctionArgs.model_validate_json(args) - return do_some_work(data=f"{parsed.username} is {parsed.age} years old") + return process_user_data(parsed.username , parsed.age) tool = FunctionTool(