Skip to content

fix: #3115 block disabled function tools before execution - #3118

Merged
seratch merged 1 commit into
openai:mainfrom
Aphroq:investigate/issue-3115-disabled-tool-execution
May 5, 2026
Merged

seratch merged 1 commit into
openai:mainfrom
Aphroq:investigate/issue-3115-disabled-tool-execution

Conversation

@Aphroq

@Aphroq Aphroq commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This change prevents agent-configured FunctionTools from executing when their dynamic is_enabled callback becomes false after the tool was exposed to the model but before execution starts.

The function tool executor now re-checks the currently enabled agent function tools before creating tool tasks. If the model called an agent-configured tool that is currently disabled, the run fails fast with ModelBehaviorError instead of invoking the tool. The check uses object identity for agent-configured tools so synthetic or adapter-provided FunctionTools that are not present in agent.tools can still execute.

This keeps is_enabled aligned with its documented runtime gating semantics for permissions, feature flags, quotas, tenant policy, and other side-effect-sensitive tool access.

Test plan

  • uv run pytest tests/test_run_step_execution.py -k "disabled_before_execution or non_agent_function_tool" -q
  • uv run pytest tests/test_run_step_execution.py -q
  • bash .agents/skills/code-change-verification/scripts/run.sh

Issue number

Closes #3115

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@github-actions github-actions Bot added bug Something isn't working feature:core labels May 4, 2026
@seratch

seratch commented May 5, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@seratch seratch added this to the 0.15.x milestone May 5, 2026
@seratch
seratch merged commit 7a5d32b into openai:main May 5, 2026
10 checks passed
@Aphroq Aphroq changed the title fix: block disabled function tools before execution fix: #3115 block disabled function tools before execution May 7, 2026
RudrenduPaul pushed a commit to RudrenduPaul/openai-agents-python that referenced this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic function tool is still executed after is_enabled becomes false

2 participants