-
Notifications
You must be signed in to change notification settings - Fork 578
feat(openai-agents): Set system instruction attribute on gen_ai.chat spans
#5370
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: webb/openai-responses-system-instruction
Are you sure you want to change the base?
feat(openai-agents): Set system instruction attribute on gen_ai.chat spans
#5370
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Openai
Openai Agents
Other
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| non_system_messages = [ | ||
| message for message in messages if not _is_system_instruction(message) | ||
| ] |
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.
Missing string input handling causes AttributeError crash
Medium Severity
The _set_input_data function declares messages can be str | list[TResponseInputItem] but doesn't handle strings. When messages is a string, the list comprehension iterates over individual characters, and line 168 then calls message.get("type") on each character, raising AttributeError: 'str' object has no attribute 'get'. The OpenAI integration's _set_responses_api_input_data handles this correctly with an if isinstance(messages, str): check that wraps the string and returns early.
Additional Locations (1)
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.
The code throws an exception when passed a string before, so I consider this out of scope.
The type is correct and we should fix this later on, but in practice the patched function is called with a list in code paths from Agent.run().
Description
Revert 54034dc and set system instruction attributes on
gen_ai.chatspans instead ofgen_ai.invoke_agentspans.Re-uses functions from setting system instructions in
OpenAIIntegration, sinceopenai-agentsuses a Responses API compatible input schema.Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)