Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

Refactors HTTP clients in the azure.ai.agents extension to use azcore.runtime.Pipeline instead of raw http.Client, enabling consistent policy handling, logging, and correlation headers across all HTTP requests.

Now the trace ID is properly propagated to the extension and being set in the X-Ms-Correlation-Request-Id header for outgoing API calls during azd ai agent init and agent deployment.

image image

TODO

Changes

Migrate to runtime.Pipeline

  • registry_api/operations.go - Replace http.Client with pipeline-based requests
  • foundry_projects_client.go - Same migration, plus fix for defer-in-loop resource leak

Add policies to ARM SDK clients

  • New client_options.go with NewArmClientOptions() helper providing standard policies
  • Updated all armcognitiveservices and armsubscriptions client instantiations in:
    • init.go (ProjectsClient, DeploymentsClient)
    • service_target_agent.go (ProjectsClient)
    • model_catalog.go (ModelsClient)
    • azure_client.go (subscriptions Client)

Debug logging in azd ai agent init

  • Support debug logging of HTTP requests and responses during azd ai agent init

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • code.cloudfoundry.org
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • dario.cat
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • go.opentelemetry.io
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • go.uber.org
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • go.yaml.in
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • google.golang.org
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy -o br-935d10f6676f -j DROP si_-_Surum_1.pem /opt/hostedtoolc-e /usr/bin/test 10 -buildtags /opt/hostedtoolc--global test -e igiCert_Assured_ID_Root_G2.pem /opt/hostedtoolc-e (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>azure.ai.agents - Update registry_api to use azcore runtime.Pipeline and policies</issue_title>
<issue_description>### Task 1
Update extension code in:

  • cli/azd/extensions/azure.ai.agents/internal/pkg/agents/registry_api/operations.go
  • cli/azd/extensions/azure.ai.agents/internal/pkg/azure/foundry_projects_client.go
  • other extension components that use direct HTTP requests (e.g., any usage of http.Client)

to use azcore's runtime.Pipeline for HTTP request handling. This is to enable policy, logging, and correlation header configuration similar to the agent_api/operations.go implementation. See #6137 as a reference.

Sub-tasks:

  • Refactor RegistryAgentManifestClient to use runtime.Pipeline and associated policies
  • Ensure credential, policy chaining, and diagnostic logging match agent_api usage
  • Review other components in azd/extensions/azure.ai.agents that perform direct HTTP requests (e.g., any usage of http.Client) and update them to use pipelines/policies as appropriate

Relevant files/components for review:

  • registry_api/operations.go (primary)
  • agent_api/operations.go (reference impl)
  • foundry_projects_client.go

Task 2

Update places where we create/use specific azure service clients from azure-sdk-for-go (e.g. armcognitiveservices.NewProjectsClient in cli/azd/extensions/azure.ai.agents/internal/cmd/init.go) to use similar policies and logging config as:

Logging: policy.LogOptions{
					AllowedHeaders: []string{azsdk.MsCorrelationIdHeader},
				},
				PerCallPolicies: []policy.Policy{
					azsdk.NewMsCorrelationPolicy(),
					azsdk.NewUserAgentPolicy(...),
				},
```</issue_description>

<agent_instructions>Use modern, idiomatic Go practices and if you see good opportunities for refactoring, please do so</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 5, 2025 18:04
Copilot AI changed the title [WIP] Update registry_api to use azcore runtime.Pipeline and policies Update registry_api and foundry_projects_client to use azcore runtime.Pipeline Dec 5, 2025
Copilot AI requested a review from JeffreyCA December 5, 2025 18:14
@JeffreyCA JeffreyCA changed the base branch from jeffreyca/ext-agents-operations to main December 5, 2025 18:15
@JeffreyCA JeffreyCA changed the title Update registry_api and foundry_projects_client to use azcore runtime.Pipeline azure.ai.agents - fix correlation ID propagation and tracing, update components to use azcore runtime.Pipeline Dec 5, 2025
@JeffreyCA JeffreyCA linked an issue Dec 5, 2025 that may be closed by this pull request
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.

azure.ai.agents - support debug logging in azd ai agent init azure.ai.agents - Update registry_api to use azcore runtime.Pipeline and policies

2 participants