-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
If Agent is configured with structured output and tools, the additions to system prompt lack space between them.
This is quite clear from source code, lines:
- https://github.com/agno-agi/agno/blob/main/libs/agno/agno/agent/agent.py#L4618
- https://github.com/agno-agi/agno/blob/main/libs/agno/agno/agent/agent.py#L4630
When both of conditions work together, the resulting prompt contains: Do not reflect on the quality of the returned search results in your responseProvide your output as a JSON containing the following fields
IMO any addition to system prompt should be done with assumption that there might be no whitespace at the end of the preceding system prompt.
Steps to Reproduce
Run the provided hermetic test case
Agent Configuration (if applicable)
from agno.agent import Agent
from agno.models.anthropic import Claude
from anthropic.types import Message, Usage, TextBlock
from pydantic import BaseModel
class FakeClaude(Claude):
def invoke(self, *args, **kwargs):
return Message(
content=[TextBlock(text='{"response": "worked"}', type="text")],
id="test1",
model=self.id,
role="assistant",
type="message",
usage=Usage(input_tokens=1, output_tokens=2),
)
class Output(BaseModel):
response: str
def tool():
return "hello"
agent = Agent(model=FakeClaude(), response_model=Output, tools=[tool])
result = agent.run()
print(result.messages[0].content)
assert "responseProvide" not in result.messages[0].content, result.messages[0].content
Expected Behavior
The best is to have "\n\n" before each addition to system prompt, to ensure whitespace and markdown flow.
Actual Behavior
It uses system prompt with "responseProvide" glued together.
Screenshots or Logs (if applicable)
No response
Environment
- OS: Linux
- Agno: 1.7.6 (and master)
Possible Solutions (optional)
No response
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working