Skip to content

fix: check require_approval field instead of mcp_server in ApprovalFilter isinstance check#5288

Open
jaideepr97 wants to merge 12 commits intollamastack:mainfrom
jaideepr97:fix/approval-filter-isinstance-bug
Open

fix: check require_approval field instead of mcp_server in ApprovalFilter isinstance check#5288
jaideepr97 wants to merge 12 commits intollamastack:mainfrom
jaideepr97:fix/approval-filter-isinstance-bug

Conversation

@jaideepr97
Copy link
Copy Markdown
Contributor

@jaideepr97 jaideepr97 commented Mar 25, 2026

This bug was identified and patched by Claude during a systematic audit of the Responses API code paths.

Summary

  • Fix _approval_required() to check isinstance(mcp_server.require_approval, ApprovalFilter) instead of isinstance(mcp_server, ApprovalFilter)
  • Access .always/.never on mcp_server.require_approval instead of mcp_server
  • Add regression tests covering all require_approval modes ("always", "never", and ApprovalFilter with both lists)

The previous code checked isinstance(mcp_server, ApprovalFilter), but mcp_server is an OpenAIResponseInputToolMCP, so the check was always False. The ApprovalFilter.always and .never lists were dead code — every tool defaulted to requiring approval regardless of configuration.

Closes #5287

Test plan

  • New unit tests in test_approval_filter_bug.py (7 tests covering all branches)
  • Existing tests/unit/providers/inline/agents/builtin/responses/ suite passes (8/8)
$ uv run pytest tests/unit/providers/inline/agents/builtin/responses/ -v
=============================== 8 passed in 0.02s ===============================

Made with Cursor

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 25, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

This pull request has merge conflicts that must be resolved before it can be merged. @jaideepr97 please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 25, 2026
…lter isinstance check

The _approval_required() method checked isinstance(mcp_server, ApprovalFilter)
but mcp_server is an OpenAIResponseInputToolMCP, so the check was always False.
This made the ApprovalFilter.always and .never lists dead code — every tool
defaulted to requiring approval regardless of filter configuration.

Fix by checking isinstance(mcp_server.require_approval, ApprovalFilter) and
accessing .always/.never on the require_approval field.

Closes llamastack#5287

Signed-off-by: Jaideep Rao <jrao@redhat.com>
Made-with: Cursor
@jaideepr97 jaideepr97 force-pushed the fix/approval-filter-isinstance-bug branch from a0aea1a to d181118 Compare March 25, 2026 16:39
Update test imports to use the new module paths after upstream renamed
providers/inline/agents/ to providers/inline/responses/.

Signed-off-by: Jaideep Rao <jrao@redhat.com>
Made-with: Cursor
@mergify mergify bot removed the needs-rebase label Mar 25, 2026
Signed-off-by: Jaideep Rao <jrao@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ApprovalFilter for MCP tools is non-functional — never list is ignored, all tools require approval

2 participants