Skip to content

feat: Stricter DevRel classification & GitHubToolkit fixes #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PrithvijitBose
Copy link

@PrithvijitBose PrithvijitBose commented Aug 13, 2025

Closes #93

This PR improves the DevRel agent’s classification logic and fixes issues in the GitHubToolkit, ensuring only relevant messages trigger the agent and reducing false positives.

Key Changes:

ClassificationRouter Enhancements:

  • Fallback stricter: Defaults to needs_devrel=False instead of True.
  • Quick keyword check: Skips unnecessary LLM calls for obviously non-DevRel messages.
  • Boolean enforcement: Ensures needs_devrel is always a real boolean (True/False).
  • Dynamic bot name support: Reads settings.bot_name so any bot name works without code changes.
  • Fallback refinement: Only marks needs_devrel=True if the bot is mentioned and the message is relevant.
  • Output improvement: Adds "bot_mentioned" field for tracking when a mention occurred.

GitHubToolkit Fixes:

  • Resolved 'str' object does not support item assignment error by returning dictionaries instead of strings in unimplemented branches.
  • Ensures LLM-classified results pass through correctly and extra info is added for a clean JSON response.

Effect:

  • Fewer false positives and wasted API calls.
  • Only genuinely relevant messages trigger the DevRel agent.
  • Cleaner and more robust JSON responses from GitHubToolkit.

https://drive.google.com/file/d/1s9lX5iPkRdKDFV8wWVVTX3pxGeBct1DC/view?usp=drive_link

(check this drive to see the output)

Summary by CodeRabbit

  • New Features

    • Bot name is now configurable via environment/settings.
    • Triage respects direct bot mentions, influencing escalation, priority, and returning whether the bot was mentioned.
    • Clearer, structured messages are returned when certain GitHub actions are not yet supported.
  • Documentation

    • Updated environment example file to include BOT_NAME configuration.

Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

Adds bot name configuration and uses it to detect explicit bot mentions in classification; tightens fallback triage to require mentions; adjusts default needs_devrel to False; enriches classification payload with bot_mentioned; updates GitHub toolkit to return structured dicts for unimplemented paths.

Changes

Cohort / File(s) Summary
Configuration: Bot name
backend/app/core/config/settings.py, backend/.env.example
Introduces Settings.bot_name (default "DevRelBot") and adds BOT_NAME to .env.example.
Classification routing
backend/app/classification/classification_router.py
Adds bot mention detection, includes mention note in triage context, changes default needs_devrel to False, updates fallback logic/signature to use mention_flag, and returns bot_mentioned in payload. Docstrings updated to “Strict.”
GitHub toolkit return shape
backend/app/agents/devrel/github/github_toolkit.py
Changes unimplemented branches to return structured dicts with status/message instead of strings.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant CR as ClassificationRouter
  participant LLM as LLM

  U->>CR: Message
  CR->>CR: Detect @bot mention (from Settings.bot_name)
  alt Can call LLM triage
    CR->>LLM: DEVREL_TRIAGE_PROMPT (+mention note if mentioned)
    LLM-->>CR: JSON (needs_devrel?, priority, reasoning)
    CR->>CR: Default needs_devrel=False if missing
  else Fallback
    CR->>CR: _fallback_triage(mention_flag)
  end
  CR-->>U: {needs_devrel, priority, reasoning, bot_mentioned}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Assessment against linked issues

