From e37f2ba2a563de4b4f10e3516eae08e04e7b7fe1 Mon Sep 17 00:00:00 2001 From: MurtazaAliCode Date: Fri, 1 Aug 2025 16:18:07 +0500 Subject: [PATCH] Update agent.py --- src/agents/agent.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/agents/agent.py b/src/agents/agent.py index c6f25b08f6..cdcf947951 100644 --- a/src/agents/agent.py +++ b/src/agents/agent.py @@ -221,6 +221,14 @@ class Agent(AgentBase, Generic[TContext]): """Whether to reset the tool choice to the default value after a tool has been called. Defaults to True. This ensures that the agent doesn't enter an infinite loop of tool usage.""" + def __post_init__(self): + if self.instructions is not None and not ( + isinstance(self.instructions, str) or callable(self.instructions) + ): + raise TypeError( + f"The 'instructions' must be a string or a callable, but received {type(self.instructions).__name__}." + ) + def clone(self, **kwargs: Any) -> Agent[TContext]: """Make a copy of the agent, with the given arguments changed. For example, you could do: ```