BCQuality rule · agentsCopilot & Agentsofficial - Microsoftderived - from the source, no model text

Bind extra agent subscribers only inside an agent session

Page-filter tweaks, extra validation, and prompt dialogs for the agent should not run for every user. Agent Session.IsAgentSession distinguishes agent UI sessions. Binding those subscribers on System Initialization only when the session is an agent session avoids global subscriber cost.

Rule on GitHub · community layer · agents · BC 27.. · tier official · derived

Description

Page-filter tweaks, extra validation, and prompt dialogs for the agent should not run for every user. Agent Session.IsAgentSession distinguishes agent UI sessions. Binding those subscribers on System Initialization only when the session is an agent session avoids global subscriber cost. Models register SingleInstance table subscribers unconditionally.

Best Practice

On OnAfterInitialization, exit unless Agent Session.IsAgentSession. Then BindSubscription a single-instance codeunit that holds the current task id. Keep those subscribers internal.

See sample: bind-agent-subscribers-only-in-agent-session.good.al.

Anti Pattern

Event subscribers on Sales Header OnAfterInsert that always Message the agent, with no IsAgentSession guard. Detection signal: agent-only behaviour in a static subscriber that is not bind-gated.

See sample: bind-agent-subscribers-only-in-agent-session.bad.al.

Examples

Names

Changed by


From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).