Objective Addressed Explanation
Stricter activation via explicit mention; ignore general chatter (#93)
Update classification prompt with new strict rules (#93) Context includes mention note, but no direct evidence of prompt text/rules changes.
Handle direct project-related questions without mention (#93) Unclear from code whether non-mention, project-specific queries are allowed to trigger.
Review and improve other prompts (agent_prompt, summarization_prompt, etc.) (#93) No changes observed outside classification router context handling.
Reduce false positives post-implementation (#93) Outcome metric; not verifiable from code changes.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Return shape changed to dict for unimplemented paths in execute() (backend/app/agents/devrel/github/github_toolkit.py) Not related to classification prompt strictness or prompt suite review in #93; affects GitHub toolkit behavior.

Poem

I twitch my ears at mentions clear—@devrel, you called my name!
No chatter chase, no random race; I hop to only worthy flame.
With stricter nose and tidy prose, I triage, swift and keen.
A meta nibble, toolkit dribble—our burrow’s running clean. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
backend/app/classification/classification_router.py (1)

59-59: Missing mention_flag parameter in error fallback

The error handler at line 59 calls _fallback_triage(message) without the mention_flag parameter. While Python will use the default value of False, it would be cleaner to explicitly handle the mention detection even in error cases.

Consider preserving the mention flag even in error cases:

         except Exception as e:
             logger.error(f"Triage error: {str(e)}")
-            return self._fallback_triage(message)
+            # Try to detect mention even in error case
+            mention_flag = self.bot_name in message.lower() if message else False
+            return self._fallback_triage(message, mention_flag)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4ff6eb and be441b8.

📒 Files selected for processing (4)
  • backend/.env.example (1 hunks)
  • backend/app/agents/devrel/github/github_toolkit.py (1 hunks)
  • backend/app/classification/classification_router.py (2 hunks)
  • backend/app/core/config/settings.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/app/classification/classification_router.py (1)
backend/app/services/embedding_service/service.py (2)
  • llm (55-68)
  • model (41-52)
🪛 dotenv-linter (3.3.0)
backend/.env.example

[warning] 26-26: [UnorderedKey] The LANGSMITH_PROJECT key should go before the LANGSMITH_TRACING key


[warning] 29-29: [EndingBlankLine] No blank line at the end of the file


[warning] 29-29: [SpaceCharacter] The line has spaces around equal sign


[warning] 29-29: [ValueWithoutQuotes] This value needs to be surrounded in quotes

🔇 Additional comments (8)
backend/app/core/config/settings.py (1)

18-18: No action needed—bot_name is already configurable via .env
Pydantic’s BaseSettings (from pydantic_settings) combined with the top-of-file load_dotenv() call ensures that an environment variable named BOT_NAME will override the default "DevRelBot". The existing Config.env_file = ".env" (plus extra = "ignore") covers loading and ignores unrelated variables, so you can set in your .env:

BOT_NAME=MyCustomBot

and the bot_name field will pick it up.

backend/app/agents/devrel/github/github_toolkit.py (2)

107-107: Good fix for dictionary consistency

The change from returning a plain string to a dictionary ensures consistent return types across all branches, preventing the "'str' object does not support item assignment" error that would occur at lines 120-121.


113-113: Good fix for dictionary consistency

The change ensures a consistent dictionary return type, preventing runtime errors during result augmentation.

backend/app/classification/classification_router.py (5)

11-11: Documentation accurately reflects the stricter classification approach

The updated docstring clearly indicates the shift from simple to strict DevRel triage, aligning with the PR objectives.


14-14: Dynamic bot name support implemented correctly

Good implementation of reading the bot name from settings, enabling flexibility across different deployments without code changes.


24-30: Effective bot mention detection with proper context enrichment

The implementation correctly detects bot mentions and enriches the context for the LLM, which aligns with the PR objective of requiring explicit mentions for DevRel activation.


48-48: Stricter default reduces false positives

Changing the default needs_devrel from True to False is a crucial improvement that aligns with the PR objective of reducing unnecessary DevRel agent invocations.


61-69: Well-designed fallback logic aligns with PR objectives

The fallback triage effectively implements the stricter classification by only triggering DevRel when the bot is mentioned. The priority and reasoning adjustments based on the mention flag provide clear context for downstream processing.

Comment on lines +26 to +29

#Discord Bot Name Configuration
BOT_NAME = "DevRelBot" #Add your own Discord Bot name
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix environment variable syntax and formatting issues

The new BOT_NAME environment variable has incorrect syntax with spaces around the equal sign and missing quotes around the value. Additionally, there are formatting issues that should be addressed.

Apply this diff to fix the syntax and formatting:

 LANGSMITH_PROJECT=
 
-#Discord Bot Name Configuration
-BOT_NAME = "DevRelBot" #Add your own Discord Bot name
+# Discord Bot Name Configuration
+BOT_NAME="DevRelBot" # Add your own Discord Bot name
+

This fixes:

  1. Removes spaces around the equal sign (environment variable syntax)
  2. Adds a space after # in the comment header for consistency
  3. Adds a space after # in the inline comment
  4. Adds a blank line at the end of the file
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LANGSMITH_PROJECT=
#Discord Bot Name Configuration
BOT_NAME = "DevRelBot" #Add your own Discord Bot name
LANGSMITH_PROJECT=
# Discord Bot Name Configuration
BOT_NAME="DevRelBot" # Add your own Discord Bot name
🧰 Tools
🪛 dotenv-linter (3.3.0)

[warning] 26-26: [UnorderedKey] The LANGSMITH_PROJECT key should go before the LANGSMITH_TRACING key


[warning] 29-29: [EndingBlankLine] No blank line at the end of the file


[warning] 29-29: [SpaceCharacter] The line has spaces around equal sign


[warning] 29-29: [ValueWithoutQuotes] This value needs to be surrounded in quotes

🤖 Prompt for AI Agents
In backend/.env.example around lines 26 to 29, the BOT_NAME entry and nearby
comments have incorrect environment variable syntax and formatting; remove
spaces around the equal sign, set the value as BOT_NAME="DevRelBot" (no
surrounding spaces), add a space after the '#' in the comment header and the
inline comment for consistency, and ensure the file ends with a single blank
line.

Comment on lines 110 to 111
result = "Not implemented"
# result = await handle_issue_creation(query)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent return type for issue_creation branch

While you fixed the repo_support and documentation_generation branches to return dictionaries, the issue_creation branch still returns a plain string "Not implemented", which will cause the same error when trying to augment it with intent_analysis and type at lines 120-121.

Apply this diff to maintain consistency:

             elif classification == "issue_creation":
-                result = "Not implemented"
+                result = {"status": "not_implemented", "message": "Issue creation not implemented yet"}
                 # result = await handle_issue_creation(query)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
result = "Not implemented"
# result = await handle_issue_creation(query)
elif classification == "issue_creation":
- result = "Not implemented"
+ result = {"status": "not_implemented", "message": "Issue creation not implemented yet"}
# result = await handle_issue_creation(query)
🤖 Prompt for AI Agents
In backend/app/agents/devrel/github/github_toolkit.py around lines 110-111, the
issue_creation branch returns a plain string "Not implemented" while other
branches return dictionaries; change that branch to return a dictionary (e.g.,
{'result': 'Not implemented'}) so the code downstream can augment it with
intent_analysis and type without errors, and ensure the dict shape matches the
repo_support/documentation_generation branches.

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.

FEATURE REQUEST: Enhance Classification Prompt for Stricter DevRel Query Handling
1 participant