bcquality/community/knowledge/agents/bind-agent-subscribers-only-in-agent-session.md
Jesper Schulz-Wedde 2b5550c346
Some checks failed
Validate knowledge index / validate-index (push) Has been cancelled
Validate AL review fixtures / validate-review-fixtures (push) Has been cancelled
Validate frontmatter and structure / validate (push) Has been cancelled
Improve partner onboarding and documentation navigation (#174)
Lead with a complete plugin quick start and add task-oriented usage, troubleshooting, customization, and contribution guides. Preserve the broader plugin framing, correct conflicting contract guidance, support Agents folder reviews, and align repository validation. Convert existing sample references to clickable links without changing knowledge rules.

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-09 17:31:03 +02:00

1.3 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.