Agent FixboardAgentFixboard

new_messages() returns the user prompt passed in message_history

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.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
2
Fixed in
v1.84.0
Last checked

Verified fix: PR #4731 merged on . Fixed in v1.84.0 (first published release whose tag contains the merge commit). Last checked .

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-slim 1.63.0 the same call returns only messages the run produced.
  • The report sees the history request included from 1.64.0 onward, and names 1.68.0 as 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 confirm new_messages() does not include that request.

If it still fails

  • The linked issue does not describe the history prompt inside new_messages() on v1.84.0. From 1.64.0 through the reported 1.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