@@ -277,8 +277,6 @@ def __post_init__(self):
277
277
f"Agent model must be a string, Model, or None, got { type (self .model ).__name__ } "
278
278
)
279
279
280
- from .model_settings import ModelSettings
281
-
282
280
if not isinstance (self .model_settings , ModelSettings ):
283
281
raise TypeError (
284
282
f"Agent model_settings must be a ModelSettings instance, "
@@ -309,23 +307,25 @@ def __post_init__(self):
309
307
)
310
308
311
309
if self .hooks is not None :
312
- from .lifecycle import AgentHooks
310
+ from .lifecycle import AgentHooksBase
313
311
314
- if not isinstance (self .hooks , AgentHooks ):
312
+ if not isinstance (self .hooks , AgentHooksBase ):
315
313
raise TypeError (
316
314
f"Agent hooks must be an AgentHooks instance or None, "
317
315
f"got { type (self .hooks ).__name__ } "
318
316
)
319
317
320
- if not (
321
- self .tool_use_behavior == "run_llm_again"
322
- or self .tool_use_behavior == "stop_on_first_tool"
323
- or isinstance (self .tool_use_behavior , list )
324
- or callable (self .tool_use_behavior )
318
+ if (
319
+ not (
320
+ isinstance (self .tool_use_behavior , str )
321
+ and self .tool_use_behavior in ["run_llm_again" , "stop_on_first_tool" ]
322
+ )
323
+ and not isinstance (self .tool_use_behavior , dict )
324
+ and not callable (self .tool_use_behavior )
325
325
):
326
326
raise TypeError (
327
327
f"Agent tool_use_behavior must be 'run_llm_again', 'stop_on_first_tool', "
328
- f"a list of tool names , or a callable, got { type (self .tool_use_behavior ).__name__ } "
328
+ f"StopAtTools dict , or callable, got { type (self .tool_use_behavior ).__name__ } "
329
329
)
330
330
331
331
if not isinstance (self .reset_tool_choice , bool ):
0 commit comments