Skip to content

Commit f8153b9

Browse files
authored
Update examples (#2300)
1 parent da4acc6 commit f8153b9

4 files changed

Lines changed: 46 additions & 6 deletions

File tree

examples/agent_patterns/forcing_tool_use.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ async def main(tool_use_behavior: Literal["default", "first_tool", "custom"] = "
8989
"-t",
9090
"--tool-use-behavior",
9191
type=str,
92-
required=True,
92+
default="default",
9393
choices=["default", "first_tool", "custom"],
94-
help="The behavior to use for tool use. Default will cause tool outputs to be sent to the model. "
95-
"first_tool_result will cause the first tool result to be used as the final output. "
96-
"custom will use a custom tool use behavior function.",
94+
help=(
95+
"The behavior to use for tool use. "
96+
"default sends tool outputs back to the model, first_tool uses the first tool result as the final output, "
97+
"custom runs a custom tool use behavior function."
98+
),
9799
)
98100
args = parser.parse_args()
99101
asyncio.run(main(args.tool_use_behavior))

examples/basic/prompt_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
4. Run the example with the `--prompt-id` flag.
1919
"""
2020

21-
DEFAULT_PROMPT_ID = "pmpt_6850729e8ba481939fd439e058c69ee004afaa19c520b78b"
21+
DEFAULT_PROMPT_ID = "pmpt_6965a984c7ac8194a8f4e79b00f838840118c1e58beb3332"
2222

2323

2424
class DynamicContext:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import asyncio
2+
3+
from agents import Agent, Runner, gen_trace_id, trace
4+
from agents.mcp import MCPServerStreamableHttp
5+
6+
7+
async def main():
8+
async with MCPServerStreamableHttp(
9+
name="DeepWiki MCP Streamable HTTP Server",
10+
params={
11+
"url": "https://mcp.deepwiki.com/mcp",
12+
# Allow more time for remote tool responses.
13+
"timeout": 15,
14+
"sse_read_timeout": 300,
15+
},
16+
# Retry slow/unstable remote calls a couple of times.
17+
max_retry_attempts=2,
18+
retry_backoff_seconds_base=2.0,
19+
client_session_timeout_seconds=15,
20+
) as server:
21+
agent = Agent(
22+
name="DeepWiki Assistant",
23+
instructions="Use the tools to respond to user requests.",
24+
mcp_servers=[server],
25+
)
26+
27+
trace_id = gen_trace_id()
28+
with trace(workflow_name="DeepWiki Streamable HTTP Example", trace_id=trace_id):
29+
print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}\n")
30+
result = await Runner.run(
31+
agent,
32+
"For the repository openai/codex, tell me the primary programming language.",
33+
)
34+
print(result.final_output)
35+
36+
37+
if __name__ == "__main__":
38+
asyncio.run(main())

examples/reasoning_content/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from agents.models.interface import ModelTracing
2121
from agents.models.openai_provider import OpenAIProvider
2222

23-
MODEL_NAME = os.getenv("EXAMPLE_MODEL_NAME") or "gpt-5"
23+
MODEL_NAME = os.getenv("REASONING_MODEL_NAME") or "gpt-5"
2424

2525

2626
async def stream_with_reasoning_content():

0 commit comments

Comments
 (0)