- Notifications
You must be signed in to change notification settings - Fork17
Agent conversation handling#45
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Pull Request Overview
This PR refactors the guardrails agent integration to improve concurrency and consistency. The key change is moving from stage-based guardrail batching to individual guardrail execution, allowing the Agents SDK to run guardrails concurrently and improving observability.
- Refactored
_create_agents_guardrails_from_configto create one function per guardrail instead of one per stage - Added
_extract_text_from_inputhelper to handle multiple input formats from the Agents SDK - Simplified stage names and improved error reporting consistency
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/guardrails/agents.py | Core refactoring: creates individual guardrail functions instead of stage-based functions, adds text extraction helper, simplifies stage naming |
| examples/basic/agents_sdk.py | Adds PII guardrail example and debug code for testing guardrail metadata |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
gabor-openai left a comment
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.
TY
f95ae68 intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Agent guardrail client was not properly extracting the last user message before sending to guardrails. Instead the entire conversation history was being passed. This caused an error with the moderation endpoint which expected a string.
The fix:
datafieldAdditionally updated the Agent response to include the full output info dict returned by the guardrails (seedocs for what each check returns)
Guardrail metadata can be accessed when not raised as an exception via the run response with
result.new_items[0].agent.input_guardrailsor...output_guardrailsWhen triggered and raised
exc.guardrail_result.inputor...outputNote: This is for accessing agent-level guardrail which are all guardrails except
Prompt Injection Detectionwhich is run as a tool-level guardrail. Currently, to access the tool-level guardrail results you can useresult.tool_output_guardrail_results[0].output.output_infoorexc.output.output_infowhen raised. It will provide the full metadata when a guardrail is triggered. But if the guardrail passes it will only provide"<guardrail_name> check passed". Modifying that behavior will require a PR to the Agents SDK repo