Skip to content

[compare]fix optimize for managed agent - #9954

Open
Jessie Li (YoYoJa) wants to merge 28 commits into
Azure:feature/managed-harness-agentsfrom
YoYoJa:jessli/fixManagedOptimization
Open

[compare]fix optimize for managed agent#9954
Jessie Li (YoYoJa) wants to merge 28 commits into
Azure:feature/managed-harness-agentsfrom
YoYoJa:jessli/fixManagedOptimization

Conversation

@YoYoJa

@YoYoJa Jessie Li (YoYoJa) commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes prompt-agent optimization behavior for both job submission and candidate application.

Prompt agents use the definition already deployed to the Foundry service, so azd ai agent optimize no longer requires local copies of the agent model, instructions, tools, or skills. Applying a candidate now persists its supported mutations to the inline prompt-agent definition in azure.yaml.

Hosted and voice-agent behavior remains unchanged.

Changes

Optimize job submission

For kind: prompt agents:

  • Detect the agent kind using the shared agentkind.Kind resolver.
  • Skip local baseline discovery and creation.
  • Skip prompts for:
    • Agent instructions
    • Skills directory
    • Tools file
    • Target agent model
  • Avoid reading local instruction, skill, and tool files.
  • Omit service-owned fields from optimization_config:
    • model
    • system_prompt
    • skills
    • tools
  • Preserve unrelated settings such as model_search_space.
  • Build the request from a sanitized copy without modifying the original configuration.

Dataset, evaluator, evaluation-model, and optimization-model handling is unchanged.

Apply an optimization candidate

For prompt agents, azd ai agent optimize apply now:

  • Loads the selected candidate’s mutation metadata.
  • Finds candidates by candidate ID or name.
  • Uses mutation keys to identify fields changed by the candidate.
  • Reads final values from the candidate configuration.
  • Writes supported mutations to the inline agent definition in azure.yaml.

Supported mappings:

Candidate configuration azure.yaml
system_prompt, systemPrompt, or instructions instructions
model model
tools tools

Mutation metadata is used only to determine which fields changed because its values may have different response shapes. Final values come from the candidate configuration endpoint.

Hosted agents do not enter this new inline-definition update path.

Tests

Added regression coverage for:

  • Starting prompt-agent optimization without local instructions, skills, tools, or model.
  • Omitting service-owned fields from prompt-agent optimization requests.
  • Preserving unrelated optimization settings and the original configuration.
  • Preserving hosted-agent request behavior.
  • Candidate lookup and missing-candidate errors.
  • Applying prompt-agent instruction and tool mutations.
  • Updating only fields listed in the candidate mutation metadata.
  • Explicitly excluding voice agents from prompt-agent mutation persistence.

Validation

  • go test ./internal/cmd
  • go build ./...

Jessie Li (YoYoJa) and others added 11 commits August 24, 2026 14:35
* refactor: support telemetry in ai agent related extensions

* refactor: support telemetry in ai agent related extensions

* refactor: support telemetry in ai agent related extensions

* fix: satisfy extension cspell check

* fix: use released azd telemetry SDK
* Expose live cache fallback warnings

Persist successful template cache fallback warnings outside the interactive PTY and replay them from the always-run pipeline step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 153e03c1-54b4-4a0f-860e-9fe1e574a0fd

* Preserve cache marker cleanup failures

Keep stale refresh markers from being masked by non-blocking warning file initialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 153e03c1-54b4-4a0f-860e-9fe1e574a0fd

---------

Co-authored-by: Jian Wu <wujia@microsoft.com>
Copilot-Session: 153e03c1-54b4-4a0f-860e-9fe1e574a0fd
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Jessie Li (YoYoJa) and others added 9 commits September 10, 2026 11:49
Add a container that can download and run all the protobuff compilers we need, for Go, Python and JS.

Kick it off with 'go tool mage generateProtos'
* fix repeatly optimization

* update change log

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* address comment
Fixes Azure#9908

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jessie Li (YoYoJa) and others added 6 commits September 10, 2026 15:24
* fix repeatly optimization

* update change log

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* address comments

* address comment

* fix optimize test

* fix test

* address comment
* feat(ai): add orthogonal Responses primitives

* refactor(ai): remove Responses replay cursors

* refactor(ai): drop legacy Response state

* refactor(ai): report Response identity once

* refactor(ai): consolidate Responses implementation

