Skip to content

feat: implement OOD query filtering in bot logic and enforce scoped i…#11

Open
kpj2006 wants to merge 3 commits into
AOSSIE-Org:mainfrom
kpj2006:main
Open

feat: implement OOD query filtering in bot logic and enforce scoped i…#11
kpj2006 wants to merge 3 commits into
AOSSIE-Org:mainfrom
kpj2006:main

Conversation

@kpj2006

@kpj2006 kpj2006 commented Jun 19, 2026

Copy link
Copy Markdown
Member

…nteraction guidelines via .clinerules

Addressed Issues:

Fixes #(issue number)

Screenshots/Recordings:

Additional Notes:

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

  • New Features

    • Bot now prompts users to clarify their topic when questions fall outside supported help areas (setup, README, contributing, debugging).
  • Bug Fixes

    • Fixed message handling for threaded conversations to correctly identify relevant channels.

@github-actions github-actions Bot added no-issue-linked PR is not linked to any issue backend Changes to backend code python Python code changes size/M Medium PR (51-200 lines changed) labels Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@kpj2006, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 35 minutes and 51 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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 credits.

🚦 How do rate limits work?

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

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c0ddd84c-f067-4b5c-8b22-15b4a376fefb

📥 Commits

Reviewing files that changed from the base of the PR and between 5f1554e and 15db778.

📒 Files selected for processing (1)
  • bot.py

Walkthrough

Adds an out-of-domain query guard to bot.py via a new is_query_covered() helper that keyword-matches the user query and thread context against supported categories. Integrates it into process_message to override the prompt with a clarification request and log a gap entry. Also fixes thread-aware channel ID resolution. Updates .clinerules with a matching guidance block.

Changes

OOD Query Guard and Thread Channel Routing

Layer / File(s) Summary
Clarifying rule and is_query_covered helper
.clinerules, bot.py
.clinerules gains an OOD-query guidance block; bot.py adds is_query_covered(query, context) which lowercases both inputs and scans predefined keyword categories to return a boolean coverage result.
process_message thread routing fix and insufficient_info branch
bot.py
Channel detection now uses the parent channel ID for threaded messages. An is_query_covered gate overrides full_prompt with a clarification-request instruction and records an insufficient_info gap entry when no keyword category matches.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Python Lang

Poem

🐇 Hop, hop — if your question strays,
The bot won't wander in a maze!
It checks the keywords, finds the gap,
Then asks you back with a friendly tap.
"Setup, README, or a bug to fix?"
Stay on track — that's the clever trick! 🌿

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: implementing OOD query filtering and enforcing scoped interaction guidelines through .clinerules, which directly aligns with the file modifications.
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.

@github-actions github-actions Bot added repeat-contributor PR from an external contributor who already had PRs merged needs-review labels Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
Messages
📖

⚠️ PR Template Check

These are non-blocking, but please fix:

  • Please replace the placeholder Fixes #(issue number) with the actual issue number (e.g. Fixes #42).

  • Some required checklist items are not completed:

  • My PR addresses a single issue

  • My code follows the project's code style

  • My changes generate no new warnings or errors

Generated by 🚫 dangerJS against 15db778

@kpj2006 kpj2006 added the gsoc label Jun 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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.

Inline comments:
In `@bot.py`:
- Around line 166-182: The is_query_covered function currently checks if
keywords exist in either the current query or the entire conversation context
history, which allows past in-domain messages to incorrectly mark a new
out-of-domain query as covered. Remove the context checking from the keyword
matching logic in the is_query_covered function by changing the condition that
currently checks both query and context to only check the current query. This
ensures coverage determination is based solely on the current user query and not
the entire thread history.
- Around line 166-182: The keyword matching in the is_query_covered function
uses simple substring checks (kw in q and kw in ctx) which cause false positives
with short keywords like "pr" matching unrelated words like "price". Replace the
substring matching logic with word boundary checking to ensure only complete
words are matched, not partial substrings. Consider using regular expressions
with word boundaries (\b) to check if each keyword in the categories dictionary
appears as a whole word in the query or context strings rather than allowing
arbitrary substring matches.
- Around line 192-196: In the is_in_configured_channel assignment, replace the
attribute access `message.channel.parent.id` with `message.channel.parent_id`
when is_in_thread is true. The parent attribute can be None when the parent
channel is unavailable in the client cache (in discord.py 2.3.2), which causes
an AttributeError when dereferencing .id. The parent_id attribute is always
stable and available, so use that instead for the channel ID comparison.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8e50c4d3-a666-4955-8623-21261ec8842a

📥 Commits

Reviewing files that changed from the base of the PR and between 1cbd1a4 and 5f1554e.

📒 Files selected for processing (2)
  • .clinerules
  • bot.py

Comment thread bot.py Outdated
Comment thread bot.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Changes to backend code gsoc needs-review no-issue-linked PR is not linked to any issue python Python code changes repeat-contributor PR from an external contributor who already had PRs merged size/M Medium PR (51-200 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant