fix: extract shared _retry_backoff helper in workflows.py - #3833
fix: extract shared _retry_backoff helper in workflows.py#3833praisonai-triage-agent[bot] wants to merge 1 commit into
Conversation
The step retry exponential-backoff + progress-print block was duplicated byte-for-byte between the top-level _run_impl loop and the shared _apply_step_policies helper. Extract it into a single private _retry_backoff() used by both paths. Behaviour is unchanged: same 2**(retry_count-1) timing, same verbose print, same time.sleep. All retryability, guardrail, on_step_error and guardrail_failed semantics are preserved. Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
|
@coderabbitai review |
|
/review |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more β On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
β Action performedReview finished.
|
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: π Files selected for processing (1)
π WalkthroughWalkthroughThe workflow retry backoff logic now uses a shared ChangesWorkflow retry backoff
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: π₯ Pre-merge checks | β 5β Passed checks (5 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR extracts duplicated retry delay and progress-reporting logic into a private static helper without changing retry semantics.
Confidence Score: 5/5The PR appears safe to merge with no actionable regressions identified. Both retry paths invoke a shared helper containing the same backoff calculation, verbose message, and sleep behavior as the removed inline blocks.
|
| Filename | Overview |
|---|---|
| src/praisonai-agents/praisonaiagents/workflows/workflows.py | Consolidates two equivalent retry-backoff blocks into one helper while preserving their arguments, conditions, output, and timing. |
Reviews (1): Last reviewed commit: "fix: extract shared _retry_backoff helpe..." | Re-trigger Greptile
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task ββ View job Final Architecture Review β PR #3833 β Approved
Phase 1 β Architecture Review (AGENTS.md)
Phase 2 β Issue FixesReviewed CodeRabbit, Greptile, and Qodo comments β no actionable issues were raised (CodeRabbit: "No actionable comments"; Greptile: 5/5 confidence, safe to merge). Independent review β verified the two call sites and the helper:
Confirmed preserved on the top-level path: No fixes required. No files modified. Phase 3 β Verdictβ Approve. The change is minimal, lightweight, backward-compatible, and genuinely reduces duplication with zero behavioural change. Tests: Note: I cannot submit a formal GitHub approval (bot security restriction), but this is my approving architecture review. Safe to merge. |
Fixes #3832
Summary
The step retry exponential-backoff + progress-print block was duplicated byte-for-byte between two places in
praisonaiagents/workflows/workflows.py:_run_implloop, and_apply_step_policieshelper.This PR takes the minimal, sanctioned interim path from the issue: extract just the duplicated retry-delay-and-print into a single private
Workflow._retry_backoff(step, retry_count, max_retries, error, verbose)helper, and call it from both paths.What changed
_retry_backoffstaticmethod containing the2 ** (retry_count - 1)backoff, the byte-identical verbose progress line, andtime.sleep(...)._run_implwith a call to it._apply_step_policieswith a call to it.Behaviour preserved (zero change)
2 ** (retry_count - 1)),max_retriessemantics, and theis_retryableearly-break.validation_feedbackpropagation, retry-on-invalid.on_step_errorcallback firing and theguardrail_failedflag / downstreamstep_failedhandling (left exactly as-is on the top-level path).output_filewriting behaviour.The larger "fold the whole per-step body into a
run_bodyclosure" merge was intentionally not done: it would require converting ~140 lines of the top-level loop body into a closure and threadingon_step_error/guardrail_failedback out β invasive and risky. This change removes the most-copied lines with no behaviour change, per AGENTS.md (lightweight, minimal, backward-compatible).Testing
tests/test_workflow_patterns.pyβ 86 passedtests/test_validation_feedback.pyβ 6 passedtests/unit/workflows/β 129 passed (5 pre-existing failures are unrelatedlitellmoptional-dependency import errors)Generated with Claude Code
Summary by CodeRabbit