Skip to content

fix: skip rate limit evaluation for inactive templates#763

Open
amreetkhuntia wants to merge 1 commit into
juspay:releasefrom
amreetkhuntia:fix/skip-inactive-template-leads
Open

fix: skip rate limit evaluation for inactive templates#763
amreetkhuntia wants to merge 1 commit into
juspay:releasefrom
amreetkhuntia:fix/skip-inactive-template-leads

Conversation

@amreetkhuntia
Copy link
Copy Markdown
Contributor

@amreetkhuntia amreetkhuntia commented May 15, 2026

Only run outbound rate limit check when the template is active. Inactive templates still proceed through the full call flow.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved handling of inactive templates in telephony call processing. Rate-limiting logic now correctly skips when templates are inactive, ensuring more accurate call queue management.

Review Change Stack

Copilot AI review requested due to automatic review settings May 15, 2026 11:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2346941a-4648-4582-9b7a-68a33f0fc61f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR refines the outbound rate-limit/deferral logic in process_backlog_leads by adding template active-state validation. The conditional guard now requires both ExecutionMode.TELEPHONY execution mode and an active (or absent) template before applying rate-limit checks, preventing deferral of leads matched to inactive templates.

Changes

Template active-state gating for rate-limit deferral

Layer / File(s) Summary
Template active-state check for TELEPHONY rate-limit gating
app/ai/voice/agents/breeze_buddy/managers/calls.py
The conditional guard around outbound rate-limit/deferral behavior is updated to require (template is None or template.is_active) alongside ExecutionMode.TELEPHONY, skipping rate-limit logic when a template is inactive.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • juspay/clairvoyance#720: Updates process_backlog_leads rate-limit/deferral gating based on ExecutionMode.TELEPHONY.
  • juspay/clairvoyance#330: Modifies process_backlog_leads in the breeze_buddy calls manager with stuck-lead cleanup and retry flow changes.

Suggested reviewers

  • priyanshi-2003
  • manas-narra
  • yugesh-ganipudi
  • narsimhaReddyJuspay

Poem

A template may rest, yet the deferral goes on,
Now Breeze Buddy checks: "Is this template alive?"
No more wasted waits on a template gone wrong—
Each lead finds the path where true templates survive. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: skip rate limit evaluation for inactive templates' directly and accurately summarizes the main change: conditional gating of rate-limit logic based on template active status.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

 Only run outbound rate limit check when the template is active.
 Inactive templates still proceed through the full call flow.
@amreetkhuntia amreetkhuntia force-pushed the fix/skip-inactive-template-leads branch from 6d22dc7 to 4c70429 Compare May 15, 2026 11:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts Breeze Buddy’s backlog lead processing so outbound rate-limit checks are only evaluated for active templates, avoiding rate-limit blocking/alerting for inactive templates while keeping the rest of the call flow unchanged.

Changes:

  • Gate check_outbound_rate_limit_and_alert() behind template.is_active for telephony leads.
  • Preserve existing behavior for leads that continue through the full call placement flow.

Comment on lines +579 to +581
if locked_lead.execution_mode == ExecutionMode.TELEPHONY and (
template is None or template.is_active
):
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/ai/voice/agents/breeze_buddy/managers/calls.py (1)

579-581: ⚡ Quick win

Consider adding observability logging when rate-limit check is skipped for inactive templates.

When an inactive template causes the rate-limit check to be bypassed, there's no log entry explaining this decision. This could make debugging and monitoring more difficult, especially when investigating why certain calls were not rate-limited.

📊 Proposed logging enhancement
+                if locked_lead.execution_mode == ExecutionMode.TELEPHONY and template and not template.is_active:
+                    logger.info(
+                        f"Skipping rate limit check for lead {locked_lead.id} - template {locked_lead.template} is inactive"
+                    )
                 if locked_lead.execution_mode == ExecutionMode.TELEPHONY and (
                     template is None or template.is_active
                 ):
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/ai/voice/agents/breeze_buddy/managers/calls.py` around lines 579 - 581,
The rate-limit check is currently gated by the condition using
locked_lead.execution_mode and template.is_active, but when a template exists
and is inactive the check is silently bypassed; add an observability log right
where the condition is evaluated (around the if using locked_lead, template, and
ExecutionMode.TELEPHONY) to emit a clear message when template is present but
inactive and therefore the rate-limit check is skipped, including identifiers
like locked_lead.id and template.id (and execution mode) to aid debugging and
monitoring.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/ai/voice/agents/breeze_buddy/managers/calls.py`:
- Around line 579-581: The rate-limit check is currently gated by the condition
using locked_lead.execution_mode and template.is_active, but when a template
exists and is inactive the check is silently bypassed; add an observability log
right where the condition is evaluated (around the if using locked_lead,
template, and ExecutionMode.TELEPHONY) to emit a clear message when template is
present but inactive and therefore the rate-limit check is skipped, including
identifiers like locked_lead.id and template.id (and execution mode) to aid
debugging and monitoring.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b64b08a3-b8c8-43ca-b3b2-15cbb9e42f07

📥 Commits

Reviewing files that changed from the base of the PR and between 8c19455 and 6d22dc7.

📒 Files selected for processing (1)
  • app/ai/voice/agents/breeze_buddy/managers/calls.py

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