Skip to content

Conversation

@robbie-portia
Copy link
Contributor

Description

This PR introduces .on_error() and .ignore_errors() methods to PlanBuilderV2, enabling granular error handling for individual steps within a plan.

Motivation: Previously, any unhandled exception in a step would halt the entire plan. With these new methods, users can now define custom logic to:

  1. Recover from errors: An on_error handler can return a value, which will be used as the step's output, allowing the plan to continue execution.
  2. Propagate errors: The handler can re-raise the exception, causing the plan to fail as before.
  3. Ignore errors: The .ignore_errors() shortcut provides a simple way to swallow exceptions and proceed with None as the step's output.

This significantly enhances the robustness and flexibility of plan execution by providing explicit control over error flow.

Ticket Link: N/A

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Requires sync with platform release
  • Documentation update

Screenshots

N/A

Changelog

  • Added .on_error() and .ignore_errors() to PlanBuilderV2 for per-step error handling.
  • Updated plan executor to respect on_error handlers, allowing for error recovery or explicit propagation.

Open in Cursor Open in Web

This commit introduces the `on_error` and `ignore_errors` methods to the PlanBuilderV2. These allow users to define custom error handling logic for individual steps, enabling more robust and resilient plan execution. The `on_error` method accepts a callable that will be executed when a step fails. If the callable returns a value, that value becomes the step's output, and execution continues. The `ignore_errors` method is a convenience function that sets the error handler to return `None`, effectively skipping over failed steps.

Co-authored-by: robbie <[email protected]>
@cursor
Copy link

cursor bot commented Sep 12, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@openhands-ai
Copy link

openhands-ai bot commented Sep 12, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Python Testing
    • Formatting (ruff)

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #785 at branch `cursor/add-error-handling-to-plan-builder-bcce`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

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