Skip to content

fix: handle context.Canceled in gemini backend to report "aborted" status#929

Open
kuishou68 wants to merge 1 commit intomultica-ai:mainfrom
kuishou68:fix/issue-928-gemini-aborted-status
Open

fix: handle context.Canceled in gemini backend to report "aborted" status#929
kuishou68 wants to merge 1 commit intomultica-ai:mainfrom
kuishou68:fix/issue-928-gemini-aborted-status

Conversation

@kuishou68
Copy link
Copy Markdown
Contributor

Closes #928

Problem

The geminiBackend.Execute goroutine in server/pkg/agent/gemini.go does not handle context.Canceled (user-initiated cancellation). When a task is stopped externally, runCtx.Err() returns context.Canceled, but the code only checks for context.DeadlineExceeded. As a result, user cancellations fall through to the else branch and are reported as "failed" instead of "aborted".

The inline comment says "Distinguish context cancellation (timeout) from exit errors" but the implementation only partially fulfilled that intent.

Fix

Added a context.Canceled branch to mirror the behaviour already present in claude.go:

} else if runCtx.Err() == context.Canceled {
    result.Status = "aborted"
    result.Error = "execution cancelled"
}

This ensures user-initiated cancellations are correctly reported as "aborted" rather than "failed", consistent with all other backends.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multica-web Ignored Ignored Apr 14, 2026 1:12am
multica-web-production Ignored Ignored Apr 14, 2026 1:12am

Request Review

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.

[Bug]: gemini backend reports "failed" instead of "aborted" when task is cancelled by user

1 participant