Update examples (#2300)

This commit is contained in:
Kazuhiro Sera
2026-01-13 12:09:03 +09:00
committed by GitHub
parent da4acc659e
commit f8153b95a2
4 changed files with 46 additions and 6 deletions
+6 -4
View File
@@ -89,11 +89,13 @@ if __name__ == "__main__":
"-t",
"--tool-use-behavior",
type=str,
required=True,
default="default",
choices=["default", "first_tool", "custom"],
help="The behavior to use for tool use. Default will cause tool outputs to be sent to the model. "
"first_tool_result will cause the first tool result to be used as the final output. "
"custom will use a custom tool use behavior function.",
help=(
"The behavior to use for tool use. "
"default sends tool outputs back to the model, first_tool uses the first tool result as the final output, "
"custom runs a custom tool use behavior function."
),
)
args = parser.parse_args()
asyncio.run(main(args.tool_use_behavior))
+1 -1
View File
@@ -18,7 +18,7 @@ Write a poem in {{poem_style}}
4. Run the example with the `--prompt-id` flag.
"""
DEFAULT_PROMPT_ID = "pmpt_6850729e8ba481939fd439e058c69ee004afaa19c520b78b"
DEFAULT_PROMPT_ID = "pmpt_6965a984c7ac8194a8f4e79b00f838840118c1e58beb3332"
class DynamicContext:
@@ -0,0 +1,38 @@
import asyncio
from agents import Agent, Runner, gen_trace_id, trace
from agents.mcp import MCPServerStreamableHttp
async def main():
async with MCPServerStreamableHttp(
name="DeepWiki MCP Streamable HTTP Server",
params={
"url": "https://mcp.deepwiki.com/mcp",
# Allow more time for remote tool responses.
"timeout": 15,
"sse_read_timeout": 300,
},
# Retry slow/unstable remote calls a couple of times.
max_retry_attempts=2,
retry_backoff_seconds_base=2.0,
client_session_timeout_seconds=15,
) as server:
agent = Agent(
name="DeepWiki Assistant",
instructions="Use the tools to respond to user requests.",
mcp_servers=[server],
)
trace_id = gen_trace_id()
with trace(workflow_name="DeepWiki Streamable HTTP Example", trace_id=trace_id):
print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}\n")
result = await Runner.run(
agent,
"For the repository openai/codex, tell me the primary programming language.",
)
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())
+1 -1
View File
@@ -20,7 +20,7 @@ from agents import ModelSettings
from agents.models.interface import ModelTracing
from agents.models.openai_provider import OpenAIProvider
MODEL_NAME = os.getenv("EXAMPLE_MODEL_NAME") or "gpt-5"
MODEL_NAME = os.getenv("REASONING_MODEL_NAME") or "gpt-5"
async def stream_with_reasoning_content():