Skip to content

fix: channel token drift alert#842

Open
sharifajahanshaik wants to merge 1 commit into
juspay:releasefrom
sharifajahanshaik:fix-channel-token-drift-alert
Open

fix: channel token drift alert#842
sharifajahanshaik wants to merge 1 commit into
juspay:releasefrom
sharifajahanshaik:fix-channel-token-drift-alert

Conversation

@sharifajahanshaik

@sharifajahanshaik sharifajahanshaik commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed resource cleanup behavior in call lifecycle handlers. Resource releases now properly consider call direction and execution mode, improving stability across different call types.
    • Enhanced accuracy of call processing count queries to better reflect active dispatcher-eligible outbound calls, reducing potential tracking errors.

Copilot AI review requested due to automatic review settings June 17, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b12300b0-0a4b-47ad-ac20-bd902bf667b1

📥 Commits

Reviewing files that changed from the base of the PR and between cd803b3 and d567740.

📒 Files selected for processing (2)
  • app/ai/voice/agents/breeze_buddy/managers/calls.py
  • app/database/queries/breeze_buddy/dispatch.py

Walkthrough

Three call lifecycle handlers (reconcile_stuck_processing_leads, handle_call_completion, handle_unanswered_calls) now gate outbound-number release and channel-token semaphore return on call_direction == OUTBOUND and is_dispatchable(execution_mode) in addition to outbound_number_id. The count_processing_by_outbound_number_query SQL query gains matching call_direction and execution_mode predicates.

Changes

Outbound + Dispatchable Release Gating

Layer / File(s) Summary
Processing count query restricted to outbound dispatchable leads
app/database/queries/breeze_buddy/dispatch.py
count_processing_by_outbound_number_query adds call_direction = 'OUTBOUND' and execution_mode IN ('TELEPHONY', 'TELEPHONY_TEST') SQL predicates; docstring updated to describe the dispatcher-owned token scope and exclusion of inbound/non-dispatchable legs.
Call handler resource release gated on outbound + dispatchable
app/ai/voice/agents/breeze_buddy/managers/calls.py
reconcile_stuck_processing_leads, handle_call_completion, and handle_unanswered_calls each tighten the outbound-number/channel-token release condition to require call_direction == OUTBOUND and is_dispatchable(execution_mode) in addition to outbound_number_id.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • juspay/clairvoyance#773: Also modifies calls.py to add is_dispatchable(lead.execution_mode) gating to prevent non-dispatchable leads from participating in call lifecycle cleanup and retry scheduling.

Poem

🐇 Hoppity-hop through the call dispatch lane,
Only outbound and dispatchable leads shall claim!
No inbound imposters shall steal the token away,
The semaphore rests safely at end of day.
Consistent gates on query and handler in sync —
A tidy resource garden, no leaks at the brink! 🌸

🚥 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: channel token drift alert' directly addresses the main change: fixing a channel token drift alert by refining resource cleanup logic for outbound-dispatchable calls.
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

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.

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