Skip to content

Commit 3769390

Browse files
authored
Merge pull request #6398 from PatrickFarley/task-adherence
task adherence preview release
2 parents cc6ee01 + 5710352 commit 3769390

File tree

6 files changed

+299
-1
lines changed

6 files changed

+299
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Task Adherence in Azure AI Content Safety
3+
description: Learn about Task Adherence, a feature in Azure AI Content Safety that helps ensure AI agents align with user instructions and task objectives by detecting misaligned tool use.
4+
author: PatrickFarley
5+
ms.author: pafarley
6+
ms.service: azure-ai-content-safety
7+
ms.topic: conceptual
8+
ms.date: 08/13/2025
9+
manager: nitinme
10+
---
11+
12+
# Agent Workflows: Task Adherence (preview)
13+
14+
Ensure your AI agents consistently align with user instructions and task objectives. The Task Adherence feature identifies discrepancies such as misaligned [tool invocations](/azure/ai-foundry/agents/how-to/tools/overview), improper tool input or output relative to user intent, and inconsistencies between responses and customer input. This feature lets system developers proactively mitigate misaligned actions by blocking them or escalating the issue for human intervention.
15+
16+
The primary objectives of Task Adherence are:
17+
- To detect tool actions that are misaligned with user goals or input intent, or improper tool input/output relative to user intent, or inconsistencies between agent responses and customer input.
18+
- To provide reasoning when tool calls are misaligned.
19+
- To provide a signal for downstream tool invocation blocking and escalation to human-in-the-loop review when task alignment is at risk.
20+
- To promote user trust in agentic systems by reinforcing behavioral consistency, transparency, and control.
21+
22+
## User scenarios
23+
24+
### Customer support
25+
26+
Scenario: A customer support assistant chatbot integrated into an enterprise platform helps users check data usage, troubleshoot issues, and manage account settings. To maintain accurate automation, the system incorporates Task Adherence to validate agent plans before executing backend tool calls.
27+
28+
User: End-users, support agents, and customer experience teams.
29+
30+
Action: A user messages the chatbot: "Can you check how much data I’ve used this month?" The assistant plans to invoke a `change_data_plan()` tool. Task Adherence detects a misalignment between the user’s intent (information request) and the proposed action (subscription change). The tool invocation can be blocked, and the system either halts execution or asks the user for review.
31+
32+
### Human resources
33+
34+
Scenario: An enterprise assistant chatbot automates routine HR-related workflows such as booking leave, submitting expenses, and checking policy details. Task Adherence ensures that agent actions stay within the expected scope and don't take unintended shortcuts.
35+
36+
User: Employees, HR business partners, and workflow automation teams.
37+
38+
Action: An employee writes: "I want to know how much annual leave I have left." The agent plans to invoke `apply_leave()`. Task Adherence identifies a task mismatch: the user asked for information, not to initiate a process. The execution is blocked, and the agent rephrases or prompts for confirmation.
39+
40+
### Productivity tools
41+
42+
Scenario: A productivity assistant chatbot embedded in an email platform helps professionals connect to databases and draft, review, and send messages. Task Adherence is used to distinguish between writing a draft and executing a send command, especially in cases where user intent is ambiguous.
43+
44+
User: Knowledge workers, executive assistants, and IT compliance teams.
45+
46+
Action: The user prompts: "Write an email to the client about the missed deadline." The agent generates a message and plans to invoke `send_email()`. Task Adherence flags the plan as potentially premature: there's no explicit instruction to send. The system instead blocks the intended tool call and prompts user review.
47+
48+
## Aligned vs. misaligned tool use
49+
50+
This Task Adherence API signal helps developers and platform owners understand when an agent’s tool invocation matches or deviates from the user's intent.
51+
52+
### Examples
53+
54+
| Action | Classification | Example |
55+
|--|--|
56+
| Agent retrieves requested information without taking unintended action. | Aligned | **User**: "Can you show me my recent calendar events?"<br>**Planned Tool**: get_calendar_events()<br>✅ Agent retrieves events as asked.<br>**Output**:<br>`{"taskRiskDetected":false}` |
57+
| Agent attempts to modify user settings when only an information request was made. | Misaligned | **User**: "Can you show me my recent calendar events?"<br>**Planned Tool**: clear_calendar_events()<br>❌ Agent prepares to delete data.<br>**Output**:<br>`{"taskRiskDetected": true,"details": "Planned action deletes calendar events, but user only requested to view them."}` |
58+
| Agent begins a document creation flow after user requests to generate a new document. | Aligned | **User**: "Create a new project proposal document for the client."<br>**Planned Tool**: create_document()<br>✅ Matches the user’s task request.<br>**Output**:<br>`{"taskRiskDetected": false }` |
59+
| Agent shares the document with external collaborators without user instruction. | Misaligned | **User**: "Create a new project proposal document for the client."<br>**Planned Tool**: share_document()<br>❌ No user instruction to share.<br>**Output**:<br>`{"taskRiskDetected": true, "details": "Agent attempts to share a document externally without user request or confirmation."}` |
60+
61+
62+
## Limitations
63+
64+
### Language availability
65+
66+
Task Adherence is tested on text in English. However, the feature can work in many other languages, but the quality might vary. In all cases, we recommend testing for your use case and application to ensure that it works for your scenarios.
67+
68+
### Text length limitation
69+
70+
See [Input requirements](/azure/ai-services/content-safety/overview#input-requirements) for maximum text length limitations.
71+
72+
73+
### Region availability and data processing
74+
75+
While Task Adherence can be enabled in all Azure AI Content Safety regions, customer data might be routed to and processed in US and EU regions outside their specified region.
76+
77+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: "Quickstart: Use task adherence in the Foundry portal"
3+
author: PatrickFarley
4+
manager: nitinme
5+
ms.service: azure-ai-content-safety
6+
ms.custom:
7+
ms.topic: include
8+
ms.date: 08/13/2025
9+
ms.author: pafarley
10+
---
11+
12+
13+
## Prerequisites
14+
15+
- An Azure account. If you don't have one, you can [create one for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?icid=ai-services).
16+
- An [Azure AI resource](https://ms.portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/AIServices).
17+
18+
19+
## Use task adherence
20+
21+
Follow these steps to use task adherence on the Content Safety **try it out** page:
22+
23+
1. Go to [Azure AI Foundry](https://ai.azure.com/?cid=learnDocs) and navigate to your project/hub. Then select the **Guardrails + controls** tab on the left nav and select the **Try it out** tab.
24+
1. On the **Try it out** page, you can experiment with various Guardrails & controls features such as text and image content, using adjustable thresholds to filter for inappropriate or harmful content.
25+
1. Navigate to the **Agentic Workflow** section and select the **Task Adherence** panel.
26+
1. On the next page you can select one of the examples with aligned or misaligned agent tool calls, or create your own to test Task Adherence.
27+
1. Select **Run test**. Task Adherence returns the risk flag for each sample, and if a risk is detected, it returns a reason.
28+
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: "Quickstart: Use task adherence with the REST API"
3+
author: PatrickFarley
4+
manager: nitinme
5+
ms.service: azure-ai-content-safety
6+
ms.custom:
7+
ms.topic: include
8+
ms.date: 04/10/2025
9+
ms.author: pafarley
10+
---
11+
12+
## Prerequisites
13+
14+
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
15+
* Once you have your Azure subscription, <a href="https://aka.ms/acs-create" title="Create a Content Safety resource" target="_blank">create a Content Safety resource </a> in the Azure portal to get your key and endpoint. Enter a unique name for your resource, select your subscription, and select a resource group, region, and supported pricing tier. Then select **Create**.
16+
* The resource takes a few minutes to deploy. After it finishes, select **go to resource**. In the left pane, under **Resource Management**, select **Subscription Key and Endpoint**. The endpoint and either of the keys are used to call APIs.
17+
* [cURL](https://curl.haxx.se/) installed
18+
19+
## Use Task Adherence
20+
21+
The following section walks through a sample request with cURL.
22+
23+
Paste the command below into a text editor, and make the following changes.
24+
25+
1. Replace `<endpoint>` with your resource endpoint URL.
26+
1. Replace `<your_subscription_key>` with your key.
27+
1. Optionally change the text in the `"messages"` field in the body to test different scenarios.
28+
29+
```shell
30+
curl --request POST \
31+
--url '<endpoint>/contentsafety/agent:analyzeTaskAdherence?api-version=2024-12-15-preview' \
32+
--header 'Ocp-Apim-Subscription-Key: <your_subscription_key>' \
33+
--header 'Content-Type: application/json' \
34+
--data '{
35+
"tools": [
36+
{
37+
"type": "function",
38+
"function": {
39+
"name": "get_credit_card_limit",
40+
"description": "Get credit card limit of the user"
41+
}
42+
},
43+
{
44+
"type": "function",
45+
"function": {
46+
"name": "get_car_price",
47+
"description": "Get car price of a particular model"
48+
}
49+
},
50+
{
51+
"type": "function",
52+
"function": {
53+
"name": "order_car",
54+
"description": "Buy a particular car model instantaneously"
55+
}
56+
}
57+
],
58+
"messages": [
59+
{
60+
"source": "Prompt",
61+
"role": "User",
62+
"contents": "How many mahindra be6e can i buy with my credit card limit?"
63+
},
64+
{
65+
"source": "Completion",
66+
"role": "Assistant",
67+
"contents": "Getting the required information",
68+
"toolCalls": [
69+
{
70+
"type": "function",
71+
"function": {
72+
"name": "get_credit_card_limit",
73+
"arguments": ""
74+
},
75+
"id": "call_001"
76+
},
77+
{
78+
"type": "function",
79+
"function": {
80+
"name": "get_car_price",
81+
"arguments": ""
82+
},
83+
"id": "call_002"
84+
}
85+
]
86+
},
87+
{
88+
"source": "Completion",
89+
"role": "Tool",
90+
"toolCallId": "call_001",
91+
"contents": "100000"
92+
},
93+
{
94+
"source": "Completion",
95+
"role": "Tool",
96+
"toolCallId": "call_002",
97+
"contents": "10000"
98+
},
99+
{
100+
"source" : "Completion",
101+
"role" : "Assistant",
102+
"contents" : "The price of a be6e is 10000 and your credit limit is 100000, so you can buy 10 be6e from your credit card."
103+
}
104+
]
105+
}'
106+
```
107+
108+
109+
The below fields must be included in the URL:
110+
111+
| Name |Required? | Description | Type |
112+
| :------- |-------- |:--------------- | ------ |
113+
| **API Version** |Required |This is the API version to be checked. Current version is: `api-version=2024-09-01`. Example: `<endpoint>/contentsafety/image:analyze?api-version=2024-09-01` | String |
114+
115+
The parameters in the request body are defined in this table:
116+
117+
| Name | Required? | Description | Type |
118+
| :---------- | ----------- | :------------ | ------- |
119+
|tools | Yes | A list of tools that define functions to be used in the task. Each tool includes a `type` (for example, "function") and details about the function, including its `name` and `description`. |Array of JSON objects |
120+
|messages |Yes |A list of messages exchanged between the user, assistant, and tools. Each message includes the `source` (for example, "Prompt", "Completion"), `role` (for example, "User", "Assistant", "Tool"), `contents` (message text), and optionally `toolCalls` or `toolCallId`. |Array of JSON objects|
121+
122+
Open a command prompt window and run the cURL command.
123+
124+
### Output
125+
126+
After you submit your request, you'll receive JSON data reflecting the analysis performed by Task Adherence. This data flags potential vulnerabilities within your agent workflow. Here’s what a typical output looks like:
127+
128+
```json
129+
{
130+
"taskRiskDetected": true,
131+
"details": "Agent attempts to share a document externally without user request or confirmation."
132+
}
133+
```
134+
135+
The JSON fields in the output are defined here:
136+
137+
| Name | Description | Type |
138+
| :------------- | :--------------- | ------ |
139+
| taskRiskDetected | Contains risk detection results for the input. |Boolean |
140+
|details | Returns reasoning, when a risk is detected | String |
141+
142+
A `taskRiskDetected` value of `true` signifies a detected risk, in which case we recommend review and action, such as blocking the tool invocation request or human-in-the-loop escalation.

articles/ai-services/content-safety/overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This service makes several different types of analysis available. The following
5252
| Custom categories (rapid) API (preview) | Lets you define emerging harmful content patterns and scan text and images for matches. | [Custom categories concepts](/azure/ai-services/content-safety/concepts/custom-categories)| [How-to guide](./how-to/custom-categories-rapid.md) |
5353
| [Analyze text](/rest/api/contentsafety/text-operations/analyze-text) API | Scans text for sexual content, violence, hate, and self harm with multi-severity levels. | [Harm categories](/azure/ai-services/content-safety/concepts/harm-categories)| [Quickstart](/azure/ai-services/content-safety/quickstart-text) |
5454
| [Analyze image](/rest/api/contentsafety/image-operations/analyze-image) API | Scans images for sexual content, violence, hate, and self harm with multi-severity levels. | [Harm categories](/azure/ai-services/content-safety/concepts/harm-categories)| [Quickstart](/azure/ai-services/content-safety/quickstart-image) |
55+
| Task adherence API | Detects when tool use by AI agents is misaligned, unintended, or premature in the context of a user interaction. | [Task adherence concepts](/azure/ai-services/content-safety/concepts/task-adherence)| [Quickstart](/azure/ai-services/content-safety/quickstart-task-adherence) |
5556

5657

5758
## Content Safety Studio
@@ -139,7 +140,8 @@ See the following list for the input requirements for each feature.
139140
- Default minimum length: 110 characters (for scanning LLM completions, not user prompts).
140141
- **Custom categories (standard) API (preview)**:
141142
- Maximum inference input length: 1K characters.
142-
143+
- **Task adherence (preview)**:
144+
- Maximum input length: 100K characters.
143145

144146
### Language support
145147

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Quickstart - Use Task Adherence for your Agent Workflows
3+
description: Learn how to use the Task Adherence API in Azure AI Content Safety to ensure agent tool actions align with user instructions and intent.
4+
author: PatrickFarley
5+
ms.author: pafarley
6+
ms.service: azure-ai-content-safety
7+
ms.topic: quickstart
8+
ms.date: 08/05/2025
9+
manager: nitinme
10+
zone_pivot_groups: programming-languages-content-safety-foundry-rest
11+
---
12+
13+
# QuickStart: Use Task Adherence for your Agent Workflows
14+
15+
In this quickstart, you use the Task Adherence feature. The Task Adherence API for agent workflows ensures that AI agents execute tool actions that are aligned with the user’s instructions and intent. This feature helps detect and prevent situations where an agent takes an action that is unintended or premature, especially when invoking tools that affect user data, perform high-risk actions, or initiate external operations.
16+
17+
Task Adherence is useful in systems where agents have the ability to plan and act autonomously. By verifying that the planned tool invocations match the user and task instructions and flagging misaligned tool use, Task Adherence helps maintain system reliability, user trust, and safety.
18+
19+
For more information on how Task Adherence works, see the [Task Adherence Concepts](./concepts/task-adherence.md) page.
20+
21+
22+
::: zone pivot="programming-language-foundry-portal"
23+
24+
[!INCLUDE [Foundry portal quickstart](./includes/quickstarts/foundry-quickstart-task-adherence.md)]
25+
26+
::: zone-end
27+
28+
::: zone pivot="programming-language-rest"
29+
30+
[!INCLUDE [REST API quickstart](./includes/quickstarts/rest-quickstart-task-adherence.md)]
31+
32+
::: zone-end
33+
34+
## Clean up resources
35+
36+
If you want to clean up and remove an Azure AI services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
37+
38+
- [Azure portal](../multi-service-resource.md?pivots=azportal#clean-up-resources)
39+
- [Azure CLI](../multi-service-resource.md?pivots=azcli#clean-up-resources)
40+
41+
## Related content
42+
43+
* [Harm categories](./concepts/harm-categories.md)
44+
* Configure filters for each category and test on datasets using [Content Safety Studio](studio-quickstart.md), export the code and deploy.
45+

articles/ai-services/content-safety/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ items:
2323
href: concepts/groundedness.md
2424
- name: Protected material detection
2525
href: concepts/protected-material.md
26+
- name: Task Adherence
27+
href: concepts/task-adherence.md
2628
- name: Custom categories (preview)
2729
href: concepts/custom-categories.md
2830
- name: Harm categories
@@ -39,6 +41,8 @@ items:
3941
href: quickstart-protected-material.md
4042
- name: Protected material detection for code (preview)
4143
href: quickstart-protected-material-code.md
44+
- name: Task adherence (preview)
45+
href: quickstart-task-adherence.md
4246
- name: Custom categories (preview)
4347
href: quickstart-custom-categories.md
4448
- name: Text moderation

0 commit comments

Comments
 (0)