@@ -111,6 +111,12 @@ class Handoff(Generic[TContext]):
111
111
agent and returns whether the handoff is enabled. You can use this to dynamically enable/disable
112
112
a handoff based on your context/state."""
113
113
114
+ should_return_control : bool = False
115
+ """Whether the Agent that receives control during a handoff should return control to the
116
+ original (previous) Agent upon completion of its work. If False, after the Agent that received
117
+ the handoff completes its work, the interaction will end.
118
+ """
119
+
114
120
def get_transfer_message (self , agent : Agent [Any ]) -> str :
115
121
return json .dumps ({"assistant" : agent .name })
116
122
@@ -135,6 +141,7 @@ def handoff(
135
141
input_filter : Callable [[HandoffInputData ], HandoffInputData ] | None = None ,
136
142
should_return_control : bool = False ,
137
143
is_enabled : bool | Callable [[RunContextWrapper [Any ], Agent [Any ]], MaybeAwaitable [bool ]] = True ,
144
+ should_return_control : bool = False ,
138
145
) -> Handoff [TContext ]: ...
139
146
140
147
@@ -149,6 +156,7 @@ def handoff(
149
156
input_filter : Callable [[HandoffInputData ], HandoffInputData ] | None = None ,
150
157
should_return_control : bool = False ,
151
158
is_enabled : bool | Callable [[RunContextWrapper [Any ], Agent [Any ]], MaybeAwaitable [bool ]] = True ,
159
+ should_return_control : bool = False ,
152
160
) -> Handoff [TContext ]: ...
153
161
154
162
@@ -162,6 +170,7 @@ def handoff(
162
170
input_filter : Callable [[HandoffInputData ], HandoffInputData ] | None = None ,
163
171
should_return_control : bool = False ,
164
172
is_enabled : bool | Callable [[RunContextWrapper [Any ], Agent [Any ]], MaybeAwaitable [bool ]] = True ,
173
+ should_return_control : bool = False ,
165
174
) -> Handoff [TContext ]: ...
166
175
167
176
@@ -174,6 +183,7 @@ def handoff(
174
183
input_filter : Callable [[HandoffInputData ], HandoffInputData ] | None = None ,
175
184
should_return_control : bool = False ,
176
185
is_enabled : bool | Callable [[RunContextWrapper [Any ], Agent [Any ]], MaybeAwaitable [bool ]] = True ,
186
+ should_return_control : bool = False ,
177
187
) -> Handoff [TContext ]:
178
188
"""Create a handoff from an agent.
179
189
@@ -258,4 +268,5 @@ async def _invoke_handoff(
258
268
agent_name = agent .name ,
259
269
should_return_control = should_return_control ,
260
270
is_enabled = is_enabled ,
271
+ should_return_control = should_return_control ,
261
272
)
0 commit comments