Skip to content

Improve user-facing error messages for context canceled/deadline exceeded#67

Merged
ianhodge merged 1 commit intomainfrom
oz/improve-context-canceled-error-messages
May 6, 2026
Merged

Improve user-facing error messages for context canceled/deadline exceeded#67
ianhodge merged 1 commit intomainfrom
oz/improve-context-canceled-error-messages

Conversation

@ianhodge
Copy link
Copy Markdown
Member

@ianhodge ianhodge commented May 6, 2026

Problem

When a cloud agent task fails due to a context.Canceled error (e.g., infrastructure-level context cancellation after 34 minutes of execution), the user sees the opaque message:

Failed to execute task: context canceled

This is the raw Go error string formatted with fmt.Sprintf("Failed to execute task: %v", err), providing no actionable information.

Solution

Add userFacingTaskError() to translate well-known infrastructure errors into clear, user-facing messages before sending them as TaskFailed messages to the server.

New error messages

  • context.Canceled:

    "The task was interrupted due to an infrastructure issue (context canceled). This is typically transient — please try again."

  • context.DeadlineExceeded:

    "The task exceeded its maximum allowed execution time and was terminated. Consider breaking the task into smaller steps or increasing the timeout."

  • Other errors: Preserve existing "Failed to execute task: <err>" format.

Changes

  • errors.go: Added userFacingTaskError() function
  • worker.go: Updated executeTask() to use userFacingTaskError(err) instead of fmt.Sprintf("Failed to execute task: %v", err)
  • worker_test.go: Added tests for context canceled/deadline exceeded scenarios and unit tests for userFacingTaskError()

Companion PR

Server-side defense-in-depth for these errors is in the warp-server companion PR, which adds context.Canceled/context.DeadlineExceeded cases to FromError() in the platformerrors package.

Conversation: https://staging.warp.dev/conversation/827c8486-edd0-4431-bb34-bda17e042c18
Run: https://oz.staging.warp.dev/runs/019dfe67-8ddc-7a9a-a8f4-cf95f003a682
This PR was generated with Oz.

…eded

Replace the raw 'Failed to execute task: context canceled' message with
clear, actionable error messages when the backend returns context.Canceled
or context.DeadlineExceeded errors.

Add userFacingTaskError() that translates well-known infrastructure errors
into human-readable messages:

- context.Canceled: 'The task was interrupted due to an infrastructure
  issue (context canceled). This is typically transient — please try
  again.'
- context.DeadlineExceeded: 'The task exceeded its maximum allowed
  execution time and was terminated. Consider breaking the task into
  smaller steps or increasing the timeout.'
- Other errors: preserve existing 'Failed to execute task: <err>' format

Co-Authored-By: Oz <oz-agent@warp.dev>
@ianhodge ianhodge requested review from a team and bnavetta May 6, 2026 18:49
@ianhodge ianhodge marked this pull request as ready for review May 6, 2026 19:34
@ianhodge ianhodge merged commit 601f630 into main May 6, 2026
8 checks passed
@ianhodge ianhodge deleted the oz/improve-context-canceled-error-messages branch May 6, 2026 20:45
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.

2 participants