-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
Having an empty string as a system_prompt will result in a new message added.
This behavior is not consistent with instruction, for which an empty string do not add a new message (last line in instruction documentation).
Example Code
from pydantic_ai import Agent, RunContext
agent = Agent(
'openai:gpt-4o',
system_prompt="something",
)
@agent.system_prompt
def add_nothing() -> str:
return ""
result = agent.run_sync('foo')
print(result.all_messages())Python, Pydantic AI & LLM client version
Python 3.13.3
pydantic-ai 0.6.0