← Back to Pull requests

fix(retry): report IncompleteOutputException to error hooks #3088

Open
unknown opened this pull request with 171 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 20, 2026 07:32 UTC
Author

Describe your changes

When a response hits the token limit, the v2 retry loop re-raises IncompleteOutputException without emitting any hook, so completion:error and completion:last_attempt handlers never see it. v1 emitted completion:error for this case, and the "Error Handling" example in docs/concepts/hooks.md branches on IncompleteOutputException inside a completion:error handler.

This change emits completion:error and completion:last_attempt with is_last_attempt=True before re-raising. Terminal API errors already get the same treatment. Both the sync and async loops share one small helper. TokenBudgetError handling is unchanged, and the exception type that callers see is unchanged.

Tests: added sync and async cases to tests/v2/test_retry_runtime.py. Both fail on main (no hooks emitted) and pass with this change. uv run pytest tests/ -k "not llm and not docs": 5647 passed, 213 skipped. ruff check/ruff format --check and ty check on the touched files are clean.

Issue ticket number and link

Fixes #3087

Checklist before requesting a review

  • I have performed a self-review of my code

  • If it is a core feature, I have added thorough tests.

  • If it is a core feature, I have added documentation. (CHANGELOG entry added under Unreleased; the existing hooks docs already describe this behavior)
  • Diff: 171 lines (+128 / -43) across 2 files Reviewer: ychampion Review duration: 16101m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 171 lines diff across 2 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.308
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #3088"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.4% · Safe to merge
    21.4%