fix: name the azure.yaml key in the RAI policy validation error - #9328
Conversation
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Clarifies RAI policy configuration for unified azure.yaml agent definitions.
Changes:
- Improves policy validation messaging.
- Adds policy round-trip and deployment tests.
- Documents policy configuration and key naming.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
README.md |
Documents content safety policies. |
agent_policies_test.go |
Adds unified-shape regression coverage. |
parse.go |
Names both supported policy keys. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
cli/azd/extensions/azure.ai.agents/README.md:62
azd-code-reviewer: Add the inline agentnameto this example. Runtime validation requiresAgentDefinition.Nameand does not derive it from theservices.my-agentmap key, so copying this snippet fails withtemplate.name not in valid format: name cannot be emptybefore the policy can be deployed.
kind: hosted
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
cli/azd/extensions/azure.ai.agents/README.md:54
RAIexpands to “Responsible AI,” not “Azure AI Content Safety.” Use the product terminology so readers can identify and search for the correct policy type.
A hosted agent can be bound to an Azure AI Content Safety (RAI) policy so every
cli/azd/extensions/azure.ai.agents/README.md:74
- Document the effective cardinality of RAI policies.
mapRaiConfigreturns the first matching entry and validation accepts multiple entries, so users can list several policies while only the first is sent to Foundry. This is especially important for safety configuration; either state the first-entry behavior here or reject duplicaterai_policyentries.
- `type` is required. `rai_policy` is currently the only supported value.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
cli/azd/extensions/azure.ai.agents/README.md:77
- azd-code-reviewer: The documented list accepts multiple
rai_policyentries, butmapRaiConfigreturns the first match and the data-plane model has only oneRaiConfig; every later policy is silently ignored. For a safety setting, this can leave a policy the user intended to apply unused. Reject duplicate RAI policies during validation (with a regression test), or explicitly document that only the first entry is effective.
- `type` is required. `rai_policy` is currently the only supported value.
…leases (#9371) * chore: prepare azure.ai.agents 1.0.0-beta.8 release Bump version and add changelog for 10 PRs since beta.7: - Features: max_stalls early-stopping (#9314), invocations protocol 2.0.0 default (#9327) - Bug fixes: #9365, #9328, #9291, #9290, #9212, #9211, #9280, #9237 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * chore: prepare azure.ai.projects 1.0.0-beta.4 release Bump version and add changelog for 1 PR since beta.3: - Bug fix: cap Foundry ARM deployment names to 64 chars (#9292) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * chore: add imatiach to cspell contributor aliases Fix cspell-ext CI gate failure for the azure.ai.agents CHANGELOG entry referencing @imatiach-msft (PR #9314). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* test(azure.ai.agents): validate azure.yaml examples in docs `azure.yaml` examples in this extension's docs weren't validated by anything, so they could drift out of sync with the code and ship broken. Two instances were found by hand recently: the README migration example omitted the required agent `name` (#9328), and a Learn article documented `rai_config.rai_policy_name`, which azd ignores entirely — deploying with no guardrail and no error. Adds TestDocExamplesAreValid, which extracts every fenced YAML block declaring an `azure.ai.agent` service from the extension's markdown and applies two checks: 1. Resolver — the snippet must survive AgentDefinitionFromService, the same entry point azd uses at deploy time. Catches the missing-`name` class. 2. Vocabulary — every property must be declared in schemas/azure.ai.agent.json or parsed by azd core. azd deliberately ignores unrecognized service properties for forward compatibility, which is exactly how a doc can advertise a setting that silently does nothing. Catches the `rai_config` class, which the resolver alone cannot. Not every snippet is meant to be complete: the three `azure.ai.agent` entries in docs/private-networking.md intentionally omit `kind` so azd falls back to the on-disk agent.yaml. Those opt out of check 1 with an `<!-- azd:doc-example partial -->` marker, keeping the default strict rather than inferring intent. Fixes #9330 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e7ba2e0e-80cf-4226-b56e-ac7cbbc7338f * test(azure.ai.agents): validate doc snippets through core's field shapes and the full schema Co-authored-by: glharper <64209257+glharper@users.noreply.github.com> * test(azure.ai.agents): name the doc and the fix when a value can't reach structpb The two structpb.NewStruct assertions were the only doc-content-reachable ones without a message, so a value structpb can't represent failed with a bare "proto: invalid type: time.Time" and no hint about what to change. It is reachable from a snippet: an unquoted date under an extension-owned key (metadata: released: 2024-07-18) decodes to time.Time and fails exactly that way. Both assertions now report file:line/service and say to quote ambiguous scalars. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d5b46e6-fc04-48bb-9a2c-156105966b48 * docs(agents): mark the config env snippet as a partial example The service-scoped env section added by #9079 shows only where `env:` belongs, so its snippet has no `kind:` and cannot resolve to a full agent definition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd * Validate doc examples against the full schema and core YAML shapes Addresses review on #9368. Compile azure.ai.agent.json and validate the runtime-active inline or legacy config property map, so required, type, enum, pattern, and nested additionalProperties constraints are enforced in addition to the existing friendly vocabulary check. Reject extension properties in the inactive location because azd selects one shape rather than merging them. Replace untyped core service placeholders with strict test-only mirrors of Docker, AKS/Helm/Kustomize, infra/layers/deploymentStacks, and hook YAML. Mirror HooksConfig's mapping-or-list parsing and core's nil-hook validation, and reject nested core-field typos that azd would otherwise ignore. Regression coverage exercises each constraint and field family. The JSON Schema validator was already a transitive dependency; mark it direct now that the doc test imports it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b4617dfd-adfb-4b30-9222-477a041f8af9 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Copilot-Session: e7ba2e0e-80cf-4226-b56e-ac7cbbc7338f Copilot-Session: 1d5b46e6-fc04-48bb-9a2c-156105966b48 Copilot-Session: fed9e97b-e79b-4889-ac76-0d9a428599cd Copilot-Session: b4617dfd-adfb-4b30-9222-477a041f8af9
Fixes #8709
RAI policies already flow from unified
azure.yamlagent definitions to the Foundry API, but this path lacked coverage and documentation. The validation error also suggested the legacyrai_policy_namekey, even though unifiedazure.yamlusesraiPolicyName.Sample PR: https://github.com/microsoft-foundry/foundry-samples-pr/pull/802
Doc PR: https://github.com/MicrosoftDocs/azure-ai-docs-pr/pull/13567