bcquality/community/knowledge/agents/do-not-create-agents-in-install-upgrade-or-background.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.4 KiB

bc-version domain keywords technologies countries application-area
27..
agents
agent-create
install
upgrade
job-queue
interactive-session
background
al
w1
all

Do not create agent instances from install, upgrade, or background sessions

Description

Agent.Create requires an interactive user session. The platform blocks creation from install codeunits, upgrade codeunits, and background sessions (job queue, scheduled tasks). Packaging an agent in an app does not mean spinning up instances at install. Models still call Create from OnInstallAppPerCompany to activate the agent.

Best Practice

Create instances from a setup page, a wizard, or another UI-driven path after the user is in a client session. Apply instructions and Activate there. For existing companies after an upgrade, document that an admin must open setup; do not create from the upgrade codeunit.

See sample: do-not-create-agents-in-install-upgrade-or-background.good.al.

Anti Pattern

Agent.Create inside OnInstallAppPerCompany, OnUpgradePerCompany, or a job-queue codeunit. The call fails at runtime even if it compiles. Detection signal: Agent.Create in Subtype = Install, Subtype = Upgrade, or a non-UI session.

See sample: do-not-create-agents-in-install-upgrade-or-background.bad.al.