[AAASM-4782] 🐛 (openai_agents): Fail closed on governance error and never downgrade a decided deny - #273
Merged
Conversation
…e a deny Under enforce, a governance error (e.g. GatewayError) from check_tool_start was swallowed and the tool ran ungoverned; the deny branch's audit ran inside the same handler, so a fault there fell through and downgraded a decided deny to an allow. Mirror the other adapters: deny under enforce on a governance fault (fall-open kept for observe/disabled), and guard the deny audit so its failure cannot re-enter the run path. Refs AAASM-4782
…ny integrity Assert under enforce a GatewayError from check_tool_start blocks the tool (S1/S2) and a deny whose audit raises AssemblyError is not downgraded (S6), plus the observe negative control that a governance fault still fails open. Refs AAASM-4782
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
Claude Code — automated reviewCI: green. Scope: matches the ticket. Side effects: none — green full-suite CI (incl. build/lint/impacted tests) validates no existing-function breakage. Front-End: no FE/dashboard code touched → no Playwright validation applies. Verdict: ✅ ready to approve & merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
openai_agentsgoverned_invokewrapped the check-and-deny in a broadtry/exceptthat caught anyAssemblyErrorand then ran the tool unconditionally, with no enforce gate. Two defects:GatewayError) raised bycheck_tool_startwas swallowed, so the tool ran ungoverned even underenforce. Every other adapter (and the shared_shared/tool_governanceflow) fails closed here._record_async_tool_resultbefore returningblocked_result, inside the sametry. If that audit call raised anAssemblyError, the exception was caught and execution fell through to run the tool — turning a computed DENY into an ALLOW.This PR makes
openai_agentsmatch the other 10 adapters:excepthandler, when the error is a governance error and the posture isenforce(via the adapter's existing_interceptor_enforcessignal), it now returns a blocked/deny string instead of falling through to the original invoke. Underobserve/disabledthe current fall-through (fail-open by design) is unchanged._record_denied_tool_resulthelper that swallows any audit failure, so a fault-prone audit call can never re-enter the run path and downgrade a decided deny.Happy path and
observe/disabledbehavior are identical to before.Type of Change
Breaking Changes
Related Issues
Fixes AAASM-4782
Testing
Added regression tests under
test/unit/adapters/openai_agents/:GatewayErrorfromcheck_tool_start→ tool BLOCKED (deny string).record_resultraisesAssemblyError→ tool still BLOCKED (deny not downgraded).observe(no enforce), a governance error still fails open (tool runs), unchanged.How to verify:
Result:
45 passed.ruff check,ruff format --check, andmypy agent_assemblyon the changed files are all clean.Checklist