---
id: change/bcapps/14527
type: change
title: "#14527 Don't reuse a Payables Agent user that has no permissions in the company"
summary: Payables Agent setup now verifies that a reused agent user has permissions in the current company before attempting to reuse it, preventing task failures when a company is deleted and recreated with the same name.
tier: official
language: en
tags:
  - fix
  - main
  - bc30
  - codeunit pa setup
system: copilot
review:
  state: reviewed
  by: opus
  at: "2026-11-27T01:03:39.433Z"
  flags: []
generated:
  at: "2026-12-06T00:14:19.053Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: 8e490a7b17d19122c1031369cbf82097cf65cfa9
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/14527
    title: "microsoft/BCApps#14527: Don't reuse a Payables Agent user that has no permissions in the company"
    date: "2026-11-26"
    commit: 8e490a7b17d19122c1031369cbf82097cf65cfa9
    t: null
    quote: The setup found it by that name and reused it, but its permissions belonged to the deleted company.
links:
  learn: []
  objects:
    - object/codeunit/3343
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/dev-itpro/ai/ai-development-toolkit-permissions
      title: Agent permissions (preview)
      label: possibly related
      why: Agent permissions configuration to ensure Payables Agent users have proper company access
      by: model
number: 14527
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/14527
kind: pr
base_branch: main
major: "30"
merged_at: "2026-11-26T23:12:33Z"
author: Explorer986
author_type: User
community_contribution: false
labels:
  - "AL: Apps (W1)"
  - "Team: Finance"
change_class: code
change_kind: fix
behavior_change: true
breaking: false
files:
  count: 1
  additions: 18
  deletions: 1
  al: 1
apps:
  - PayablesAgent
objects_touched:
  - key: codeunit/3343
    page: codeunit/3343
    type: codeunit
    id: 3343
    name: PA Setup
    app: PayablesAgent
    status: modified
objects_unjoined: []
obsoletions: []
backports:
  - number: 14673
    base: releases/29.x
    url: https://github.com/microsoft/BCApps/pull/14673
fixes_issues: []
work_items:
  - 640641
systems:
  - copilot
quote: The setup found it by that name and reused it, but its permissions belonged to the deleted company.
joined_against:
  major: "30"
  commit: 4d60d10920084a35a6231e5a0ffbd0577b0c399e
---

# #14527 Don't reuse a Payables Agent user that has no permissions in the company

> Payables Agent setup now verifies that a reused agent user has permissions in the current company before attempting to reuse it, preventing task failures when a company is deleted and recreated with the same name.

[Pull request](https://github.com/microsoft/BCApps/pull/14527) · merged into `main` (BC30) on 2026-11-26 by Explorer986 · 1 file (+18 -1), 1 AL · fix · tier official · reviewed (checked by Opus)

## What changed

- Agent user lookup by name now includes a permissions check for the current company
- If an agent user lacks permissions in the current company, a new agent is created instead of reused
- Uses the same permissions verification the agent framework runs before accepting tasks
- Agents already linked in company setup continue to work as before
- Resolves task failures with 'agent has no access control permissions' error after company recreation
- Behaviour changes for users or extensions.

## AL objects touched

- [Codeunit 3343 "PA Setup"](../../objects/codeunit/3343.md), PayablesAgent: modified

## Also merged into

- [#14673](https://github.com/microsoft/BCApps/pull/14673) into `releases/29.x` on 2026-11-30

## Context

- Work items: AB#640641
- Labels: AL: Apps (W1), Team: Finance
- Systems: copilot
- From the description: "The setup found it by that name and reused it, but its permissions belonged to the deleted company."

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Agent permissions (preview)](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/ai/ai-development-toolkit-permissions) — possibly related: Agent permissions configuration to ensure Payables Agent users have proper company access (model-linked)

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
