Skip to content

fix: make gateway reliability safe by default (#3438) - #3442

Merged
MervinPraison merged 2 commits into
mainfrom
claude/issue-3438-20260727-0929
Jul 29, 2026
Merged

fix: make gateway reliability safe by default (#3438)#3442
MervinPraison merged 2 commits into
mainfrom
claude/issue-3438-20260727-0929

Conversation

@praisonai-triage-agent

Copy link
Copy Markdown
Contributor

Fixes #3438

Summary

The gateway shipped an unsafe default reliability posture: running it the obvious way (BotOS(agent=...), praisonai gateway start, or a minimal gateway.yaml) gave no admission ceiling and only a 5s drain, so a burst could fan out unboundedly and a rolling restart could cut in-flight turns. The production machinery already existed β€” only the default was unsafe.

This changes the unset (None) posture that resolve_reliability resolves to a safe-by-default deployment, keying off bind posture, keeping all explicit overrides:

  • Unset + loopback bind β†’ bounded admission ceiling + fair wait queue + strict outbound ordering, with a snappy 5s drain.
  • Unset + non-loopback bind (a real deployment) β†’ the full production window (15s drain).
  • reliability="off" β†’ explicit opt-out to today's immediate-teardown / no-backpressure behaviour.
  • reliability="default" β†’ the explicit legacy posture (5s drain, no ceiling) for callers who ask for it.
  • Explicit drain_timeout / max_concurrent_runs / admission_policy still always win.

Changes

  • bots/_reliability.py: add bind_host-aware default resolution + _is_externally_bound helper; unset posture now yields admission + drain; docstrings updated.
  • cli/features/gateway.py: always resolve reliability in the no-config path and thread the bind host so an external bind comes up with backpressure.
  • Tests updated/added in test_reliability.py and test_outbox_ordering.py.

Layer placement

Wrapper (praisonai-bot gateway runtime). No new public knobs added β€” only the default value each of the existing CLI/YAML/Python surfaces resolves to.

Test plan

  • python -m pytest src/praisonai-bot/tests/unit/bots/test_reliability.py test_outbox_ordering.py β€” 36 passed
  • Remaining bots-suite failures confirmed pre-existing (missing pydantic/aiohttp optional deps), unrelated to this change

Generated with Claude Code

The unset (None) reliability posture now resolves to a backpressured
deployment β€” bounded admission ceiling + fair wait queue + graceful drain β€”
instead of the old no-admission one. It is bind-aware: a non-loopback bind
(a real deployment) resolves to the full production window, loopback keeps a
snappy 5s drain. reliability="off" opts back into today's immediate-teardown
behaviour; explicit reliability="default" keeps the legacy no-ceiling posture.

Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
@MervinPraison

Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison

Copy link
Copy Markdown
Owner

/review

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more β†’

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account β†’

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us β†’

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
βœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@MervinPraison, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f290f13-4992-474f-822a-a66a599ed497

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 54b4334 and 03b0d93.

πŸ“’ Files selected for processing (4)
  • src/praisonai-bot/praisonai_bot/bots/_reliability.py
  • src/praisonai-bot/praisonai_bot/cli/features/gateway.py
  • src/praisonai-bot/tests/unit/bots/test_outbox_ordering.py
  • src/praisonai-bot/tests/unit/bots/test_reliability.py
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-3438-20260727-0929

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@praisonai-triage-agent praisonai-triage-agent Bot added pipeline/blocked:ci Blocked: CI not green on HEAD pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet pipeline/final-claude-pending Reviews done; waiting for FINAL @claude labels Jul 27, 2026
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the gateway’s unset reliability posture safe by default.

  • Adds bind-aware reliability resolution with bounded admission, queueing, strict outbound ordering, and appropriate drain windows.
  • Applies reliability resolution to no-config CLI startup.
  • Preserves explicit default, off, and caller-provided overrides.
  • Adds coverage for loopback classification, admission defaults, drain behavior, and outbound ordering.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains, and the prior loopback-classification issue is addressed through IP-based loopback detection with regression coverage.

Important Files Changed

Filename Overview
src/praisonai-bot/praisonai_bot/bots/_reliability.py Introduces bind-aware safe defaults and fixes the previously reported handling of noncanonical loopback IP addresses using numeric IP classification.
src/praisonai-bot/praisonai_bot/cli/features/gateway.py Always resolves reliability in no-config startup and passes the effective bind host into resolution.
src/praisonai-bot/tests/unit/bots/test_reliability.py Covers safe defaults, external and loopback drain windows, explicit legacy behavior, and the prior loopback-address finding.
src/praisonai-bot/tests/unit/bots/test_outbox_ordering.py Updates ordering expectations for the new safe unset posture while preserving explicit legacy presets.

Reviews (2): Last reviewed commit: "fix: recognize all loopback bind forms i..." | Re-trigger Greptile

Comment thread src/praisonai-bot/praisonai_bot/bots/_reliability.py Outdated
@MervinPraison

Copy link
Copy Markdown
Owner

@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

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.
  6. Repo routing: agent-callable tools β†’ PraisonAI-Tools; lifecycle plugins β†’ PraisonAI-Plugins; optional sandbox backends β†’ PraisonAI-Plugins (praisonai.sandbox entry point) β€” request changes if wrongly added to praisonaiagents/

Phase 2: FIX Valid Issues
7. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
8. Also independently identify and fix any gaps or issues you find in the changed code β€” do not rely only on prior reviewer feedback
9. Push all code fixes directly to THIS branch (do NOT create a new PR)
10. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
11. If all issues are resolved, approve the PR / close the Issue
12. If blocking issues remain, request changes / leave clear action items

1 similar comment
@MervinPraison

Copy link
Copy Markdown
Owner

@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

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions
  4. SDK value: review in depth whether the change genuinely adds value to the SDK β€” never add features for the sake of adding them. It must strengthen the SDK (simpler, more user-friendly, robust, world-class, secure). If it does not clearly add value, request changes or recommend rejecting/closing rather than merging scope creep
  5. Do not bloat the Agent class with additional params β€” only if absolutely required; we already support many params.
  6. Repo routing: agent-callable tools β†’ PraisonAI-Tools; lifecycle plugins β†’ PraisonAI-Plugins; optional sandbox backends β†’ PraisonAI-Plugins (praisonai.sandbox entry point) β€” request changes if wrongly added to praisonaiagents/

Phase 2: FIX Valid Issues
7. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
8. Also independently identify and fix any gaps or issues you find in the changed code β€” do not rely only on prior reviewer feedback
9. Push all code fixes directly to THIS branch (do NOT create a new PR)
10. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
11. If all issues are resolved, approve the PR / close the Issue
12. If blocking issues remain, request changes / leave clear action items

@MervinPraison MervinPraison added pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:cooldown Blocked: post-push or @claude cooldown and removed pipeline/final-claude-pending Reviews done; waiting for FINAL @claude pipeline/blocked:no-final Blocked: no FINAL @claude trigger yet labels Jul 27, 2026
@praisonai-triage-agent

praisonai-triage-agent Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review β€” PR #3442 βœ…

  • Read AGENTS.md + repo guidelines
  • Review changed files (_reliability.py, gateway.py, tests)
  • Assess reviewer feedback (Greptile loopback classification)
  • Fix valid issue + add tests
  • Run tests β€” 37 passed
  • Push to branch

Phase 1 β€” Architecture review (per AGENTS.md)

Check Verdict
Layer placement βœ… Correct. All changes in the wrapper (praisonai-bot gateway runtime). Core praisonaiagents/ untouched. No praisonai-rust/praisonai-ts touched.
Protocol-driven βœ… No heavy impl leaks into core; resolve_reliability composes onto existing BotOS args.
Backward compatible βœ… Explicit drain_timeout/max_concurrent_runs/admission_policy and reliability="default"/"off" all preserve prior behaviour. Only the unset posture changes β€” the stated intent of #3438.
Performance βœ… Resolution runs once at gateway startup, not on any hot path.
SDK value βœ… Genuine hardening: a safe-by-default deployment posture without adding public knobs. Not scope creep.
No Agent bloat βœ… Agent class not modified; no new params.

Phase 2 β€” Fixes implemented

Greptile finding (valid): _is_externally_bound used a literal allowlist (127.0.0.1, ::1, …), so valid loopback binds like 127.0.0.2, 127.255.255.255, and expanded 0:0:0:0:0:0:0:1 were misclassified as external and given the 15s production drain instead of the intended 5s loopback window.

Fix (bots/_reliability.py): classify loopback numerically via the stdlib ipaddress module (ip_address(...).is_loopback), keeping the known non-IP hostnames ("", localhost, loopback) as an explicit allowlist. A literal IP that isn't loopback β†’ external; a non-IP DNS name β†’ external (conservative, correct). No new deps, no new public surface.

Test (test_reliability.py): added test_unset_noncanonical_loopback_bind_stays_snappy covering 127.0.0.2, 127.255.255.255, 0:0:0:0:0:0:0:1, and [::1].

Files modified this review:

  • src/praisonai-bot/praisonai_bot/bots/_reliability.py
  • src/praisonai-bot/tests/unit/bots/test_reliability.py

Skipped: Qodo (reviews paused) and CodeRabbit (rate-limited) left no actionable items; no other reviewer findings outstanding.

Phase 3 β€” Verdict

βœ… Approve. The change is minimal, backward-compatible, correctly layered in the wrapper, and the one valid reviewer finding is now fixed with coverage. python -m pytest test_reliability.py test_outbox_ordering.py β†’ 37 passed.

Note: I can't submit a formal GitHub approval (disabled for security); treating this as an approving review.

Commit: becf0f30f Β· Β· Branch: claude/issue-3438-20260727-0929

Classify loopback numerically via ipaddress so 127.0.0.2,
127.255.255.255, and expanded IPv6 ::1 keep the snappy loopback drain
instead of the 15s production window. Addresses Greptile review feedback.

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@praisonai-triage-agent

Copy link
Copy Markdown
Contributor Author

@claude CI failed on HEAD becf0f30. Please fix the failures below and push to this branch.

Failed checks

Failures (extracted)

(Could not extract pytest details β€” see job logs above.)

Critical review first

Before changing code or tests, decide which side is wrong:

  1. Legitimate feature change β€” the PR intent is correct but implementation or tests need updating. Preserve SDK guarantees; update tests only when behaviour intentionally changed and document why.
  2. Regression / bug in this PR β€” the failure exposes a real breakage introduced here. Fix the implementation; do not weaken, skip, or delete tests just to go green.
  3. Pre-existing flake or unrelated failure β€” say so explicitly; prefer fixing the root cause over masking it.

SDK guardrails (AGENTS.md):

  • Agent-callable tools β†’ PraisonAI-Tools; lifecycle plugins β†’ PraisonAI-Plugins; sandbox backends β†’ PraisonAI-Plugins (praisonai.sandbox) β€” not praisonaiagents/.
  • Do not disturb core SDK contracts to accommodate a wrapper/feature change.
  • Tests must continue to guard backward compatibility and hot-path behaviour β€” passing CI by lowering test standards is not acceptable.
  • If the feature does not genuinely add SDK value, recommend reverting or narrowing scope instead of patching around failures.

What to do

  1. State your verdict: legitimate fix, regression fix, or needs human review β€” and why (1–3 sentences).
  2. Fix root cause with minimal changes; never bloat the Agent class with extra params.
  3. Run failing tests locally with targeted pytest, plus any related SDK tests touched by the PR.
  4. Push to this branch and comment: files changed, review verdict, and why tests still protect SDK behaviour.

@praisonai-triage-agent

praisonai-triage-agent Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review + CI Triage β€” PR #3442 βœ…

  • Investigate CI failure on HEAD becf0f30
  • Review changed files (_reliability.py, gateway.py, tests)
  • Run tests locally
  • Verdict

CI failure triage β€” verdict: pre-existing infra flake, not a code regression

The three failing checks are not test failures. All three are GitHub API rate-limit (403) errors inside orchestration workflow scripts β€” nothing to do with the PR code:

Check Root cause
detect-and-trigger (Γ—2) 403 API rate limit exceeded for user ID 454862 in .github/scripts/merge-gate.js β†’ ci-failure-claude.js (loadPrContext)
claude-review-recovery Same 403 rate limit in "Sync pipeline status labels" (x-ratelimit-remaining: 0)

These are transient GitHub-API rate limits on the actor account, not a breakage introduced by this PR. They fix themselves once the limit window resets (a re-run will pass). No code or test change can address them, and per the guardrails I will not weaken/skip any tests to go green.

The actual pytest suite for this PR passes locally:

python -m pytest tests/unit/bots/test_reliability.py tests/unit/bots/test_outbox_ordering.py
37 passed

(The triage message's "Could not extract pytest details" is because there were no pytest details β€” the failing jobs never ran pytest.)


Phase 1 β€” Architecture review (per AGENTS.md)

Check Verdict
Layer placement βœ… All changes in the wrapper (praisonai-bot gateway runtime). Core praisonaiagents/ untouched; no praisonai-rust/praisonai-ts.
Protocol-driven βœ… resolve_reliability composes onto existing BotOS args; no heavy impl leaks into core.
Backward compatible βœ… Explicit drain_timeout/max_concurrent_runs/admission_policy and reliability="default"/"off" preserve prior behaviour. Only the unset posture changes β€” the exact intent of #3438.
Performance βœ… Resolution runs once at gateway startup; not on any hot path.
SDK value βœ… Genuine hardening (safe-by-default deployment) with no new public knobs β€” not scope creep.
No Agent bloat βœ… Agent class unmodified; no new params.
Routing βœ… Wrapper CLI/runtime change; correctly placed.

Phase 2 β€” Reviewer findings

  • Greptile β€” loopback allowlist: already fixed in becf0f30f. _is_externally_bound now classifies loopback numerically via ipaddress.is_loopback, so 127.0.0.2, 127.255.255.255, 0:0:0:0:0:0:0:1, [::1] all resolve to the snappy loopback drain. Verified all edge cases pass:
    127.0.0.2, 127.255.255.255, 0:0:0:0:0:0:0:1, [::1] β†’ loopback (snappy)
    0.0.0.0, ::, 192.168.1.5, example.com          β†’ external (production)
    
  • Qodo / CodeRabbit: reviews paused / rate-limited β€” no actionable items left.

No additional bugs or gaps found on independent review.

Phase 3 β€” Verdict

βœ… Approve. The change is minimal, backward-compatible, correctly layered in the wrapper, and the one valid reviewer finding is already fixed with coverage (37 passed). The reported CI failures are transient GitHub-API rate limits in workflow orchestration, unrelated to this PR β€” a re-run should clear them. No code changes required.

Note: I can't submit a formal GitHub approval (disabled for security); treat this as an approving review. No new commit β€” nothing to fix in the PR code.
Β· Branch: claude/issue-3438-20260727-0929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-ci-fix-pending pipeline/awaiting-merge-gate FINAL done; waiting for merge gate / CI pipeline/blocked:ci Blocked: CI not green on HEAD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway ships an unsafe default reliability posture β€” no admission ceiling and restarts cut in-flight turns unless the operator opts in

1 participant