---
id: object/codeunit/4315
type: object
title: Codeunit 4315 "Agent Task Builder"
summary: Codeunit 4315 "Agent Task Builder" in System Application (System.Agents). 12 public procedures. Introduced in BC26, still in BC30, changed in BC27-29.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: "26"
  last_changed: "29"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: d5fa5afc1a74fff42764450ccd8fa6117f3122dfac17748afcf84c68065017b8
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al
    title: src/System Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 4315
name: Agent Task Builder
namespace: System.Agents
app: System Application
extends: null
first_version: "26"
last_version: "30"
present_in:
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "27"
  - "28"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 12
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 2
  called_by: 5
  implements: 0
---

# Codeunit 4315 "Agent Task Builder"

> Codeunit 4315 "Agent Task Builder" in System Application (System.Agents). 12 public procedures. Introduced in BC26, still in BC30, changed in BC27-29.

System Application · System.Agents · BC26-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Agent/Interaction/AgentTaskBuilder.Codeunit.al) · facts from BC29

## Procedures

- `Initialize(NewAgentUserSecurityId: Guid; NewTaskTitle: Text[150]): codeunit "Agent Task Builder"`: Initialize the agent task builder with the mandatory parameters.
- `Create(): Record "Agent Task"`: Create a new task for the agent.
- `Create(SetTaskStatusToReady: Boolean): Record "Agent Task"`: Create a new task for the agent.
- `Create(SetTaskStatusToReady: Boolean; RequiresMessage: Boolean): Record "Agent Task"`: Create a new task for the agent.
- `GetAgentTaskMessageCreated(): Record "Agent Task Message"`: Get the agent task message that was created.
- `SetExternalId(ExternalId: Text[2048]): codeunit "Agent Task Builder"`: Set the external ID of the task.
- `SetModelId(ModelId: Code[30]): codeunit "Agent Task Builder"`: Set the model ID that will be used to process the task. If the model ID is not set, the model from the agent will be used, if any. If the agent does not have a model, the default model will be used.
- `SetBillingContext(BillingContext: Enum "Agent Task Billing Context"): codeunit "Agent Task Builder"`: Set the billing context for the task.
- `AddTaskMessage(From: Text[250]; MessageText: Text): codeunit "Agent Task Builder"`: Add a task message to the task. Only a single message can be added to the task.
- `AddTaskMessage(var AgentTaskMessageBuilder: Codeunit "Agent Task Message Builder"): codeunit "Agent Task Builder"`: Add a task message to the task. Only a single message can be added to the task.
- `GetTaskMessageBuilder(): Codeunit "Agent Task Message Builder"`: Get the agent task message builder.
- `TaskExists(AgentUserSecurityId: Guid; ConversationId: Text): Boolean`: Check if a task exists for the given agent user and conversation

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 4310 "Agent Task Builder Impl."](../codeunit/4310.md) (8 calls: `AddTaskMessage → AddTaskMessage`, `Create → Create`, `GetAgentTaskMessageCreated → GetAgentTaskMessageCreated`, …)
- [Codeunit 4300 "Agent Task Impl."](../codeunit/4300.md) (1 call: `TaskExists → TaskExists`)

## Called by

- [Codeunit 4582 "SOA Retrieve Emails"](../codeunit/4582.md) (4 calls: `AddEmailToAgentTask → TaskExists`, `AddEmailToNewAgentTask → Create`, `AddEmailToNewAgentTask → GetAgentTaskMessageCreated`, …)
- [Codeunit 4361 "Agent Task Template"](../codeunit/4361.md) (3 calls: `RepeatTask → AddTaskMessage`, `RepeatTask → Create`, `RepeatTask → Initialize`)
- [Page 4359 "Agent New Task Message"](../page/4359.md) (3 calls: `CreateNewTask → AddTaskMessage`, `CreateNewTask → Create`, `CreateNewTask → Initialize`)
- [Codeunit 4415 "SOA Create Task Impl"](../codeunit/4415.md) (2 calls: `CreateTask → Create`, `CreateTask → Initialize`)
- [Codeunit 3303 "Payables Agent"](../codeunit/3303.md) (1 call: `BuildAgentTask → Initialize`)

## Across versions

- Present in: BC26-30
- Changed (declaration) in: BC27-29

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Agent Task Builder")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
