Skip to content

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

Open
Dooriya Li (dooriya) wants to merge 1 commit into
Azure:mainfrom
dooriya:dooriya-fix-agent-run-exit-code
Open

fix(ai-agents): propagate local agent exit failures#9600
Dooriya Li (dooriya) wants to merge 1 commit into
Azure:mainfrom
dooriya:dooriya-fix-agent-run-exit-code

Conversation

@dooriya

Copy link
Copy Markdown

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.


err = proc.Wait()
close(done)
wasCanceled := ctx.Err() != nil
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

2 participants