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

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 the tool's output to be the final answer, but the model keeps adding unnecessary summaries? With `tool_use_behavior`, you can make tool output the final result directly, stop at specific tools, or customize output handling with fine-grained control. ๐Ÿ“Œ Title: tool_use_behavior ๐Ÿ”— URL: ๐Ÿงฉ Overview `tool_use_behavior` controls what happens after an agent calls a tool. Setting `"stop_on_first_tool"` makes the first tool's output the final result. `StopAtTools(stop_at_tool_names=[...])` limits this behavior to specific tools. You can also pass a custom function that returns `ToolsToFinalOutputResult(is_final_output=True, final_output=...)` to transform the output before finalizing it. ๐Ÿ›  How to use it ```python from agents import Agent, StopAtTools, ToolsToFinalOutputResult # First tool output becomes the final result agent_direct = Agent( name="direct", tools=[search_tool], tool_use_behavior="stop_on_first_tool", ) # Stop only on specific tools agent_selective = Agent( name="selective", tools=[search_tool, format_tool, send_tool], tool_use_behavior=StopAtTools( stop_at_tool_names=["format_tool"] ), ) # Custom function for output control def custom_behavior(context, tool_results): result = tool_results[0] if result.tool_name == "get_answer": return ToolsToFinalOutputResult( is_final_output=True, final_output=f"Answer: {result.output}", ) return ToolsToFinalOutputResult(is_final_output=False) agent_custom = Agent( name="custom", tools=[get_answer, search_tool], tool_use_behavior=custom_behavior, ) ``` ๐Ÿ— Building it into production ใƒปUse `"stop_on_first_tool"` for proxy-style agents that return API results directly ใƒปFinalize output at specific pipeline steps to reduce unnecessary LLM calls ใƒปStandardize output format with custom functions for stable downstream integration ใƒปPass structured data (JSON, etc.) directly to subsequent processing without model summarization ๐Ÿ’ก Use cases ๐Ÿ”Œ Proxy agents returning API results as-is ๐Ÿ“Š Direct output of database query results ๐Ÿ”„ Output finalization at pipeline intermediate steps ๐ŸŽฏ Selective control to use only specific tool results as final output โš ๏ธ Watch out With `"stop_on_first_tool"`, the model won't interpret or supplement results. If user-friendly output is needed, use a custom function. Also verify behavior when multiple tools are called in parallel. โœจ With `tool_use_behavior`, take agent output from "model decides" to "by design." #OpenAIAgentSDK# #AIAgent#
๋” ๋ณด๊ธฐ