Skip to content

Commit 9841c5e

Browse files
authored
Added runtime validation for Agent name field
1 parent 405cddb commit 9841c5e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/agents/agent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ class Agent(Generic[TContext]):
187187
"""Whether to reset the tool choice to the default value after a tool has been called. Defaults
188188
to True. This ensures that the agent doesn't enter an infinite loop of tool usage."""
189189

190+
def __post_init__(self):
191+
if not isinstance(self.name, str):
192+
raise TypeError(f"Agent name must be a string, got {type(self.name).__name__}")
193+
190194
def clone(self, **kwargs: Any) -> Agent[TContext]:
191195
"""Make a copy of the agent, with the given arguments changed. For example, you could do:
192196
```

0 commit comments

Comments
 (0)