Skip to content

Commit 4233028

Browse files
authored
Update agent.py
1 parent 30f5aef commit 4233028

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/agents/agent.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ def __post_init__(self):
277277
f"Agent model must be a string, Model, or None, got {type(self.model).__name__}"
278278
)
279279

280-
from .model_settings import ModelSettings
281-
282280
if not isinstance(self.model_settings, ModelSettings):
283281
raise TypeError(
284282
f"Agent model_settings must be a ModelSettings instance, "
@@ -309,23 +307,25 @@ def __post_init__(self):
309307
)
310308

311309
if self.hooks is not None:
312-
from .lifecycle import AgentHooks
310+
from .lifecycle import AgentHooksBase
313311

314-
if not isinstance(self.hooks, AgentHooks):
312+
if not isinstance(self.hooks, AgentHooksBase):
315313
raise TypeError(
316314
f"Agent hooks must be an AgentHooks instance or None, "
317315
f"got {type(self.hooks).__name__}"
318316
)
319317

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)
325325
):
326326
raise TypeError(
327327
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__}"
329329
)
330330

331331
if not isinstance(self.reset_tool_choice, bool):

0 commit comments

Comments
 (0)