Skip to content

Commit 660577b

Browse files
authored
Merge pull request #313607 from MicrosoftDocs/release-sre-agent
[RELEASE PUBLISH] [SRE Agent] Sync to generated content
2 parents 569bfb0 + 25de378 commit 660577b

133 files changed

Lines changed: 5715 additions & 1403 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Azure DevOps connector in Azure SRE Agent
3+
description: Connect Azure DevOps for source code analysis, work item management, and wiki knowledge with OAuth or managed identity authentication.
4+
ms.topic: conceptual
5+
ms.service: azure-sre-agent
6+
ms.date: 03/16/2026
7+
author: craigshoemaker
8+
ms.author: cshoe
9+
ms.ai-usage: ai-assisted
10+
#customer intent: As an SRE, I want to understand Azure DevOps connector capabilities so that I can decide which connector type and authentication method to use for my team's needs.
11+
---
12+
13+
# Azure DevOps connector in Azure SRE Agent
14+
15+
Connect Azure DevOps so your agent can search your code, create work items, and index your wiki as a knowledge source.
16+
17+
> [!TIP]
18+
> **Quick overview**
19+
>
20+
> - Two connector types: **Azure DevOps OAuth** for live code and work items, **Documentation connector** for wiki knowledge.
21+
> - OAuth supports **User account** (Microsoft Entra ID) and **Managed identity** authentication.
22+
> - A single connector covers your entire Azure DevOps organization, including all projects and repos.
23+
> - Wiki content is indexed for semantic search and autosyncs every 24 hours.
24+
25+
## Two connector types
26+
27+
Azure DevOps has two connector types because they serve different purposes.
28+
29+
| Connector | What it does | Auth options |
30+
|---|---|---|
31+
| **Azure DevOps OAuth** | Live source code access, work items, pipelines, semantic code search | User account (OAuth) or Managed identity |
32+
| **Documentation connector** | Indexes wiki pages and docs into a searchable knowledge base | Managed identity or PAT |
33+
34+
You can use both together. Use the OAuth connector for live code investigations and the documentation connector for wiki-based knowledge.
35+
36+
## Azure DevOps OAuth connector
37+
38+
The OAuth connector gives your agent live access to source code, work items, and pipelines across your entire Azure DevOps organization.
39+
40+
### Authentication types
41+
42+
Choose the authentication method that fits your team's needs.
43+
44+
| Method | How it works | Best for |
45+
|---|---|---|
46+
| **User account** | Sign in with your Microsoft Entra ID account. The agent accesses Azure DevOps through your permissions. Tokens refresh automatically. | The interactive setup is recommended for most users |
47+
| **Managed identity** | Use the agent's managed identity to authenticate. Supports Federated Identity Credentials (FIC) for cross-tenant access. | Automated setup, service accounts, cross-tenant access |
48+
49+
> [!TIP]
50+
> **OAuth tokens refresh automatically**
51+
>
52+
> Azure DevOps OAuth tokens expire after approximately one hour, but your agent refreshes them automatically before expiration using a 5-minute buffer. Each refresh generates a new refresh token, creating a self-sustaining renewal chain. Your connector stays connected through multihour investigations with no manual reauthentication required.
53+
>
54+
> **When you need to reauthenticate:** if the refresh token expires (lifetime varies by Microsoft Entra ID policy), if an admin revokes the app authorization, or if you set up your connector before version 26.2.247.0 (one reauthentication enables autorefresh going forward).
55+
56+
### What the agent can do
57+
58+
The OAuth connector gives your agent the following capabilities.
59+
60+
**Source code analysis:**
61+
62+
- Search code across all repos in your organization by using the Azure DevOps Search API.
63+
- Read file contents by path and branch.
64+
- Correlate Azure resource errors with source code locations (with confidence scoring).
65+
- Perform semantic code searches to find code related to an incident by using natural language.
66+
67+
**Work item management:**
68+
69+
- Create work items (Task, Bug, Epic, Feature) with area path, iteration, priority, and severity.
70+
- Link work items to Azure resources for traceability.
71+
72+
**Repository mapping:**
73+
74+
- Find and link Azure Repos to Azure resources.
75+
- Identify infrastructure-as-code files (Bicep, Terraform, ARM templates) in linked repos.
76+
77+
## Documentation connector (wiki knowledge)
78+
79+
Index your Azure DevOps wiki pages so your agent can search them during investigations. When your agent encounters an issue, it searches your indexed wiki for relevant troubleshooting guides, architecture docs, and runbooks.
80+
81+
### How it works
82+
83+
The documentation connector processes your wiki content through the following steps:
84+
85+
1. **Crawls** all pages from your specified Azure DevOps wiki URL (or a specific subsection).
86+
1. **Chunks and embeds** document content into a vector search index.
87+
1. **Semantic search** - during investigations, your agent finds relevant passages and cites the original wiki page.
88+
1. **Auto-syncs every 24 hours** to pick up wiki updates.
89+
90+
### Supported content
91+
92+
The documentation connector supports the following content types:
93+
94+
- Wiki pages (Azure DevOps Wiki format)
95+
- Git repository files including 15 supported formats: `.md`, `.txt`, `.rst`, `.adoc`, `.asciidoc`, `.wiki`, `.textile`, `.org`, `.htm`, `.html`, `.json`, `.yaml`, `.yml`, `.xml`, `.csv`
96+
- Scoped indexing that points to a subpage to index only a specific section of your wiki
97+
98+
## Get started
99+
100+
Use the following resources to set up your Azure DevOps connector.
101+
102+
| Resource | What you learn |
103+
|---|---|
104+
| [Connect source code](connect-source-code.md) | Step-by-step guide for connecting GitHub and Azure DevOps repositories |
105+
| [Set up an Azure DevOps connector](azure-devops-connector.md) | Detailed Azure DevOps connector tutorial |
106+
107+
## Next step
108+
109+
> [!div class="nextstepaction"]
110+
> [Set up an Azure DevOps connector](azure-devops-connector.md)
111+
112+
## Related content
113+
114+
- [Root cause analysis](root-cause-analysis.md): How source code context improves investigation accuracy.
115+
- [Memory and knowledge](memory.md): How indexed knowledge integrates with your agent's persistent memory.
116+
- [Upload knowledge documents](upload-knowledge-document.md): Upload documents directly instead of connecting a wiki.
117+
- [Connectors](connectors.md): Overview of all connector types.

