-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore: Throw in Runner.run_async()
if the passed in content doesn't contain role
#2458
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?
chore: Throw in Runner.run_async()
if the passed in content doesn't contain role
#2458
Conversation
Response from ADK Triaging Agent Hello @TanejaAnkisetty, thank you for your contribution! This PR is a bug fix. Could you please associate a GitHub issue with this PR? If there is no existing issue, could you please create one? This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A content without role will also cause invalid event list in session history.
Instead of accommodating this invalid input, I think a better approach would be throw in Runner.run_async
.
Side note: GenAI SDK provides a convenient types.UserContent
class, which is subclass of types.Content with role='user'
preset.
Appreciate the quick response. |
@Jacksunwei - Updated the code to make the input valid by expecting the
|
Runner.run_async()
if the passed in content doesn't contain role
Summary
Verifies that user-provided messages are always passed to the LLM as 'user' role, regardless of whether the role is explicitly set in types.Content. Before the current fix, if the LlmRequest from the user doesn't have the 'user' role, but has the user content, then the text is being replaced with the standard text - "Handle the requests as specified in the System Instruction." and the content from the user is completely ignored and not passed into the LLM.
Code to replicate the problem
Before the fix (current adk-python code output)
After the fix (after resolving the fix)
Testing
Following unit test is created to test the applied changes and added in the location as suggested in the guidelines.
adk-python\tests\unittests\models\test_base_llm.py