* refactor(ai): isolate Responses invoke logic

* refactor(ai): align Responses command organization

* test(ai): exercise Responses lifecycle HTTP contracts

* feat(ai): unify invocation commands and long-running option

* docs(ai): clarify protocol inference and long-running guarantees

* fix(ai): simplify follow guidance and explain unavailable streams

* refactor(ai): restore existing Responses code locations

* refactor(ai): consolidate Responses helpers and tests

* refactor(ai): trim lifecycle flags and document new helpers

* fix(ai): preserve protocol resolution and spelling fixes after rebase

* fix(ai): keep agent and protocol explicit in follow guidance

* test(ai): add offline invocation command scenarios

* fix(ai): preserve safe recovery guidance and defer scenario mapping
* feat(ai-agents): agent.yaml model and Foundry service clients (1/4) (Azure#9754)

* feat(ai-agents): agent.yaml model and Foundry service clients

First of four stacked changes adding managed harness agent support.
This one is the data model and the HTTP clients; it adds no commands
and performs no deployment, so it can be read on its own.

agent_yaml gains the prompt agent manifest: the harness block and its
skills, environment and built-in tool controls, the memory block, tool
declarations, and the feature gate that decides which manifest features
a given harness accepts. Blocks azd interprets reject unknown keys, so
a typo such as builtin_tool for builtin_tools fails the parse instead of
deploying an agent with capabilities the author believed were off. Tools
stay untyped and pass through, so a tool newer than this build still
deploys.

agent_api gains the managed agent contract and its operations. pkg/azure
gains the Foundry data plane clients for files, projects, connections
and RAI policies; the toolsets client is removed because the service
replaced it with the connections control plane.

New spelling terms stay in the extension cspell config rather than the
shared core one, which this branch does not touch.

* fix(ai-agents): preserve inline RAI policy fields

* refactor(ai-agents): reuse unified prompt agent client

* refactor(ai-agents): reference supported sibling resources

---------

Co-authored-by: hund030 <zhihuan@microsoft.com>

* feat(ai-agents): provision and deploy prompt agents (2/4) (Azure#9755)

* feat(ai-agents): agent.yaml model and Foundry service clients

First of four stacked changes adding managed harness agent support.
This one is the data model and the HTTP clients; it adds no commands
and performs no deployment, so it can be read on its own.

agent_yaml gains the prompt agent manifest: the harness block and its
skills, environment and built-in tool controls, the memory block, tool
declarations, and the feature gate that decides which manifest features
a given harness accepts. Blocks azd interprets reject unknown keys, so
a typo such as builtin_tool for builtin_tools fails the parse instead of
deploying an agent with capabilities the author believed were off. Tools
stay untyped and pass through, so a tool newer than this build still
deploys.

agent_api gains the managed agent contract and its operations. pkg/azure
gains the Foundry data plane clients for files, projects, connections
and RAI policies; the toolsets client is removed because the service
replaced it with the connections control plane.

New spelling terms stay in the extension cspell config rather than the
shared core one, which this branch does not touch.

* feat(ai-agents): provision and deploy prompt agents

Second of four stacked changes. Builds on the model and clients from the
previous change and adds the service target that turns a prompt agent
manifest into deployed Foundry resources.

Deployment is graph driven. The manifest is resolved into nodes for the
agent and for every resource it depends on -- memory store, connections,
skills, RAI policy -- and the graph decides creation order and reports
per node progress. Sibling resources are reconciled rather than
recreated, so a redeploy that changes nothing makes no writes.

This package is submitted whole rather than split further. The graph
types are shared by every node implementation and the nodes are
mutually referential, so any smaller cut does not compile without a
refactor that would itself need review.

* fix(ai-agents): preserve inline RAI policy fields

* refactor(ai-agents): reuse unified prompt agent client

* refactor(ai-agents): reference supported sibling resources

* refactor(ai-agents): align prompt deployment dependencies

* fix(ai-agents): constrain prompt deployment to Foundry

* fix(ai-agents): scope prompt deployment state

* fix(ai-agents): bypass tagged lookup for prompt agents

* fix(ai-agents): align prompt schema and policy contract

* fix(ai-agents): remove unshipped prompt config fallback

---------

Co-authored-by: hund030 <zhihuan@microsoft.com>

* feat(ai-agents): CLI surface for managed harness agents (3/4) (Azure#9756)

* feat(ai-agents): agent.yaml model and Foundry service clients

First of four stacked changes adding managed harness agent support.
This one is the data model and the HTTP clients; it adds no commands
and performs no deployment, so it can be read on its own.

agent_yaml gains the prompt agent manifest: the harness block and its
skills, environment and built-in tool controls, the memory block, tool
declarations, and the feature gate that decides which manifest features
a given harness accepts. Blocks azd interprets reject unknown keys, so
a typo such as builtin_tool for builtin_tools fails the parse instead of
deploying an agent with capabilities the author believed were off. Tools
stay untyped and pass through, so a tool newer than this build still
deploys.

agent_api gains the managed agent contract and its operations. pkg/azure
gains the Foundry data plane clients for files, projects, connections
and RAI policies; the toolsets client is removed because the service
replaced it with the connections control plane.

New spelling terms stay in the extension cspell config rather than the
shared core one, which this branch does not touch.

* feat(ai-agents): provision and deploy prompt agents

Second of four stacked changes. Builds on the model and clients from the
previous change and adds the service target that turns a prompt agent
manifest into deployed Foundry resources.

Deployment is graph driven. The manifest is resolved into nodes for the
agent and for every resource it depends on -- memory store, connections,
skills, RAI policy -- and the graph decides creation order and reports
per node progress. Sibling resources are reconciled rather than
recreated, so a redeploy that changes nothing makes no writes.

This package is submitted whole rather than split further. The graph
types are shared by every node implementation and the nodes are
mutually referential, so any smaller cut does not compile without a
refactor that would itself need review.

* feat(ai-agents): CLI surface for managed harness agents

Third of four stacked changes. Adds the commands that sit on top of the
model and the deployment engine from the previous two.

azd ai agent init gains a kind and harness selection and writes the
matching manifest, including discovery of an existing Responsible AI
policy with a warn and fall back path when none can be read. list, show,
delete and invoke gain managed agent handling, with invoke supporting
streamed responses. Infrastructure synthesis learns the project endpoint
so a generated module resolves it from the environment.

Also carries the extension CHANGELOG for all four changes in this stack,
since the entries describe features that only exist once the stack is
complete.

* fix(ai-agents): preserve inline RAI policy fields

* refactor(ai-agents): reuse unified prompt agent client

* refactor(ai-agents): reference supported sibling resources

* refactor(ai-agents): align prompt deployment dependencies

* fix(ai-agents): constrain prompt deployment to Foundry

* fix(ai-agents): scope prompt deployment state

* fix(ai-agents): align prompt CLI with Foundry

* fix(ai-agents): enforce managed prompt CLI contract

* fix(ai-agents): unify prompt project context

* fix(ai-agents): bypass tagged lookup for prompt agents

* fix(ai-agents): complete managed prompt invocation

* fix(ai-agents): finalize prompt init contract

* fix(ai-agents): finalize prompt agent lifecycle

---------

Co-authored-by: hund030 <zhihuan@microsoft.com>

* fix(ai-agents): harden prompt agent lifecycle

* fix(ai-agents): defer harness capability validation

* fix(ai-agents): use published connections dependency

* fix(ai-agents): publish versioned prompt skill references

* fix(ai-agents): route prompt manifest adoption correctly

* fix(ai-agents): reuse existing models for prompt adoption

* feat(ai-agents): support greenfield prompt agent init

* refactor(ai-agents): remove prompt agent list command

* refactor(ai-agents): simplify prompt agent contracts

* refactor(ai-agents): remove temporary prompt overrides

* fix(ai-agents): align Copilot harness tool configuration

* fix(ai-agents): align prompt authoring with service contract

* fix(ai-agents): preserve prompt lifecycle errors

* fix(ai-agents): resolve prompt connection service names

* fix(ai-agents): hide managed harness init entrypoints

* feat(ai-agents): report resolved agent telemetry context

* fix(ai-agents): skip standalone deploy telemetry

* fix(ai-agents): harden prompt agent lifecycle

* fix(ai-agents): expand prompt tool environment values

* fix(ai-agents): clear prompt conversation state

* docs(telemetry): document agent context event

* Validate Responsible AI policy name in prompt features

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix(ai-agents): harden prompt resolution paths

* fix(ai-agents): align skill and telemetry identities

* chore: limit managed agent PR scope

---------

Co-authored-by: Kshitij Chawla <166698309+kshitij-microsoft@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants