Symptom
agent.run() with message_history and no user_prompt makes result.new_messages() include the ModelRequest from that history. The user prompt in the report is hi.
Evidence what you'll see
- On
pydantic-ai-slim1.63.0the same call returns only messages the run produced. - The report sees the history request included from
1.64.0onward, and names1.68.0as the version they were on.
Why it happens
A request resumed from message_history carried the current run's run_id, so new_messages() counted it as new.
Affected versions
Pydantic AI 1.68.0, Python 3.12. The change starts at 1.64.0. The linked issue does not name an operating system.
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- Run with
message_history=[ModelRequest(parts=[UserPromptPart(content="hi")])]and confirmnew_messages()does not include that request.
If it still fails
- The linked issue does not describe the history prompt inside
new_messages()onv1.84.0. From1.64.0through the reported1.68.0, it is included.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it