bcquality/community/knowledge/agents/bind-agent-subscribers-only-in-agent-session.md
Stefano Demiliani 53e2cf2fa4
Add community guidance and review support for Business Central agents (#137)
* feat(community/agents): add AL agent quality guidance

- add 20 agent knowledge rules with good and bad AL samples
- clarify setup dialog shape, temporary persistence, permissions, profiles, instructions, capability registration, and interface wiring
- add the community-owned AL agents review skill
- make review fixture discovery layer-aware with custom, community, and Microsoft precedence
- document layer-aware evaluation behavior

* fix(community/agents): align setup and permission samples

- mark agent setup pages as non-extensible where required
- narrow the agent profile by hiding an unrelated sales-order field
- define a dedicated read-only permission set for the sales review agent
- assign AL-defined permission sets with system scope and the owning app ID
- clarify the permission scope guidance for default access controls

* Address agent review feedback
2026-09-02 16:06:25 +02:00

1.2 KiB

bc-version domain keywords technologies countries application-area
27..
agents
agent-session
isagentsession
bindsubscription
system-initialization
singleinstance
al
w1
all

Bind extra agent subscribers only inside an agent session

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.