Skip to content

Adding tool input and output guardrails - #1792

Merged
rm-openai merged 4 commits into
openai:mainfrom
steven10a:dev/steven/tool_guardrails
Sep 26, 2025
Merged

rm-openai merged 4 commits into
openai:mainfrom
steven10a:dev/steven/tool_guardrails

Conversation

@steven10a

@steven10a steven10a commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor
  • This PR was started from PR 1606: Tool Guardrails
  • It adds input and output guardrails at the tool level which can trigger ToolInputGuardrailTripwireTriggered and ToolOutputGuardrailTripwireTriggered exceptions
  • It includes updated documentation, a runnable example, and unit tests
  • make check and unit tests all pass

Edits since last review:

  • Extracted nested tool running logic in _run_impl.py
  • Added rejecting tool call or tool call output and returning a message to the model (rather than only raising an exception)
  • Added the tool guardrail results to the RunResult
  • Removed docs

Comment thread src/agents/tool_guardrails.py Resolved
Comment thread src/agents/_run_impl.py Resolved
Comment thread src/agents/tool_guardrails.py Resolved
Comment thread docs/guardrails.md Resolved
Comment thread examples/basic/tools.py Resolved
@seratch seratch added enhancement New feature or request feature:core labels Sep 24, 2025
@steven10a
steven10a force-pushed the dev/steven/tool_guardrails branch from 03962fa to 55c949a Compare September 25, 2025 14:22
@steven10a
steven10a requested a review from rm-openai September 25, 2025 15:59

@rm-openai rm-openai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants