Skip to content

Example: error handling and failure cascade #27

@JackChen-me

Description

@JackChen-me

Context

The orchestrator supports graceful failure: when a task fails, its dependents are blocked while independent tasks continue. This is documented in the orchestrator's docstring as a key design decision, but no example demonstrates this behavior.

Proposed example: 09-error-handling.ts

A pipeline where one task intentionally fails, showing how the framework handles it:

  • 4 tasks in two branches: A → B and C → D
  • Task A deliberately fails (e.g., calls a nonexistent API or throws an error)
  • Task B is blocked (depends on A)
  • Tasks C and D run and complete successfully
  • Final result shows mixed statuses: completed, failed, blocked
  • Demonstrates TeamRunResult.success === false with partial results still usable

APIs to showcase

  • TaskStatus: 'failed' and 'blocked' states
  • Failure cascade through dependency graph
  • Partial success in TeamRunResult.agentResults
  • Error events in onProgress callback

Acceptance criteria

  • File at examples/09-error-handling.ts
  • npx tsx examples/09-error-handling.ts runs successfully (exits 0 despite partial failure)
  • npm run lint passes
  • Style consistent with existing examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Backlog — revisit after core stabilizesdocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions