Skip to content

feat(agents): export Agent Insights as JSON - #9937

Open
Ilya Matiach (imatiach-msft) wants to merge 7 commits into
Azure:mainfrom
imatiach-msft:feat/agent-insights-export
Open

feat(agents): export Agent Insights as JSON#9937
Ilya Matiach (imatiach-msft) wants to merge 7 commits into
Azure:mainfrom
imatiach-msft:feat/agent-insights-export

Conversation

@imatiach-msft

@imatiach-msft Ilya Matiach (imatiach-msft) commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Closes #9955

Summary

  • Add azd ai agent insights export [name] to the Foundry Agents extension.
  • Export every current insight page as JSON to stdout or --out-file for PowerShell and CI automation.
  • Include highlighted traces, linked traces, and proposed fixes by default, with category, severity, and status filters.
  • Reuse existing Foundry project endpoint and azd authentication resolution, verify the returned monitor belongs to the requested agent, and preserve unknown service fields for forward compatibility.

Customer scenario

This provides a supported automation surface for teams that currently review Insights in the portal and need to archive, filter, or feed the findings into an engineering workflow.

$export = azd ai agent insights export | ConvertFrom-Json
$export.insights | Where-Object severity -eq "high"

For durable UTF-8 output:

azd ai agent insights export my-agent `
  --project-endpoint "https://<account>.services.ai.azure.com/api/projects/<project>" `
  --out-file ".\insights.json"

$export = Get-Content ".\insights.json" -Raw -Encoding utf8 | ConvertFrom-Json

The extension PR bundle has not yet been published. Use the pipeline-generated azd ext install command once a bundle is available.

Validation

  • go test ./... -short
  • go build ./...

Review follow-up

  • Send the required Foundry-Features: AgentInsights=V1Preview header on API requests.
  • Honor --environment for both deployed-agent and endpoint resolution.
  • Preserve azure.yaml service-name resolution when --project-endpoint is supplied; outside a project, the positional argument is the remote agent name.
  • Keep environment-bound exports in the selected project: missing or unreadable FOUNDRY_PROJECT_ENDPOINT values fail rather than using a global or shell fallback. An explicit --project-endpoint remains an intentional override.
  • Add regressions for current/selected environments, missing/invalid endpoints, read errors, explicit overrides, and standalone fallback.
  • Exercise the production Insights client pipeline through an injected TLS test transport; header assertions fail if the production preview policy is removed.
  • Add offline cmd:insights scenarios tier0/0.17-insights-export-help.yaml and tier0/0.18-insights-export-validate-severity.yaml, plus PR impact mapping. Scenarios are statically validated, not executed; use foundry-extension-scenario-orchestrator to run them.

Add a PowerShell-friendly Agent Insights export command with filtering, full cursor pagination, sensitive-detail handling, and PR-bundle documentation.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e
@azure-pipelines

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

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e

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.

🟡 Changes recommended

Environment selection and combined service-name/endpoint resolution can target the wrong agent or project.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds JSON export automation for Foundry Agent Insights.

Changes:

  • Adds the insights export command with filters and file output.
  • Introduces a paginated Insights API client and tests.
  • Documents and registers the command.
File summaries
File Description
README.md Documents Insights export.
models.go Defines API paging models.
client.go Implements Insights API requests.
client_test.go Tests client behavior.
codes.go Adds structured error codes.
root.go Registers the command.
insights.go Implements export orchestration.
insights_test.go Tests export behavior.
eval.go Generalizes endpoint flag helper.
eval_show.go Uses renamed helper.
eval_list.go Uses renamed helper.
extension.yaml Adds an extension example.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 2
  • Review effort level: Balanced

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

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/insights.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/insights.go Outdated
Copilot AI review requested due to automatic review settings September 9, 2026 20:57

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.

🟡 Changes recommended

Insights requests omit the required Foundry preview feature header.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Add the required Agent Insights preview header and honor explicit azd environment selection for both agent and project endpoint resolution.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e
Copilot AI review requested due to automatic review settings September 9, 2026 21:23

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.

🟡 Changes recommended

Endpoint fallback can combine an agent from one environment with another project and export the wrong sensitive insights.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/agent_context.go Outdated
Require environment-bound exports to use the selected azd environment endpoint unless explicitly overridden. Fail on missing endpoints and environment read errors instead of consulting unrelated project defaults.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e
Copilot AI review requested due to automatic review settings September 10, 2026 19:10

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.

🔵 Needs a closer look

The required preview-header regression tests bypass the production client configuration they are intended to protect.

Review details

Suppressed comments (1)

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

cli/azd/extensions/azure.ai.agents/internal/pkg/agents/insights_api/client_test.go:37

  • This test injects foundryFeaturesPolicy into its own pipeline, so it does not verify that NewClient actually installs the required header policy; deleting the production policy at client.go:54 would leave both request tests green. Please construct the test client through the production pipeline with an injectable transport/options seam so this regression coverage exercises the real wiring.
  • Files reviewed: 16/16 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Preserve environment selection alongside updated deployed-agent metadata resolution and retain both README additions.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e
Inject only the HTTP transport into NewClient so preview-header regression tests verify production policy registration over TLS, including authentication and cursor requests.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e
Copilot AI review requested due to automatic review settings September 10, 2026 19:27
@imatiach-msft

Copy link
Copy Markdown
Contributor Author

Addressed the production-pipeline regression coverage finding in cc869fa.

The tests now construct the client through NewClient and inject only an HTTP transport backed by a local TLS server. Removed NewClientFromPipeline and the test-side header policy installation. Both monitor and insight requests assert the literal preview header and bearer authentication, including continuation-cursor requests.

I temporarily removed the policy from the production constructor and confirmed both header tests failed, then restored it and confirmed they pass. The tests now detect precisely the regression identified in the review.

Also merged latest main (9281b22) in 55707f4, resolving the README and deployed-agent metadata helper conflicts while preserving environment selection and endpoint isolation.

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.

🟡 Changes recommended

The new command lacks the required interactive tester scenario coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/root.go
Add cmd:insights help and invalid-severity scenarios and map Insights changes to their regression tag.

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

Copilot-Session: f0181e33-e234-4d7f-8307-59d76779378e

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.

🟢 Approval recommended

The implementation matches the stated behavior and includes comprehensive regression coverage for the previously identified risks.

Review details
  • Files reviewed: 20/20 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@imatiach-msft

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 9937 in repo Azure/azure-dev

@trangevi

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@trangevi

Copy link
Copy Markdown
Member

/azp run "azure-dev - cli"

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@trangevi

Copy link
Copy Markdown
Member

/azp run azure-dev - cli

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@trangevi

Copy link
Copy Markdown
Member

/azp run azure-dev - ext - microsoft.azd.extensions

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@trangevi

Copy link
Copy Markdown
Member

/azp run azure-dev - ext - azure.ai.agents

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

azure.ai.agents PR build

Note

This is an unsigned development build. Install it only if you trust this PR.

Install the extension:

azd ext install "https://azuresdkartifacts.z5.web.core.windows.net/azd/extensions/pr/9937/azure-ai-agents.zip"
  • Version: 1.0.0-beta.14.pr.9937.6813692
  • Merge commit: 5ad7d1b

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.

Support Agent Insights JSON export in the azd Agents extension

3 participants