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_indexonv1.63.0. On1.41.0the 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