-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandoff-gpt5-to-gemini.py
More file actions
45 lines (37 loc) · 1.19 KB
/
handoff-gpt5-to-gemini.py
File metadata and controls
45 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from agents import Agent, ModelSettings, Runner, function_tool, handoff, set_default_openai_api
from agents.extensions.models.litellm_model import LitellmModel
from openai.types.shared import Reasoning
@function_tool
def echo_tool(input: str) -> str:
return input
@function_tool
def speak_tool(input: str) -> str:
return input
@function_tool
def final_tool(input: str) -> str:
return input
gemini_model = LitellmModel(
model="gemini/gemini-3-pro-preview"
)
agent1 = Agent(
name="Gemini Agent",
instructions="You are a helpful assistant",
model=gemini_model,
tools=[echo_tool, speak_tool, final_tool],
model_settings=ModelSettings(reasoning=Reasoning(effort="low"))
)
agent2 = Agent(
name="OpenAI Agent",
instructions="You are a helpful assistant",
model="gpt-5-mini",
tools=[echo_tool, speak_tool, final_tool],
model_settings=ModelSettings(reasoning=Reasoning(effort="low")),
handoffs=[ handoff(agent1, nest_handoff_history=False) ]
)
result = Runner.run_sync(
agent2, "handoff to Gemini Agent, then use echo_tool and speak_tool"
)
print("--------------------------------")
print(result.final_output)
print("----------")
print(result.to_input_list())