Skip to content

fix(agents): classify non-HTTP Azure client errors and preflight GetAgent attribution - #11000

Draft
Hui Miao (huimiu) wants to merge 2 commits into
mainfrom
hui/agent-deploy-error-classification
Draft

Hui Miao (huimiu) wants to merge 2 commits into
mainfrom
hui/agent-deploy-error-classification

Conversation

@huimiu

@huimiu Hui Miao (huimiu) commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

When Azure SDK or Foundry HTTP calls fail without an *azcore.ResponseError in azure.ai.agents, exterrors.ServiceFromAzure falls back to Internal(operation, ...). That collapses timeouts, local credential failures, DNS/TLS/proxy transport errors, and malformed 2xx payloads into one internal bucket without user guidance. Two pre-deploy GetAgent preflight checks in service_target_agent.go also pass OpCreateAgent instead of OpGetAgent, attributing preflight read errors to create_agent.

This PR fixes preflight GetAgent attribution, classifies non-ResponseError client failures in ServiceFromAzure into distinct categories and codes with remediation guidance, and redacts URL credentials, query parameters, and fragments from surfaced error messages.

Changes

  • Fix pre-deploy GetAgent error attribution in deployHostedCodeAgent and reconcileCreateRequestWithDeployedDigitalWorkerType to pass exterrors.OpGetAgent instead of exterrors.OpCreateAgent
  • Classify non-ResponseError failures in exterrors.ServiceFromAzure:
    • context.DeadlineExceeded, gRPC DeadlineExceeded, and net.Error.Timeout() map to Internal(CodeDeadlineExceeded, ...) (deadline_exceeded, which unwraps to context.DeadlineExceeded -> ResultCode="internal.timeout" on the host)
    • *azidentity.AuthenticationFailedError, *azidentity.AuthenticationRequiredError, and AzureDeveloperCLICredential / DefaultAzureCredential failures map to Auth(CodeAuthFailed | CodeCredentialCreationFailed, ...)
    • Post-2xx response body read failures (*ResponseReadError, NewResponseReadClassificationPolicy, WrapPipelineError, and azcore bodyDownloadPolicy errors) map to Internal(operation + "_response_read", ...)
    • Post-2xx JSON decode/unmarshal failures (*ResponseParseError) map to Internal(operation + "_response_parse", ...)
    • Client-side DNS, TLS/x509, *net.OpError, non-timeout net.Error, and *url.Error transport failures map to Dependency(operation + "_transport", ...) with network/DNS/TLS troubleshooting guidance
  • Add fail-closed RedactURL and safeErrorMessage in internal/exterrors so URL userinfo, query parameters, fragments, and malformed URLs are redacted before formatting error messages
  • Attach NewResponseReadClassificationPolicy to Azure/Foundry client pipelines and wrap post-2xx response read and JSON decode failures with WrapPipelineError, WrapResponseRead, and WrapResponseParse across agent_api and internal/pkg/azure
  • Preserve uncertain-write remediation guidance in StateStoreWriteOutcomeUnknownError when ServiceFromAzure classifies a mid-flight transport drop as Dependency
  • Add unit and regression tests in internal/exterrors/errors_test.go, internal/pkg/agents/agent_api/operations_test.go, and internal/project/hosted_agent_errors_test.go, update internal/project/prompt_headers_test.go, and update cli/azd/extensions/azure.ai.agents/AGENTS.md

User-facing changes

When an azd agent command or azd deploy / azd up fails due to local authentication or client-side network/DNS/TLS transport issues before receiving an HTTP response from Foundry or Azure, the error now includes a remediation suggestion (such as running azd auth login or checking network, VPN, Private Endpoint DNS, TLS proxy, or firewall settings), and embedded URL credentials, query parameters, and fragments are redacted.

Telemetry change

What changed: Refines span status ResultCode (StatusDescription) and existing error attributes emitted on command (cmd.*) and extension (ext.run) spans when exterrors.ServiceFromAzure handles failures in azure.ai.agents. No new events, spans, ReportUsage calls, or telemetry fields are added.

  • Preflight GetAgent ServiceError failures in hosted code and container deploy paths now emit error.service.name="get_agent" instead of "create_agent" (alongside existing error.service.statusCode, error.service.errorCode, and error.service.host), and span ResultCode changes from ext.service.create_agent.<code> to ext.service.get_agent.<code> (for example, ext.service.get_agent.403).
  • Non-ResponseError LocalError failures previously emitted ResultCode="ext.internal.<operation>", error.category="internal", and unprefixed error.code="<operation>" (for example, error.code="create_agent"). They now emit bounded, code-defined values:
    • Timeouts / deadlines (deadline_exceeded): ResultCode="internal.timeout" via context.DeadlineExceeded unwrap (no error.category / error.code attributes)
    • Local credential failures: ResultCode="ext.auth.auth_failed" or "ext.auth.credential_creation_failed", error.category="auth", error.code="auth_failed" or "credential_creation_failed"
    • Client-side DNS / TLS / socket transport errors: ResultCode="ext.dependency.<operation>_transport", error.category="dependency", error.code="<operation>_transport"
    • Post-2xx body read errors: ResultCode="ext.internal.<operation>_response_read", error.category="internal", error.code="<operation>_response_read"
    • Post-2xx JSON parse errors: ResultCode="ext.internal.<operation>_response_parse", error.category="internal", error.code="<operation>_response_parse"
    • Unclassified local errors remain ResultCode="ext.internal.<operation>", error.category="internal", error.code="<operation>"

Why it is needed: Separate genuine extension/SDK response-handling bugs and service timeouts from client-side auth, DNS, proxy, and TLS failures in agent deployment reliability metrics without losing visibility into post-2xx failures.
Approval coverage (maintainer): pending assessment

  • Values are limited to what is needed; custom and invalid inputs are handled. Emitted ResultCode, error.code, error.category, and error.service.name values come strictly from fixed code constants (Op* + fixed suffixes); customer inputs, URLs, and raw error messages are never placed in telemetry codes.
  • Field/event declarations, classification, purpose, identifier metadata, hashing rules, and affected telemetry docs are updated. Existing error.code, error.category, and error.service.* declarations (SystemMetadata / PerformanceAndHealth) in docs/specs/metrics-audit/telemetry-schema.md are unchanged; extension error-handling guidance in cli/azd/extensions/azure.ai.agents/AGENTS.md is updated.
  • Focused tests check emitted and excluded values, including hashes where relevant. Opt-out behavior is unchanged.
  • Known affected queries, tables, reports, or exports are listed, with an owner for follow-up or migration. Hosted-agent deployment availability KQL queries tracking ResultCode (ext.internal.create_agent, ext.dependency.*_transport) and unprefixed error.code (create_agent, *_transport) will be updated after release (@huimiu).
  • Code changes, metadata deployment, and downstream checks have separate statuses and owners. Extension code, unit tests, and docs are complete in this PR (@huimiu); no telemetry schema/metadata deployment is needed because no fields or events were added; downstream BI query updates are owned by @huimiu post-release.

Open questions or follow-ups: Maintainer approval-coverage assessment before merge; @huimiu to monitor split ext.dependency.*_transport, ext.auth.*, internal.timeout, and ext.internal.*_response_* codes after the next azure.ai.agents release.

Notes

Impacted cli-interactive-tester scenario tags (not auto-run): deploy, verify-deploy, cmd:up, cmd:deploy, state-stores.

@azure-pipelines

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

@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Nov 18, 2026
@huimiu
Hui Miao (huimiu) force-pushed the hui/agent-deploy-error-classification branch from 9218d76 to 4893660 Compare November 20, 2026 00:07
@huimiu
Hui Miao (huimiu) force-pushed the hui/agent-deploy-error-classification branch from 4893660 to 2d04c39 Compare November 23, 2026 00:12

This branch has not been deployed

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

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant