Skip to content

azure.ai.agents: reject hosted-only agent fields on non-hosted kinds - #9691

Open
yzxcj797 wants to merge 3 commits into
Azure:mainfrom
yzxcj797:fix/reject-hosted-only-agent-fields-9623
Open

azure.ai.agents: reject hosted-only agent fields on non-hosted kinds#9691
yzxcj797 wants to merge 3 commits into
Azure:mainfrom
yzxcj797:fix/reject-hosted-only-agent-fields-9623

Conversation

@yzxcj797

Copy link
Copy Markdown

Fixes #9623.

Summary

In the azure.ai.agents extension, codeConfiguration, policies, protocols, agentEndpoint and sessionConfiguration are hosted-agent-only: AgentDefinitionInline.toVoiceAgent() drops them for voice agents, yet both the schema and ValidateAgentDefinition accepted them for every kind — so a kind: prompt-voice manifest carrying them validated fine while silently having no effect.

Two aligned changes:

  • RuntimeValidateAgentDefinition now reports each present hosted-only field for non-hosted kinds ('<field>' is only supported for 'hosted' agents and is ignored for kind '<kind>'). Presence is checked on the raw template keys, so empty or partial values — which would unmarshal to zero fields — are reported too.
  • Schemaazure.ai.agent.json gains the matching draft-07 conditional (kind != hosted ⇒ reject anyOf of the five required fields), in the style of the existing prompt-voice model rule.

Testing

  • Added TestValidateAgentDefinition_HostedOnlyFieldsRejectedOnPromptVoice (each of the five fields rejected on a prompt-voice agent) and TestValidateAgentDefinition_HostedFieldsStillAllowedOnHosted (hosted kind unaffected).
  • Updated the one existing case whose fixture put policies on a workflow agent expecting success — with policies now hosted-only, a non-hosted agent free of the block stays valid, which is that case's premise.
  • go test ./... in the extension passes; differential: with the runtime check reverted, the new rejection test fails with got: <nil>.

codeConfiguration, policies, protocols, agentEndpoint and
sessionConfiguration are dropped by load/deploy conversion for every
non-hosted agent kind, so a manifest carrying them on e.g. a
prompt-voice agent validated fine while silently having no effect.

Reject them up front:

- ValidateAgentDefinition reports each present hosted-only field for
  non-hosted kinds (presence is checked on the raw template keys so
  empty or partial values are also reported);
- the azure.ai.agent.json schema gains the matching kind gate, in the
  style of the existing prompt-voice model rule.

Fixes Azure#9623
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
6 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported identify a customer issue label Aug 22, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution yzxcj797! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restricts hosted-only agent fields to hosted agents in runtime and schema validation.

Changes:

  • Adds schema and runtime restrictions.
  • Adds prompt-voice and hosted validation tests.
  • Updates an existing workflow test fixture.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
schemas/azure.ai.agent.json Adds conditional field restrictions.
agent_yaml/parse.go Adds runtime hosted-only field validation.
agent_yaml/parse_voice_test.go Adds validation tests.
agent_yaml/parse_test.go Updates workflow test expectations.
Suppressed comments (1)

cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse.go:673

  • This list only recognizes the inline camelCase spellings. The supported on-disk agent.yaml contract uses code_configuration, agent_endpoint, and session_configuration (yaml.go:355,357,359), and voiceAgentFromDefinitionFile passes those raw bytes here. Those three spellings therefore still validate and are silently dropped for prompt-voice agents.
	"codeConfiguration",
	"policies",
	"protocols",
	"agentEndpoint",
	"sessionConfiguration",

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +148 to +155
"if": {
"not": {
"properties": {
"kind": { "const": "hosted" }
},
"required": ["kind"]
}
},
Comment on lines +397 to +398
errors = append(errors,
validateNoHostedOnlyFields(templateBytes, agentDef.Kind)...)
Comment on lines +159 to +163
{ "required": ["codeConfiguration"] },
{ "required": ["policies"] },
{ "required": ["protocols"] },
{ "required": ["agentEndpoint"] },
{ "required": ["sessionConfiguration"] }
…chema gate

Per review:

- the schema conditional now requires kind, so kind-less service
  configuration is untouched by the hosted-only gate;
- LoadAndValidateAgentManifest validates the RAW template too: the
  typed remarshal drops hosted-only fields before
  ValidateAgentDefinition can see them;
- the inline voice deployment path (VoiceAgentFromResolvedService)
  validates the raw resolved struct before toVoiceAgent drops the
  fields;
- table-driven schema cases cover each hosted-only field on
  prompt-voice plus hosted and kind-less controls.
