-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
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
When you try to generate with just message_history, The result contains one additional message with no parts and just instructions.
Example Code
from pydantic_ai import Agent
from pydantic_ai.messages import ModelMessagesTypeAdapter
agent = Agent("openai:gpt-4o-mini", instructions="You are an Agent")
messages = [
{
"parts": [
{
"content": "How are you?",
"timestamp": "2025-06-08T14:27:04.870961Z",
"part_kind": "user-prompt",
}
],
"instructions": "You are an Agent",
"kind": "request",
},
]
history = ModelMessagesTypeAdapter.validate_python(messages)
result = agent.run_sync(message_history=history)
print(result.all_messages_json())
# [
# {
# "parts": [
# {
# "content": "How are you?",
# "timestamp": "2025-06-08T14:27:04.870961Z",
# "part_kind": "user-prompt",
# }
# ],
# "instructions": "You are an Agent",
# "kind": "request",
# },
# {"parts": [], "instructions": "You are an Agent", "kind": "request"},
# {
# "parts": [
# {
# "content": "I'm just a program, but thanks for asking! How can I assist you today?",
# "part_kind": "text",
# }
# ],
# "model_name": "gpt-4o-mini-2024-07-18",
# "timestamp": "2025-06-08T14:39:00Z",
# "kind": "response",
# },
# ]Python, Pydantic AI & LLM client version
Python 3.13.2
Pydantic AI >=0.2.14
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working