-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: enforce message history starts with user message #3440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: enforce message history starts with user message #3440
Conversation
Add validation in UserPromptNode to raise UserError if message history starts with ModelResponse, ensuring conversations begin with a user message (ModelRequest) Include comprehensive tests for invalid history, valid history, empty history, multiple messages, and validation after message cleaning to prevent issues with malformed conversation logs
aaee6e4 to
6ef2b8c
Compare
Note on
|
Only keep the test that verifies the exception is raised. The non-exception behavior is already tested by existing tests. Addresses review feedback from @DouweM on PR pydantic#3440
|
Thanks for the review @DouweM! I've removed the redundant tests and kept only Changes made:
All tests and pre-commit checks pass locally. Ready for re-review! |
|
@DouweM CI failures are from Temporal server errors (temporal.download returning 500), not this PR. All agent tests pass. The Temporal download issue should resolve soon. |
Closes #2992
Summary
Adds validation to prevent message history from starting with
ModelResponse, which causes provider API errors (e.g., Bedrock: "conversation must start with user message").Changes
_agent_graph.pyafter message cleaning (line 218)UserErrorbefore invalid history reaches providerTesting
UserErroris raised when history starts withModelResponseRelated
ModelResponsemessage #2992