-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Question
PydanticAI now enforces message history to start with user message. It is a new feature that arrived in 1.21.0 (#3440) and for me it's a breaking change. Do we really need this feature?
My use cases:
I. I've got a chatbot that starts a conversation by welcoming the user. In other words I generate the first, message and put it into the conversation history as an assistant's message (ModelResponse). The welcome message may include questions that are important for the further conversation.
With the feature that enforces conversations to start with the user message I will have to:
- inject the initial bot's message to the system_prompt / instructions instead of putting it into the conversation
- still send the welcome message to the user but omitting the conversation
- change the UI logic that is based on simply displaying the conversation history - because it will miss the initial message
This means that what is logically a conversation (assistant's message, user response, ...) is no longer a conversation in the backend.
Alternatively I can insert a fake user message into the conversation start and then filter it out where I don't need it.
II. Message processing / summarizing agents will need to always generate a fake user message (ModelRequest) that will prepend the ModelResponse with the actual summary.
Like: https://github.com/RooCodeInc/Roo-Code/pull/4150/files
I know it's due to bedrock but shouldn't this feature be:
a) optional / bedrock only
b) marked as a breaking one (at least it broke my code :) )
c) removed - if only bedrock requires it then bedrock users may simply ensure that their conversations start with User message. At the moment users of other APIs (like OpenAI) are forced to do it even though these APIs allow that.
Additional Context
pydanticai 1.21.0