登録して招待リンクを共有すると、動画再生報酬と紹介報酬を獲得できます。

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
参加 May 2026
258 フォロー中    220 ファン
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Want to stream progress in real time while a nested agent tool is running? With the `on_stream` callback, you can receive events from child agent executions in real time on the parent side. 📌 Title: Streaming Nested Agent Runs 🔗 URL: 🧩 Overview When converting an agent to a tool with `as_tool()`, you can set a callback function on the `on_stream` parameter. This callback receives `AgentToolStreamEvent` and can process events in real time during child agent execution, including `raw_response_event` and `run_item_stream_event`. The event types mirror the standard streaming format, so you can reuse existing streaming handlers. 🛠 How to use it ```python from agents import Agent, Runner research_agent = Agent( name="researcher", instructions="Research the topic in detail", ) # Streaming callback async def handle_stream(event): # raw_response_event: model responses # run_item_stream_event: tool calls, etc. if hasattr(event, 'data'): print(f"[Researching] {") parent = Agent( name="coordinator", tools=[ research_agent.as_tool( tool_name="research", tool_description="Research a topic", on_stream=handle_stream, ), ], ) # Streamed execution async for event in "Research the latest AI trends"): print(event) ``` 🏗 Building it into production ・Display child agent processing progress in the UI in real time so users never feel stuck waiting ・Use `raw_response_event` to incrementally display generated text ・Log tool execution status via `run_item_stream_event` ・Reuse existing streaming UI components as-is 💡 Use cases 🖥 Real-time UI display of multi-agent processing progress 📝 Typewriter-style incremental display of child agent responses 🔍 Visualizing a research agent's search and analysis process 📊 Providing users with intermediate feedback during long-running tasks ⚠️ Watch out The `on_stream` callback runs within the child agent's execution thread, so heavy processing will impact overall agent performance. Keep event handlers lightweight and consider offloading to an async queue if needed. Add guard clauses to ignore unknown event types for forward compatibility. ✨ With streaming, give users a transparent "see inside" experience for multi-agent workflows. #OpenAIAgentSDK# #AIAgent#
もっと見る