๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
279 ํŒ”๋กœ์ž‰ ์ค‘    408 ํŒฌ
# Practical and Useful Patterns for OpenAI Agent SDK ๐ŸŒ How you orchestrate multiple agents determines the quality and reliability of your entire system. Master LLM-driven and code-driven patterns to build the right architecture for each use case. ๐Ÿ“Œ Title: Agent orchestration ๐Ÿ”— URL: ๐Ÿงฉ Overview Multi-agent orchestration comes in two flavors: LLM-driven (the model dynamically decides routing via handoffs) and code-driven (Python code explicitly controls the flow). Combined with the Manager pattern (`as_tool`) and handoff-based delegation, these patterns let you build anything from open-ended research assistants to deterministic content pipelines. ๐Ÿ›  Usage For LLM-driven orchestration, define `Agent(name="researcher", handoffs=[web_search_agent, code_exec_agent])` and let the model dynamically choose. For code-driven pipelines, define `researcher`, `outliner`, `writer`, and `critic` agents, then in `blog_pipeline(topic)` call `await input=...)` followed by `await input= + [...])` and `await input=...)` sequentially. The generate-evaluate loop uses `for i in range(3)` to have the `critic` review, breaking if `"no issues"` is found, otherwise sending feedback back to `writer`. For parallel execution, use `asyncio.gather(*[ input=data) for a in agents])` to run sentiment, topic, and summary analyses concurrently. The Manager pattern uses `Agent(name="manager", tools=[ to call child agents as tools while retaining control. ๐Ÿ— Practical Patterns **LLM-Driven โ€” Open-Ended Tasks** Equip a research agent with web search, file search, code execution, and specialist handoffs. The LLM dynamically selects the best approach based on context. Ideal for "investigate this technology" type queries where you can't predetermine the flow. **Code-Driven โ€” Deterministic Pipelines** When steps are known upfront (research, outline, write, critique, improve), define the pipeline explicitly in Python. Each step's output can be programmatically validated and branched, giving you much tighter quality control. **Generate-Evaluate Loop** Use a `while`/`for` loop to repeatedly generate and evaluate until quality criteria are met. A critic agent reviews output until it passes โ€” achieving quality that single-shot generation can't match. Always set a maximum iteration count. **Parallel Execution with asyncio.gather** Run independent tasks (sentiment analysis, topic extraction, summarization) concurrently with `asyncio.gather`. Dramatically reduces latency compared to sequential execution. **Manager Pattern (as_tool) vs Handoff** `as_tool` keeps the Manager in control โ€” it calls child agents as tools and gets results back to synthesize. Use this when you need to combine outputs from multiple specialists. Handoffs transfer control entirely โ€” use this when the specialist should handle the rest of the conversation independently. ๐Ÿ’ก Use Cases ๐Ÿ”ฌ Research investigation (LLM-driven with dynamic web/paper/code analysis selection) ๐Ÿ“ Content creation pipeline (code-driven: research, write, review, improve) โšก Parallel data analysis (asyncio.gather for sentiment/topic/summary) ๐Ÿ‘” Manager pattern (synthesize analysis team results into a unified report) โš ๏ธ Caveats - LLM-driven patterns are flexible but may produce unnecessary handoffs or tool calls due to model judgment errors. Use code-driven control for critical flows. - Always set a maximum iteration count on generate-evaluate loops. Unbounded loops cause runaway token costs. - When using `asyncio.gather` for parallel execution, consider `return_exceptions=True` so one task's failure doesn't cancel others. - Child agents called via `as_tool` return results as text to the Manager. Specify `output_type` if you need structured data. โœจ Combine LLM-driven and code-driven orchestration to build the optimal multi-agent architecture for each use case! #OpenAIAgentSDK# #AIAgent#
๋” ๋ณด๊ธฐ