Skip to content

docs(guardrails): add pre-execution policy example#3425

Closed
EfeDurmaz16 wants to merge 1 commit into
openai:mainfrom
EfeDurmaz16:docs/tool-pre-execution-policy
Closed

docs(guardrails): add pre-execution policy example#3425
EfeDurmaz16 wants to merge 1 commit into
openai:mainfrom
EfeDurmaz16:docs/tool-pre-execution-policy

Conversation

@EfeDurmaz16
Copy link
Copy Markdown

Summary

This adds a concrete tool input guardrail example for pre-execution policy checks, following the current recommended extension point for validating a local function tool call immediately before invocation.

The example shows a payment policy guardrail that checks the exact requested tool payload before charge_card executes:

  • tool name allowlist
  • merchant allowlist
  • amount limit
  • model-visible rejection via reject_content

It also calls out the important boundary that Python-side tool input guardrails apply to local function tools, not hosted tools that execute server-side.

Closes #2970.

Verification

  • uv run python -m py_compile examples/basic/tool_policy_guardrail.py
  • uv run ruff check examples/basic/tool_policy_guardrail.py
  • uv run pyright examples/basic/tool_policy_guardrail.py
  • uv run pytest tests/test_tool_guardrails.py
  • git diff --check

Note: uv run mkdocs build --strict currently fails on existing repository-wide i18n/autoref warnings unrelated to this change.

@seratch
Copy link
Copy Markdown
Member

seratch commented May 16, 2026

Thanks for the suggestion, but we already cover the tool guardrail patterns in the docs.

@seratch seratch closed this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pre-execution validation for tool calls

2 participants