Skip to content

Stop policy execution after rejection#34

Draft
Copilot wants to merge 2 commits intoallow-multiple-policiesfrom
copilot/sub-pr-32-again
Draft

Stop policy execution after rejection#34
Copilot wants to merge 2 commits intoallow-multiple-policiesfrom
copilot/sub-pr-32-again

Conversation

Copy link

Copilot AI commented Nov 17, 2025

The policy execution loop invoked all policies in the array even after one called reject(). While the rejected flag prevented controller execution, subsequent policies still ran and could cause side effects.

Changes

  • Added early termination check in the policy execution loop to break when this.rejected is true
for (let i = 0; i < this.policyList.length; i++) {
  if (this.rejected) {
    break;
  }
  
  const name = this.policyList[i];
  // ... rest of policy invocation
}

This ensures that in a policy chain like ['correctPolicy', 'rejectingPolicy', 'secondPolicy'], only the first two policies execute when rejectingPolicy rejects.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: charliemitchell <8126582+charliemitchell@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feedback on allowing multiple policies implementation Stop policy execution after rejection Nov 17, 2025
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.

2 participants