Skip to content

fix(pi): surface provider errors from agent events - #6133

Merged
BillLeoutsakosvl346 merged 1 commit into
stagingfrom
fix/pi-provider-error-surfacing
Jul 31, 2026
Merged

fix(pi): surface provider errors from agent events#6133
BillLeoutsakosvl346 merged 1 commit into
stagingfrom
fix/pi-provider-error-surfacing

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • surface terminal Pi provider errors as failed workflow executions
  • ignore transient provider errors while Pi is retrying
  • add coverage for provider failures, retries, and successful completion

Type of Change

  • Bug fix

Testing

  • 54 targeted Pi tests passing
  • Sim type-check passing
  • lint and repository audits passing
  • tested manually with an invalid provider API key

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 31, 2026 9:03pm

Request Review

@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how Pi cloud runs fail vs succeed when the CLI exits 0, which affects PR creation and git push gating; logic is localized to event normalization with targeted tests.

Overview
Pi agent_end events now drive workflow failure when the run is actually done: if willRetry is true, the event is ignored so transient provider errors during retries do not abort; otherwise the last assistant message with stopReason error or aborted is normalized to an error event (using errorMessage when present). Successful completions still map to final.

Cloud Pi integration tests were updated to simulate this real stream (including zero CLI exit) and assert the run throws with a scrubbed provider message, stops before commit/push/PR (two sandbox commands only).

Reviewed by Cursor Bugbot for commit 9eb6d0c. Bugbot is set up for automated code reviews on this repo. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Demo:

image

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Surface terminal Pi provider errors while preserving retry behavior.

  • Inspect terminal agent_end events for assistant error and aborted stop reasons.
  • Ignore provider errors when Pi explicitly indicates it will retry.
  • Add normalization and cloud-backend coverage for terminal failures, retries, and successful completion.

Confidence Score: 5/5

The PR appears safe to merge with terminal provider errors now propagated without treating explicit retries as failures.

The changed event normalization feeds existing error accumulation and propagation paths, while the retry guard prevents transient failures from prematurely terminating execution.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/pi/events.ts Correctly distinguishes retrying provider failures from terminal error or aborted agent completion events.
apps/sim/executor/handlers/pi/events.test.ts Adds focused coverage for terminal failures, aborted runs, retries, and successful agent completion.
apps/sim/executor/handlers/pi/cloud-backend.test.ts Verifies a zero-exit Pi process with a terminal provider error aborts before repository finalization or PR creation.

Reviews (1): Last reviewed commit: "fix(pi): surface provider errors from ag..." | Re-trigger Greptile

}
case 'agent_end':
case 'agent_end': {
if (ev.willRetry === true) return { type: 'other' }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain what this is doing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if willRetry is yes, then the block should't fail, it should try again. A 429 error is an example.

@BillLeoutsakosvl346
BillLeoutsakosvl346 merged commit c0e7ea9 into staging Jul 31, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/pi-provider-error-surfacing branch August 1, 2026 04:19
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