You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an Agent is used as part of a team in another Agent, it cannot have an illegal character in the name property when using OpenAIChat as model, as this causes a crash. An 'illegal' character is defined as one that does not match this regex: ^[a-zA-Z0-9_-]+$, e.g. &
Note that the issue does not reproduce when an Agent has an illegal character in the name and is used directly, i.e. print_response is called on it. The issue only reproduces when that Agent is on a team of another Agent. (see notes at end of ticket)
Steps to Reproduce
Create an Agent with at least one character in the name property that does not match this regex: ^[a-zA-Z0-9_-]+$, e.g. use a &
Add this Agent in the team list of a second Agent
Call print_response(...) on the second Agent
Agent Configuration (if applicable)
Here is a complete example to reproduce the issue, based closely on the simplest example from your docs:
fromagno.agentimportAgentfromagno.models.openaiimportOpenAIChatagent_news_reporter=Agent(
name="News Reporter &",
model=OpenAIChat(id="gpt-4"),
description="You are an enthusiastic news reporter with a flair for storytelling!",
markdown=True
)
agent_team=Agent(
name="News Team",
team=[agent_news_reporter],
model=OpenAIChat(id="gpt-4"),
markdown=True
)
agent_team.print_response("Tell me about a breaking news story from New York.", stream=True)
Expected Behavior
The Agent runs as normal, running the Agent team and generating output successfully.
Actual Behavior
The Agent crashes with fatal error from OpenAI API.
Screenshots or Logs (if applicable)
Console output with crash stack trace:
▰▰▰▰▱▱▱ Thinking...
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Tell me about a breaking news story from New York. ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Traceback (most recent call last):
File "error_agent_name.py", line 18, in <module>
agent_team.print_response("Tell me about a breaking news story from New York.", stream=True)
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/agno/agent/agent.py", line 3285, in print_response
for resp in self.run(
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/agno/agent/agent.py", line 537, in _run
for model_response_chunk in self.model.response_stream(messages=run_messages.messages):
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/agno/models/openai/chat.py", line 700, in response_stream
for response in self.invoke_stream(messages=messages):
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/agno/models/openai/chat.py", line 340, in invoke_stream
yield from self.get_client().chat.completions.create(
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/openai/_utils/_utils.py", line 279, in wrapper
return func(*args, **kwargs)
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/openai/resources/chat/completions.py", line 863, in create
return self._post(
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/openai/_base_client.py", line 1283, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/openai/_base_client.py", line 960, in request
return self._request(
File "~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/openai/_base_client.py", line 1064, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid 'tools[0].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': 'tools[0].function.name', 'code': 'invalid_value'}}
Note that stack trace file paths modified to protect privacy, otherwise as outputted by system.
Environment
OS: macOS 14.6.1 (23G93)
Browser
Agno Version: 1.0.8
External Dependency Versions: openai 1.61.1
Additional Environment Details: Python 3.9.6, using pyenv
Possible Solutions (optional)
I would guess that you are filtering out 'illegal' characters that are disallowed by the OpenAI API, but this is not happening when there is an Agent within an Agent.
Additional Context
It may be somewhat reasonable to reject this issue since the regex is right there in the error message. However I would encourage a fix for two reasons:
It is not at all clear that it is the Agent.name that is causing the issue, in fact the error is misleading in Invalid 'tools[0].function.name': string does not match pattern. .... I had originally thought it originated with tool use in the actual project I'm working on, and it took a good amount of bisecting to find it
Perhaps most importantly, the issue does not reproduce for an Agent not on a team, which means either you are dealing with this case for an Agent used directly, or it is not picked by the OpenAI API due to the differing structuring of the calls, if that happens (I don't quite know how you're doing this and haven't looked too far under the hood)
For completeness, here is a complete example that has the illegal character but does not reproduce, as I said above in point 2:
fromagno.agentimportAgentfromagno.models.openaiimportOpenAIChatagent_news_reporter=Agent(
name="News Reporter &",
model=OpenAIChat(id="gpt-4"),
description="You are an enthusiastic news reporter with a flair for storytelling!",
markdown=True
)
agent_news_reporter.print_response("Tell me about a breaking news story from New York.", stream=True)
Thanks for your work, I hope this helps.
The text was updated successfully, but these errors were encountered:
Description
If an
Agent
is used as part of a team in anotherAgent
, it cannot have an illegal character in thename
property when usingOpenAIChat
as model, as this causes a crash. An 'illegal' character is defined as one that does not match this regex:^[a-zA-Z0-9_-]+$
, e.g.&
Note that the issue does not reproduce when an
Agent
has an illegal character in the name and is used directly, i.e.print_response
is called on it. The issue only reproduces when thatAgent
is on a team of anotherAgent
. (see notes at end of ticket)Steps to Reproduce
Agent
with at least one character in thename
property that does not match this regex:^[a-zA-Z0-9_-]+$
, e.g. use a&
Agent
in theteam
list of a secondAgent
print_response(...)
on the second AgentAgent Configuration (if applicable)
Here is a complete example to reproduce the issue, based closely on the simplest example from your docs:
Expected Behavior
The
Agent
runs as normal, running theAgent
team and generating output successfully.Actual Behavior
The
Agent
crashes with fatal error from OpenAI API.Screenshots or Logs (if applicable)
Console output with crash stack trace:
Note that stack trace file paths modified to protect privacy, otherwise as outputted by system.
Environment
BrowserPossible Solutions (optional)
I would guess that you are filtering out 'illegal' characters that are disallowed by the OpenAI API, but this is not happening when there is an
Agent
within anAgent
.Additional Context
It may be somewhat reasonable to reject this issue since the regex is right there in the error message. However I would encourage a fix for two reasons:
Agent.name
that is causing the issue, in fact the error is misleading inInvalid 'tools[0].function.name': string does not match pattern. ...
. I had originally thought it originated with tool use in the actual project I'm working on, and it took a good amount of bisecting to find itAgent
not on a team, which means either you are dealing with this case for anAgent
used directly, or it is not picked by the OpenAI API due to the differing structuring of the calls, if that happens (I don't quite know how you're doing this and haven't looked too far under the hood)For completeness, here is a complete example that has the illegal character but does not reproduce, as I said above in point 2:
Thanks for your work, I hope this helps.
The text was updated successfully, but these errors were encountered: