Skip to content

fix(ai-agents): propagate local agent exit failures - #9600

Merged
Travis Angevine (trangevi) merged 2 commits into
Azure:mainfrom
dooriya:dooriya-fix-agent-run-exit-code
Aug 19, 2026
Merged

fix(ai-agents): propagate local agent exit failures#9600
Travis Angevine (trangevi) merged 2 commits into
Azure:mainfrom
dooriya:dooriya-fix-agent-run-exit-code

Conversation

@dooriya

Copy link
Copy Markdown
Contributor

Summary

  • preserve the run context's cancellation state before cleanup cancellation
  • return non-zero local agent process exits instead of reporting Agent stopped. successfully
  • add a cross-platform regression test that runs a child process exiting with status 17

Validation

  • go test ./internal/cmd
  • go vet ./internal/cmd

Fixes #9599

Capture cancellation state before cleanup cancels the run context, so non-zero child process exits are returned instead of reported as a clean stop.

Fixes Azure#9599

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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.

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

Fixes local agent exit failures being incorrectly reported as successful.

Changes:

  • Preserves cancellation state before cleanup.
  • Adds a cross-platform non-zero exit regression test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/cmd/run.go Distinguishes cancellation from process failure.
internal/cmd/run_test.go Tests propagation of exit status 17.

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

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/run.go Outdated
Recognize direct SIGINT, SIGTERM, and Windows control-C process exits so Ctrl+C remains successful even when the child exits before the signal goroutine cancels the run context.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 09:13

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 2 out of 2 changed files in this pull request and generated no new comments.

@trangevi
Travis Angevine (trangevi) merged commit 829461a into Azure:main Aug 19, 2026
29 checks passed
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.

azd ai agent run reports success when agent exits non-zero

4 participants