chore: Moving some agent utils to utils file - #12238
Open
sjrl wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
julian-risch
requested changes
Aug 4, 2026
julian-risch
left a comment
Member
There was a problem hiding this comment.
Changes look good to me in general. Only thing is that now no tests check that Agent still calls _validate_prompt_message_blocks.
I suggest that we add the following two tests back to TestPrompts in test_agent.py. Up to you if we just check for ValueError raised or if we match the message too. WDYT?
def test_prompt_wrong_role_raises_at_init(self, make_agent):
with pytest.raises(ValueError, match="system_prompt message block must have role 'system'"):
make_agent(system_prompt=_user_msg("This is a user message, not system."))
with pytest.raises(ValueError, match="user_prompt message block must have role 'user'"):
make_agent(user_prompt=_sys_msg("This is a system message, not user."))def test_dynamic_prompt_role_raises_at_runtime(self, make_agent):
agent = make_agent(user_prompt="{% message role=role_name %}Q: {{question}}{% endmessage %}")
with pytest.raises(ValueError, match="user_prompt must render to a user message"):
agent.run(messages=[], role_name="assistant", question="Will it snow?")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
Some maintenance work to move some of the accumulated util functions in the
agents.pyto theutils.pyfile. The methods are all private so no risk of breaking imports.How did you test it?
Moved tests as well to
test_utils.pyNotes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.