articles/sre-agent/agent-hooks.md

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Agent Hooks in Azure SRE Agent
33
description: Intercept and control agent behavior with custom scripts or LLM-based validation that runs before or after specific agent actions.
44
ms.topic: concept-article
55
ms.service: azure-sre-agent
6-
ms.date: 03/09/2026
6+
ms.date: 03/18/2026
77
author: craigshoemaker
88
ms.author: cshoe
99
ms.ai-usage: ai-assisted
@@ -13,7 +13,7 @@ ms.custom: hooks, agent hooks, stop hook, post tool use, validation, audit, poli
1313

1414
# Agent hooks in Azure SRE Agent
1515

16-
Hooks are custom checkpoints that intercept and control agent behavior at key moments. Use hooks to enforce quality gates on agent responses, audit and control tool usage, block dangerous operations with policy enforcement, and prevent early task completion by validating agent output.
16+
Hooks are custom checkpoints that intercept and control agent behavior at key moments. Use hooks to enforce quality gates on agent responses, audit and control tool usage, block dangerous operations by enforcing policies, and prevent early task completion by validating agent output.
1717

1818
<!-- > [!VIDEO https://www.youtube.com/embed/VIDEO_ID]
1919
>
@@ -44,7 +44,18 @@ Two hook events are currently supported:
4444
| Event | Triggers when | What you can do |
4545
|---|---|---|
4646
| **Stop** | Agent is about to return a final response | Validate completeness, reject and force the agent to continue |
47-
| **PostToolUse** | A tool finishes executing successfully | Audit usage, block results, inject additional context |
47+
| **PostToolUse** | A tool finishes executing successfully | Audit usage, block results, inject extra context |
48+
49+
### Two levels of hooks
50+
51+
Hooks operate at two levels:
52+
53+
| Level | Where to configure | Scope |
54+
|-------|--------------------|-------|
55+
| **Agent level** | **Builder → Hooks** in the portal | Applies to the entire agent including all threads and all custom agents |
56+
| **Custom agent level** | **Agent Canvas → Custom agent → Manage Hooks**, or via the REST API v2 | Applies only when that specific custom agent runs |
57+
58+
Both levels can coexist. If an agent-level hook and a custom-agent-level hook both match the same event, **both run**. The agent-level hooks fire first.
4859

4960
### Execution types
5061

@@ -55,11 +66,11 @@ You can implement hooks by using either an LLM or a shell script:
5566
| **Prompt** | An LLM evaluates your prompt and returns a JSON decision | Nuanced validation ("Is this response complete?") |
5667
| **Command** | A bash or Python script runs in a sandboxed environment | Deterministic checks, policy enforcement, auditing |
5768

58-
**Prompt hooks** are powerful for subjective evaluation, such as checking if a response addresses all user concerns or verifying that an investigation was thorough enough. They use the `$ARGUMENTS` placeholder to receive the full hook context. If `$ARGUMENTS` isn't present in the prompt, the context is appended automatically. Prompt hooks also receive `ReadFile` and `GrepSearch` tools when a conversation transcript is available, which lets the LLM reason about the full conversation history.
69+
**Prompt hooks** are powerful for subjective evaluation, such as checking if a response addresses all user concerns or verifying that an investigation was thorough enough. They use the `$ARGUMENTS` placeholder to receive the full hook context. If `$ARGUMENTS` isn't present in the prompt, the context is appended automatically. When a conversation transcript is available, prompt hooks also receive `ReadFile` and `GrepSearch` tools, which let the LLM reason about the full conversation history.
5970

6071
**Command hooks** are better for deterministic checks, such as validating that a response contains required markers, blocking dangerous commands, or logging tool usage to an external system.
6172

62-
## What makes this different
73+
## What makes this approach different
6374

6475
The following table compares agent behavior with and without hooks.
6576

@@ -83,21 +94,15 @@ Hooks don't replace run mode safety controls - they complement them. Run modes c
8394

8495
## Configure hooks
8596

86-
Hooks require the **v2 YAML format** (`api_version: azuresre.ai/v2`, `kind: ExtendedAgent`). Define hooks under `spec.hooks` in the agent configuration.
97+
The easiest way to create hooks is through the portal UI:
8798

88-
> [!WARNING]
89-
> The portal's Subagent builder YAML tab displays agent configuration in **v1 format only**. It doesn't show or support editing hooks. To configure hooks, use the **REST API v2** endpoint:
90-
>
91-
> ```
92-
> PUT /api/v2/extendedAgent/agents/{agentName}
93-
> Content-Type: application/json
94-
> ```
95-
>
96-
> Hooks configured through the API are active even though they don't appear in the portal YAML view. You can verify hooks are working by testing the agent in the portal's **Test playground**.
97-
>
98-
> :::image type="content" source="media/agent-hooks/hooks-portal-v1-limitation.png" alt-text="Screenshot of the portal YAML tab showing v1 format without hooks." lightbox="media/agent-hooks/hooks-portal-v1-limitation.png":::
99+
1. **Agent-level hooks:** Go to **Builder****Hooks** → select **Create hook**.
100+
2. **Custom-agent-level hooks:** Go to **Agent Canvas** → select a custom agent → **Manage Hooks**.
101+
102+
> [!TIP]
103+
> You can also configure hooks through **REST API v2** by using `PUT /api/v2/extendedAgent/agents/{agentName}`. The YAML format in the following section shows the full configuration schema. To learn more, see the [API tutorial](tutorial-agent-hooks.md).
99104
>
100-
> The portal YAML tab displays v1 format. Hooks aren't visible here but are active on the server.
105+
> The **Agent Canvas YAML** tab displays v1 format and doesn't show hooks. Use the **Hooks** page under **Builder** to view and manage hooks.
101106
102107
The following example shows a complete hook configuration:
103108

@@ -168,7 +173,7 @@ Command hooks can also use exit codes instead of JSON output:
168173
|---|---|
169174
| `0` with no output | Allow (no objection) |
170175
| `0` with JSON | Parse JSON for decision |
171-
| `2` | Always block stderr becomes the reason |
176+
| `2` | Always block. stderr becomes the reason |
172177
| Other | Uses `failMode` setting (`allow` or `block`) |
173178

174179
> [!CAUTION]
@@ -252,7 +257,7 @@ The following limits apply to agent hooks.
252257

253258
## Example: Audit all tool usage
254259

255-
The following PostToolUse hook logs every tool call and injects an audit context message:
260+
The following PostToolUse hook logs every tool call and adds an audit context message:
256261

257262
```yaml
258263
hooks:
@@ -279,7 +284,7 @@ hooks:
279284
print(json.dumps(output))
280285
```
281286
282-
The `additionalContext` field is injected as a user message into the conversation, giving the agent visibility into the audit trail.
287+
The `additionalContext` field is added as a user message into the conversation, giving the agent visibility into the audit trail.
283288

284289
## Example: Require a completion marker
285290

@@ -308,25 +313,28 @@ hooks:
308313

309314
Follow these guidelines when you configure agent hooks:
310315

311-
1. **Always provide a reason when rejecting** — Rejections without reasons are treated as approvals.
312-
1. **Use appropriate timeouts** Long-running hooks slow down agent execution.
313-
1. **Handle errors gracefully** Use `failMode: allow` unless strict enforcement is required.
314-
1. **Be specific with matchers** Overly broad PostToolUse matchers can cause performance problems.
315-
1. **Test hooks thoroughly** Hooks that always reject can cause loops (mitigated by `maxRejections`).
316-
1. **Log to stderr**Use stderr for debugging output. Stdout is parsed as the hook result.
316+
1. **Always provide a reason when rejecting**. Treat rejections without reasons as approvals.
317+
1. **Use appropriate timeouts**: Long-running hooks slow down agent execution.
318+
1. **Handle errors gracefully**: Use `failMode: allow` unless strict enforcement is required.
319+
1. **Be specific with matchers**: Overly broad PostToolUse matchers can cause performance problems.
320+
1. **Test hooks thoroughly**: Hooks that always reject can cause loops (mitigated by `maxRejections`).
321+
1. **Log to stderr**: Use stderr for debugging output. The system parses stdout as the hook result.
317322

318323
## Try it yourself
319324

320325
The following screenshot shows a Stop hook in action. The agent initially responds with just "4", but the hook rejects the response because the completion marker is missing. The agent then continues and adds the marker.
321326

322327
:::image type="content" source="media/agent-hooks/hooks-stop-hook-working.png" alt-text="Screenshot showing a Stop hook in action where the agent response is decorated with a completion marker after hook rejection." lightbox="media/agent-hooks/hooks-stop-hook-working.png":::
323328

324-
## Next step
329+
## Get started
325330

326-
> [!div class="nextstepaction"]
327-
> [Tutorial: Configure agent hooks](./tutorial-agent-hooks.md)
331+
| Resource | What you'll learn |
332+
|----------|-------------------|
333+
| [Configure agent hooks (API)](tutorial-agent-hooks.md) | Set up hooks by using REST API v2 and YAML |
328334

329335
## Related content
330336

331-
- [Run modes](./run-modes.md)
332-
- [Python code execution](python-code-execution.md)
337+
| Capability | How it relates |
338+
|------------|----------------|
339+
| [Run modes](run-modes.md) | Hooks complement run mode safety controls. Modes control *what* runs, hooks control *how well* it runs. |
340+
| [Python tools](python-code-execution.md) | Create custom tools that hooks can audit and validate. |

0 commit comments

Comments
 (0)