Agent FixboardAgentFixboard

new_messages() loses messages when a history processor trims the current run

A history processor that keeps only the last few messages makes result.new_messages() return those last messages, not everything the run added. The report's new_message_index goes 0 → -2 → -4 → -6.

From GitHub

pydantic/pydantic-ai

Difficulty
Easy
Time
~5 min
Steps
1
Fixed in
v1.63.0
Last checked

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

Symptom

A history processor that keeps only the last few messages makes result.new_messages() return those last messages, not everything the run added. The report's new_message_index goes 0 → -2 → -4 → -6.

Evidence what you'll see

  • The processor in the report keeps the last 4 messages, and the run makes several tool calls.
  • Negative indexes then silently slice the list instead of raising.

Why it happens

new_messages() found the start of the run by subtracting the number of removed messages from a list index. That overshoots when the processor removes messages created in the current run.

Affected versions

Pydantic AI 1.41.0, Python 3.12. The linked issue does not name an operating system.

Fix steps

0 of 1 done

Your check marks stay in this browser only.

How to check it worked

  • Run with a keep-last-4 history processor and several tool calls, and confirm new_messages() starts at the first message of this run that is still in history.

If it still fails

  • The linked issue does not describe a negative new_message_index on v1.63.0. On 1.41.0 the index keeps falling.

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