Copilot AI review requested due to automatic review settings August 22, 2026 01:59
@yzxcj797

Copy link
Copy Markdown
Author

All three review points addressed in 626290c:

  1. Schema gate — the conditional now requires kind (if: {required: [kind], not: {properties: {kind: {const: hosted}}}}), so kind-less service configuration is untouched; the existing kind-less sessionConfiguration cases pass again, and a new explicit control covers sessionConfiguration + agentEndpoint without kind.

  2. Runtime reach

    • LoadAndValidateAgentManifest now also validates the raw template bytes (the typed remarshal drops hosted-only fields before ValidateAgentDefinition sees them);
    • the inline voice path (VoiceAgentFromResolvedService) validates the raw resolved struct via the same exported agent_yaml.ValidateHostedOnlyFields before toVoiceAgent() drops the fields.
      ValidateHostedOnlyFields accepts YAML or JSON bytes (YAML is a superset), inspects raw keys, and no-ops for hosted or unknown kinds so shape errors keep surfacing where they always did.
  3. Schema testsTestDocSchemaValidatesConstraints gains table cases for each of the five hosted-only fields on kind: prompt-voice (rejected) plus hosted and kind-less controls (valid).

Full extension suite: 21 packages ok, 0 failures.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

package project

import (
"google.golang.org/protobuf/encoding/protojson"
Comment on lines +705 to +711
var hostedOnlyAgentFields = []string{
"codeConfiguration",
"policies",
"protocols",
"agentEndpoint",
"sessionConfiguration",
}
…rt order

Per review:

- standalone agent.yaml spells three of the hosted-only fields in
  snake_case (code_configuration, agent_endpoint,
  session_configuration, per the ContainerAgent yaml tags), so the
  raw-key check now covers both spellings;
- the protojson import moves into the third-party group so the file
  is gofmt-clean.
Copilot AI review requested due to automatic review settings August 22, 2026 02:47
@yzxcj797

Copy link
Copy Markdown
Author

Both second-round points addressed:

  • the raw-key check now covers both spellingscode_configuration, agent_endpoint and session_configuration (the standalone agent.yaml authoring form per the ContainerAgent yaml tags) alongside the camelCase service-property names — with a new snake_case rejection test;
  • the protojson import moved beside structpb in the third-party group; gofmt -l internal/ is clean.

agent_yaml and project packages pass.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

yzxcj797 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (4)

Previously missed (3) — in code that hasn't changed since the last review.

cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse_voice_test.go:177

  • This hosted-kind success test supplies agentEndpoint as a scalar, but AgentEndpoint is a struct (yaml.go:804-808). Unmarshalling the hosted definition therefore fails before the new allow-list behavior is tested. Use an object value so this case can actually pass.
agentEndpoint: https://example.com

cli/azd/extensions/azure.ai.agents/internal/project/doc_examples_test.go:822

  • These five rejection cases can all pass because kind: prompt-voice already requires model, which none of them supplies; the codeConfiguration case also uses a value that independently violates its required runtime and entryPoint fields. Add a valid model to every case and make codeConfiguration valid so each error is attributable to the new hosted-only conditional.
			name: "session configuration rejected for prompt-voice",
			mutate: func(value *fixture) {
				value.value["kind"] = "prompt-voice"
				value.value["sessionConfiguration"] = map[string]any{"idleTimeoutSeconds": 300}
			},

cli/azd/extensions/azure.ai.agents/internal/project/agent_definition.go:1077

  • No test exercises hosted-only field rejection through VoiceAgentFromResolvedService; the existing round-trip test contains only valid voice fields. Add a service-config test with a raw hosted-only property and assert the validation error so the protojson/raw-key integration is covered, not only the helper itself.
		// toVoiceAgent drops hosted-only fields; check the raw definition so
		// they are rejected instead of silently ignored (#9623).
		if rawBytes, err := protojson.Marshal(resolved); err == nil {
			if err := agent_yaml.ValidateHostedOnlyFields(rawBytes); err != nil {

cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse.go:53

  • The direct validator tests do not exercise this post-conversion check. Add a LoadAndValidateAgentManifest test with a prompt-voice template and a hosted-only raw key; otherwise this branch could be removed or broken while all new runtime tests still pass, reintroducing the silent drop in the manifest-loading path.
	// The remarshal above reflects the typed conversion, which drops
	// hosted-only fields before ValidateAgentDefinition can see them, so
	// check the raw template too (#9623).
	var rawManifest map[string]any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported identify a customer issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azure.ai.agents: reject hosted-only agent fields for non-hosted kinds (schema + runtime)

2 participants