---
id: object/codeunit/4303
type: object
title: Codeunit 4303 "Agent Task"
summary: Codeunit 4303 "Agent Task" in System Application (System.Agents). 23 public procedures. Introduced in BC25, still in BC30, changed in BC26-29.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: "25"
  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: a419e4bf18832b3c8d9fd8529acaac9553bf852339e73d056fa9ad8662ea9811
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Agent/Interaction/AgentTask.Codeunit.al
    title: src/System Application/App/Agent/Interaction/AgentTask.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: 4303
name: Agent Task
namespace: System.Agents
app: System Application
extends: null
first_version: "25"
last_version: "30"
present_in:
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "26"
  - "27"
  - "28"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 23
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 1
  called_by: 1
  implements: 0
---

# Codeunit 4303 "Agent Task"

> Codeunit 4303 "Agent Task" in System Application (System.Agents). 23 public procedures. Introduced in BC25, still in BC30, changed in BC26-29.

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

## Procedures

- `TaskExists(AgentUserSecurityId: Guid; ExternalId: Text): Boolean`: Check if a task exists for the given agent user and conversation
- `GetTaskByExternalId(AgentUserSecurityId: Guid; ExternalId: Text): Record "Agent Task"`: Get the task for the given agent user and external ID.
- `SetStatusToReady(AgentTaskID: BigInteger)`: Set the status of the task to ready if the task is in the state that it can be started again. The agent task will be be picked up for processing shortly after updating the status.
- `SetStatusToReady(var AgentTask: Record "Agent Task")` (obsolete 29.0: Use the overload that takes AgentTaskID instead.): Set the status of the task to ready if the task is in the state that it can be started again. The agent task will be be picked up for processing shortly after updating the status.
- `CanSetStatusToReady(AgentTaskID: BigInteger): Boolean`: Checks if the task can be set to ready and started again.
- `CanSetStatusToReady(AgentTask: Record "Agent Task"): Boolean`: Checks if the task can be set to ready and started again. The record is not retrieved again; the caller must ensure the record is up to date.
- `StopTask(AgentTaskID: BigInteger; UserConfirm: Boolean)`: Stops the agent task.
- `StopTask(var AgentTask: Record "Agent Task"; UserConfirm: Boolean)` (obsolete 29.0: Use the overload that takes AgentTaskID instead.): Stops the agent task.
- `RestartTask(AgentTaskID: BigInteger; UserConfirm: Boolean)`: Restarts the agent task by setting its status to ready.
- `RestartTask(var AgentTask: Record "Agent Task"; UserConfirm: Boolean)` (obsolete 29.0: Use the overload that takes AgentTaskID instead.): Restarts the agent task by setting its status to ready.
- `IsTaskRunning(AgentTaskID: BigInteger): Boolean`: Checks if the agent task is currently running.
- `IsTaskRunning(var AgentTask: Record "Agent Task"): Boolean`: Checks if the agent task is currently running. The record is not retrieved again; the caller must ensure the record is up to date.
- `IsTaskCompleted(AgentTaskID: BigInteger): Boolean`: Checks if the agent task is completed.
- `IsTaskCompleted(var AgentTask: Record "Agent Task"): Boolean`: Checks if the agent task is completed. The record is not retrieved again; the caller must ensure the record is up to date.
- `IsTaskStopped(AgentTaskID: BigInteger): Boolean`: Checks if the agent task is stopped (by user or system).
- `IsTaskStopped(var AgentTask: Record "Agent Task"): Boolean`: Checks if the agent task is stopped (by user or system). The record is not retrieved again; the caller must ensure the record is up to date.
- `GetCopilotCreditsConsumed(AgentTaskID: BigInteger): Decimal` (obsolete 29.0: Use the methods in the "Agent Consumption Overview" codeunit instead.): Gets the total Copilot credits consumed by the agent task.
- `GetLogEntryDetails(var AgentTaskLogEntry: Record "Agent Task Log Entry"): Text`: Gets the details for the specified agent task log entry.
- `GetStepsDoneCount(AgentTaskID: BigInteger): Integer`: Gets the number of steps done for the specified agent task.
- `OpenAgentTaskLogEntries(AgentTaskID: BigInteger)`: Opens the agent task log entries page for the specified agent task.
- `ArchiveTask(AgentTaskID: BigInteger; UserConfirm: Boolean)`: Archives the agent task.
- `GetModelId(AgentTaskID: BigInteger): Code[30]`: Gets the model ID of the agent task.
- `GetModelName(AgentTaskID: BigInteger): Text[70]`: Gets the model name of the agent task.

## 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 4300 "Agent Task Impl."](../codeunit/4300.md) (14 calls: `ArchiveTask → ArchiveTask`, `CanSetStatusToReady → CanAgentTaskBeSetToReady`, `GetLogEntryDetails → GetDetailsForAgentTaskLogEntry`, …)

## Called by

- [Page 4362 "Agent Task Log Entry Instr"](../page/4362.md) (1 call: `UpdateControls → GetLogEntryDetails`)

## Across versions

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

## Deprecations

- procedure GetCopilotCreditsConsumed: Pending 29.0 (#if not CLEAN29), "Use the methods in the "Agent Consumption Overview" codeunit instead."
- procedure RestartTask: Pending 29.0 (#if not CLEAN29), "Use the overload that takes AgentTaskID instead."
- procedure SetStatusToReady: Pending 29.0 (#if not CLEAN29), "Use the overload that takes AgentTaskID instead."
- procedure StopTask: Pending 29.0 (#if not CLEAN29), "Use the overload that takes AgentTaskID instead."

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")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
