Skip to content

Conversation

@smokeyScraper
Copy link
Contributor

@smokeyScraper smokeyScraper commented Jul 4, 2025

closes #89

Summary by CodeRabbit

  • New Features

    • Introduced a GitHub toolkit for handling GitHub-related user queries, including web search and general GitHub help.
    • Added a ReAct supervisor agent that iteratively reasons and selects actions (web search, FAQ, onboarding, GitHub toolkit) based on user input.
    • Implemented modular tool wrappers for web search, FAQ, onboarding, and GitHub toolkit actions.
    • Added prompt templates for GitHub help, intent analysis, ReAct reasoning, and response generation.
    • Added a new message triage system to determine if Developer Relations (DevRel) assistance is needed.
  • Improvements

    • Enhanced message triage prompt and logic for DevRel assistance determination.
    • Updated agent workflow to use a supervisor-driven loop for more flexible and modular decision-making.
    • Increased the threshold for conversation summarization, reducing frequency.
  • Bug Fixes

    • Improved error handling and logging throughout agent workflows and tool integrations.
  • Refactor

    • Removed the previous detailed message classification system and replaced it with a simplified triage approach for DevRel routing.
    • Updated configuration defaults for agent models to newer versions.
    • Cleaned up unused code and imports.
  • Chores

    • Added placeholder files for future GitHub toolkit features (contributor recommendation, documentation generation, issue creation).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 4, 2025

Walkthrough

This change restructures the message classification and routing system by removing the ClassificationRouter and related enums from the agents module, introducing a simpler triage-based ClassificationRouter in a new classification package, and refactoring the DevRel agent to use a ReAct supervisor pattern with modular tool wrappers, including a new GitHub toolkit integration. Several prompt templates and tool handler stubs are added or updated.

Changes

File(s) Change Summary
backend/app/agents/init.py, backend/app/agents/classification_router.py, backend/app/agents/devrel/prompts/base_prompt.py, backend/app/agents/devrel/state.py Removed the old ClassificationRouter, its exports, enums, and a base prompt. Deleted a placeholder state file.
backend/app/classification/classification_router.py, backend/app/classification/prompt.py Added a new, simplified ClassificationRouter for DevRel triage and its prompt template.
backend/integrations/discord/bot.py Updated to use the new triage-based ClassificationRouter, replacing classification logic and variable names accordingly.
backend/app/agents/devrel/agent.py Refactored agent control flow to use a ReAct supervisor with tool wrapper nodes (web search, FAQ, onboarding, GitHub toolkit) and removed enum-based routing. Added GitHub toolkit integration.
backend/app/agents/devrel/nodes/gather_context.py Changed gather_context_node to return a dictionary with additional timestamp instead of an AgentState.
backend/app/agents/devrel/nodes/generate_response.py Added a new response generation node that synthesizes context, reasoning, and tool results using a new prompt template.
backend/app/agents/devrel/nodes/react_supervisor.py Introduced a ReAct supervisor node, decision router, tool result integration, and utility functions for iterative agent reasoning and action selection.
backend/app/agents/devrel/nodes/summarization.py Increased the summarization threshold from 5 to 15 interactions.
backend/app/agents/devrel/tool_wrappers.py Added wrapper functions for executing and integrating results from web search, FAQ, onboarding, and GitHub toolkit tools.
backend/app/agents/devrel/github/github_toolkit.py Introduced a new GitHubToolkit class for intent-driven GitHub operations, with intent classification and stubbed tool handlers.
backend/app/agents/devrel/github/prompts/general_github_help.py, backend/app/agents/devrel/github/prompts/intent_analysis.py, backend/app/agents/devrel/prompts/react_prompt.py, backend/app/agents/devrel/prompts/response_prompt.py Added new prompt templates for GitHub help, intent analysis, ReAct supervisor, and response generation.
backend/app/agents/devrel/github/tools/general_github_help.py, backend/app/agents/devrel/github/tools/search.py Added async handlers for general GitHub help (combining web search and LLM) and web search, with error handling and result formatting.
backend/app/agents/devrel/github/tools/contributor_recommendation.py, backend/app/agents/devrel/github/tools/documentation_generation.py, backend/app/agents/devrel/github/tools/issue_creation.py Added empty stubs for future GitHub tool handlers.
backend/app/agents/devrel/generate_response.py Switched from using the old base prompt to the new response prompt for LLM response generation.
backend/app/core/config/settings.py Updated model version defaults for agent configurations and made rabbitmq_url optional.
backend/app/core/orchestration/agent_coordinator.py Cleaned up and removed commented-out code related to a planned GitHub agent; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DiscordBot
    participant ClassificationRouter
    participant DevRelAgent
    participant ReActSupervisor
    participant ToolWrapper
    participant GitHubToolkit

    User->>DiscordBot: Sends message
    DiscordBot->>ClassificationRouter: should_process_message(message, context)
    ClassificationRouter-->>DiscordBot: {needs_devrel, priority, reasoning}
    alt needs_devrel == true
        DiscordBot->>DevRelAgent: Pass message and triage
        DevRelAgent->>ReActSupervisor: Start reasoning loop
        loop ReAct Iteration
            ReActSupervisor->>ToolWrapper: Select tool (web_search/FAQ/onboarding/GitHubToolkit)
            alt GitHubToolkit selected
                ToolWrapper->>GitHubToolkit: execute(query)
                GitHubToolkit-->>ToolWrapper: Tool result
            else Other tool
                ToolWrapper-->>ReActSupervisor: Tool result
            end
            ReActSupervisor-->>DevRelAgent: Decision to continue or complete
        end
        DevRelAgent->>DiscordBot: Final synthesized response
    else needs_devrel == false
        DiscordBot-->>User: Message not routed to DevRel
    end
Loading

Suggested labels

enhancement

Suggested reviewers

  • chandansgowda

Poem

A bunny hopped through code so bright,
Rewiring routers left and right!
Out with the old, in with the new,
ReAct loops and toolkits grew.
Now GitHub help is just a hop away—
This rabbit’s logic saves the day!
🐇💡


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0a98eb1 and 76b1532.

📒 Files selected for processing (1)
  • backend/app/agents/devrel/github/tools/general_github_help.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/app/agents/devrel/github/tools/general_github_help.py
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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 (13)
backend/app/agents/devrel/github/prompts/general_github_help.py (1)

8-14: Clean up redundant formatting requirements.

The formatting requirements section mentions avoiding complex markdown formatting twice (lines 9 and 14), which is redundant.

 FORMATTING REQUIREMENTS:
 - Use simple numbered lists (1. 2. 3.) instead of markdown bullets
 - Avoid complex markdown formatting like **bold** or *italic*  
 - Use plain text with clear line breaks
 - Format links as plain URLs: https://example.com
 - Use simple emojis
 - Keep paragraphs short and scannable
-- Avoid complex markdown formatting
backend/app/agents/devrel/github/tools/issue_creation.py (1)

1-2: Consider adding basic structure for the issue creation tool.

Based on the retrieved learnings, I understand your preference for minimal stubs that will be extended later. Consider adding a basic function signature or class structure to establish the interface for future implementation.

# Placeholder for GitHub issue creation functionality
async def handle_issue_creation(query: str, context: dict) -> str:
    """
    Handle GitHub issue creation requests.
    
    Args:
        query: User's issue creation request
        context: Additional context from the conversation
        
    Returns:
        Response message about the issue creation
    """
    # TODO: Implement issue creation logic
    pass

Would you like me to add this basic structure or keep it minimal for now?

backend/app/agents/devrel/github/tools/documentation_generation.py (1)

1-2: Documentation generation tool placeholder follows consistent pattern.

This empty file aligns with the established pattern for GitHub toolkit tools. The minimal approach is consistent with your preference for incremental development as shown in the retrieved learnings.

If you'd like to establish a basic interface for future implementation, I can help add a function signature similar to the other tools in the toolkit.

backend/app/agents/devrel/generate_response.py (1)

62-62: Fix inconsistent error message reference.

The error message still references the old prompt name.

-        logger.error(f"Missing key in GENERAL_LLM_RESPONSE_PROMPT: {e}")
+        logger.error(f"Missing key in RESPONSE_PROMPT: {e}")
backend/app/agents/devrel/github/tools/search.py (1)

12-12: Consider caching TavilySearchTool instance.

Creating a new TavilySearchTool instance on every call might be inefficient. Consider using a module-level instance or dependency injection.

+# Module-level instance
+_search_tool = TavilySearchTool()

 async def handle_web_search(query: str) -> Dict[str, Any]:
     """Handle web search using Tavily search tool"""
     logger.info("Handling web search request")

     try:
-        search_tool = TavilySearchTool()
-        search_results = await search_tool.search(query, max_results=5)
+        search_results = await _search_tool.search(query, max_results=5)
backend/app/classification/classification_router.py (1)

36-36: Move import to module level.

The json module import should be at the top of the file with other imports for better code organization.

backend/app/agents/devrel/nodes/generate_response.py (2)

88-88: Remove unnecessary f-string prefix.

The f-string prefix is not needed here as there are no placeholders in the string.

-        logger.info(f"Generated response prompt using existing RESPONSE_PROMPT")
+        logger.info("Generated response prompt using existing RESPONSE_PROMPT")

97-101: Extract duplicated function to shared utility.

The _get_latest_message function is duplicated from react_supervisor.py. Consider extracting this to a shared utility module to avoid code duplication and ensure consistency.

Would you like me to help create a shared utility module for common agent helper functions?

backend/app/agents/devrel/tool_wrappers.py (1)

40-44: Consider using shared message extraction utility.

The message extraction logic here duplicates the _get_latest_message function pattern. Once a shared utility is created (as suggested in generate_response.py), this could be refactored to use it.

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

104-115: Combine branches for unimplemented tools.

Multiple branches return the same "Not implemented" value. Consider combining them for clarity.

-            if classification == "contributor_recommendation":
-                result = "Not implemented"
-                # result = await handle_contributor_recommendation(query)
-            elif classification == "repo_support":
-                result = "Not implemented"
-                # result = await handle_repo_query(query)
-            elif classification == "issue_creation":
-                result = "Not implemented"
-                # result = await handle_issue_creation(query)
-            elif classification == "documentation_generation":
-                result = "Not implemented"
-                # result = await handle_documentation_generation(query)
+            if classification in ["contributor_recommendation", "repo_support", 
+                                  "issue_creation", "documentation_generation"]:
+                result = "Not implemented"
+                # TODO: Implement individual handlers as per comments above

8-13: Track implementation of remaining GitHub tools.

The TODO comments clearly indicate which tools need implementation. The current partial implementation with web search and general help provides a good foundation.

Would you like me to help implement any of the remaining GitHub tools or create issues to track their implementation?

backend/app/agents/devrel/nodes/react_supervisor.py (2)

56-56: Extract valid actions to improve maintainability.

The hardcoded list of valid actions could become a maintenance issue when adding new tools.

Consider extracting valid actions to a module-level constant:

+VALID_ACTIONS = ["web_search", "faq_handler", "onboarding", "github_toolkit", "complete"]
+
 def _parse_supervisor_decision(response: str) -> Dict[str, Any]:
     """Parse the supervisor's decision from LLM response"""
     try:
         lines = response.strip().split('\n')
         decision = {"action": "complete", "reasoning": "", "thinking": ""}
 
         for line in lines:
             if line.startswith("THINK:"):
                 decision["thinking"] = line.replace("THINK:", "").strip()
             elif line.startswith("ACT:"):
                 action = line.replace("ACT:", "").strip().lower()
-                if action in ["web_search", "faq_handler", "onboarding", "github_toolkit", "complete"]:
+                if action in VALID_ACTIONS:
                     decision["action"] = action

73-73: Consider making max iterations configurable.

The hardcoded iteration limit might be too restrictive for complex workflows.

Extract to a configurable constant or read from state:

+MAX_SUPERVISOR_ITERATIONS = 10
+
 def supervisor_decision_router(state: AgentState) -> Literal["web_search", "faq_handler", "onboarding", "github_toolkit", "complete"]:
     """Route based on supervisor's decision"""
     decision = state.context.get("supervisor_decision", {})
     action = decision.get("action", "complete")
 
     # Safety check for infinite loops
     iteration_count = state.context.get("iteration_count", 0)
-    if iteration_count > 10:
+    max_iterations = state.context.get("max_iterations", MAX_SUPERVISOR_ITERATIONS)
+    if iteration_count > max_iterations:
         logger.warning(f"Max iterations reached for session {state.session_id}")
         return "complete"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e69cb9 and 0a98eb1.

📒 Files selected for processing (26)
  • backend/app/agents/__init__.py (0 hunks)
  • backend/app/agents/classification_router.py (0 hunks)
  • backend/app/agents/devrel/agent.py (3 hunks)
  • backend/app/agents/devrel/generate_response.py (2 hunks)
  • backend/app/agents/devrel/github/github_toolkit.py (1 hunks)
  • backend/app/agents/devrel/github/prompts/general_github_help.py (1 hunks)
  • backend/app/agents/devrel/github/prompts/intent_analysis.py (1 hunks)
  • backend/app/agents/devrel/github/tools/contributor_recommendation.py (1 hunks)
  • backend/app/agents/devrel/github/tools/documentation_generation.py (1 hunks)
  • backend/app/agents/devrel/github/tools/general_github_help.py (1 hunks)
  • backend/app/agents/devrel/github/tools/issue_creation.py (1 hunks)
  • backend/app/agents/devrel/github/tools/search.py (1 hunks)
  • backend/app/agents/devrel/nodes/gather_context.py (2 hunks)
  • backend/app/agents/devrel/nodes/generate_response.py (1 hunks)
  • backend/app/agents/devrel/nodes/react_supervisor.py (1 hunks)
  • backend/app/agents/devrel/nodes/summarization.py (1 hunks)
  • backend/app/agents/devrel/prompts/base_prompt.py (0 hunks)
  • backend/app/agents/devrel/prompts/react_prompt.py (1 hunks)
  • backend/app/agents/devrel/prompts/response_prompt.py (1 hunks)
  • backend/app/agents/devrel/state.py (0 hunks)
  • backend/app/agents/devrel/tool_wrappers.py (1 hunks)
  • backend/app/classification/classification_router.py (1 hunks)
  • backend/app/classification/prompt.py (1 hunks)
  • backend/app/core/config/settings.py (2 hunks)
  • backend/app/core/orchestration/agent_coordinator.py (0 hunks)
  • backend/integrations/discord/bot.py (5 hunks)
💤 Files with no reviewable changes (5)
  • backend/app/agents/devrel/state.py
  • backend/app/core/orchestration/agent_coordinator.py
  • backend/app/agents/init.py
  • backend/app/agents/devrel/prompts/base_prompt.py
  • backend/app/agents/classification_router.py
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#87
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T23:15:13.374Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer test updates and fixes (like missing imports after module reorganization) to separate PRs rather than expanding the scope of module update/chore PRs to include comprehensive test refactoring.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T14:45:55.244Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer comprehensive test refactoring to separate PRs/efforts when doing major backend restructuring, rather than expanding the scope of the current refactoring PR to include test updates.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/shared/classification_router.py:0-0
Timestamp: 2025-06-08T13:08:48.469Z
Learning: The user plans to migrate the JSON parsing in backend/app/agents/shared/classification_router.py from manual JSON extraction to using Pydantic parser for better validation and type safety.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: backend/app/services/auth/management.py:32-33
Timestamp: 2025-06-28T14:44:36.819Z
Learning: In the Devr.AI project, smokeyScraper prefers using machine timezone (IST) for datetime operations during development and testing for easier debugging, with plans to switch to UTC for deployment later.
backend/app/agents/devrel/github/tools/issue_creation.py (1)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.
backend/app/agents/devrel/github/tools/documentation_generation.py (1)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.
backend/app/classification/classification_router.py (1)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/shared/classification_router.py:0-0
Timestamp: 2025-06-08T13:08:48.469Z
Learning: The user plans to migrate the JSON parsing in backend/app/agents/shared/classification_router.py from manual JSON extraction to using Pydantic parser for better validation and type safety.
backend/app/agents/devrel/github/tools/search.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
backend/integrations/discord/bot.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/shared/classification_router.py:0-0
Timestamp: 2025-06-08T13:08:48.469Z
Learning: The user plans to migrate the JSON parsing in backend/app/agents/shared/classification_router.py from manual JSON extraction to using Pydantic parser for better validation and type safety.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/core/orchestration/queue_manager.py:48-66
Timestamp: 2025-06-08T13:27:45.522Z
Learning: The queue manager implementation in backend/app/core/orchestration/queue_manager.py is temporary and will be replaced with RabbitMQ in the future.
backend/app/core/config/settings.py (1)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#75
File: backend/app/agents/devrel/agent.py:34-35
Timestamp: 2025-06-13T21:56:19.183Z
Learning: In the Devr.AI backend, the DevRelAgent follows a singleton pattern where only one instance exists for the entire application lifetime, using InMemorySaver with thread-based conversation management to persist user conversations across sessions.
backend/app/agents/devrel/tool_wrappers.py (3)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.
backend/app/agents/devrel/agent.py (3)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#75
File: backend/app/agents/devrel/agent.py:34-35
Timestamp: 2025-06-13T21:56:19.183Z
Learning: In the Devr.AI backend, the DevRelAgent follows a singleton pattern where only one instance exists for the entire application lifetime, using InMemorySaver with thread-based conversation management to persist user conversations across sessions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
backend/app/agents/devrel/nodes/react_supervisor.py (1)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.
🧬 Code Graph Analysis (6)
backend/app/agents/devrel/nodes/gather_context.py (1)
backend/app/agents/state.py (1)
  • AgentState (18-73)
backend/app/agents/devrel/github/tools/search.py (1)
backend/app/agents/devrel/tools/search_tool.py (1)
  • TavilySearchTool (10-52)
backend/app/agents/devrel/github/tools/general_github_help.py (2)
backend/app/agents/devrel/nodes/handlers/web_search.py (1)
  • _extract_search_query (10-23)
backend/app/agents/devrel/github/tools/search.py (1)
  • handle_web_search (7-41)
backend/integrations/discord/bot.py (2)
backend/app/classification/classification_router.py (2)
  • ClassificationRouter (10-59)
  • should_process_message (20-50)
backend/app/core/orchestration/queue_manager.py (1)
  • QueuePriority (12-15)
backend/app/agents/devrel/nodes/generate_response.py (2)
backend/app/agents/state.py (1)
  • AgentState (18-73)
backend/app/agents/devrel/nodes/react_supervisor.py (1)
  • _get_latest_message (97-101)
backend/app/agents/devrel/nodes/react_supervisor.py (2)
backend/app/agents/state.py (1)
  • AgentState (18-73)
backend/app/agents/devrel/nodes/generate_response.py (1)
  • _get_latest_message (97-101)
🪛 Pylint (3.3.7)
backend/app/classification/classification_router.py

[refactor] 10-10: Too few public methods (1/2)

(R0903)

backend/app/agents/devrel/github/tools/general_github_help.py

[error] 6-6: Attempted relative import beyond top-level package

(E0402)

backend/app/agents/devrel/nodes/generate_response.py

[refactor] 32-32: Too many local variables (16/15)

(R0914)

🪛 Ruff (0.11.9)
backend/app/agents/devrel/nodes/generate_response.py

88-88: f-string without any placeholders

Remove extraneous f prefix

(F541)

backend/app/agents/devrel/github/github_toolkit.py

104-108: Combine if branches using logical or operator

Combine if branches

(SIM114)


107-111: Combine if branches using logical or operator

Combine if branches

(SIM114)


110-114: Combine if branches using logical or operator

Combine if branches

(SIM114)

🪛 Flake8 (7.2.0)
backend/app/agents/devrel/nodes/generate_response.py

[error] 88-88: f-string is missing placeholders

(F541)

🔇 Additional comments (28)
backend/app/agents/devrel/github/prompts/general_github_help.py (1)

1-24: Well-structured prompt template with clear guidance.

The prompt provides comprehensive instructions for GitHub help responses with appropriate formatting requirements and response guidelines. The structure effectively guides the LLM to provide actionable, user-friendly responses.

backend/app/core/config/settings.py (2)

4-4: Good improvement to make rabbitmq_url optional.

The type annotation change from str to Optional[str] with None default is more accurate and follows Python typing best practices for optional configuration values.

Also applies to: 37-37


30-32: Confirmed model availability in settings.py

  • Lines 30–32 (backend/app/core/config/settings.py): Both gemini-2.5-flash and gemini-2.0-flash are generally available and supported for production use.
    No further action required.
backend/app/agents/devrel/github/tools/contributor_recommendation.py (1)

1-2: Consistent placeholder pattern for contributor recommendation tool.

This empty file maintains consistency with the other GitHub toolkit tool placeholders. The approach aligns well with your incremental development strategy and the broader ReAct-based workflow architecture.

backend/app/agents/devrel/nodes/summarization.py (1)

11-11: LGTM! Threshold adjustment aligns with ReAct workflow.

Increasing the summarization threshold from 5 to 15 interactions makes sense for the new ReAct supervisor pattern, allowing for more iterative reasoning cycles before triggering summarization.

backend/app/agents/devrel/generate_response.py (2)

5-5: LGTM! Prompt import updated correctly.

The import change from GENERAL_LLM_RESPONSE_PROMPT to RESPONSE_PROMPT properly aligns with the new prompt template structure.


49-49: LGTM! Variable name updated consistently.

The prompt variable reference has been correctly updated to use the new RESPONSE_PROMPT.

backend/app/agents/devrel/nodes/gather_context.py (3)

3-3: LGTM! Added necessary typing imports.

The Dict and Any imports support the updated return type annotation.


8-8: LGTM! Return type updated for ReAct workflow.

Changing from AgentState to Dict[str, Any] aligns with the new ReAct supervisor pattern where nodes return partial state updates rather than full state objects.


35-37: LGTM! Added timestamp tracking and improved formatting.

Adding last_interaction_time ensures proper timestamp tracking, and the trailing comma follows Python best practices for easier future modifications.

backend/app/classification/prompt.py (1)

1-26: LGTM! Well-structured triage prompt.

The prompt provides:

  • Clear scope definition for DevRel responsibilities
  • Structured JSON response format for consistent parsing
  • Good examples demonstrating the expected classification logic
  • Comprehensive coverage of DevRel use cases

This is a clean, actionable prompt that should work well with the new classification router.

backend/app/agents/devrel/github/tools/search.py (1)

7-41: LGTM! Well-structured web search handler.

The function provides:

  • Proper async implementation
  • Comprehensive error handling with try-catch
  • Consistent return format with status, query, and results
  • Good logging for debugging
  • Clear handling of no-results scenario
backend/app/agents/devrel/github/prompts/intent_analysis.py (1)

1-29: LGTM! Well-structured intent analysis prompt.

The prompt template is comprehensive and well-designed for GitHub intent classification. The 7 predefined categories cover the major GitHub DevRel operations effectively, and the explicit JSON output format with confidence scoring will help ensure reliable classification results.

The emphasis on returning raw JSON without markdown formatting aligns well with programmatic consumption requirements.

backend/app/agents/devrel/prompts/react_prompt.py (1)

1-35: LGTM! Excellent ReAct supervisor prompt design.

The prompt effectively implements the ReAct (Reasoning and Acting) pattern with clear Think -> Act -> Observe instructions. The 5 available actions provide good coverage of DevRel operations, and the decision criteria for each action are well-defined.

The comprehensive context variables (conversation history, tool results, platform info) will enable informed decision-making by the supervisor.

backend/app/agents/devrel/prompts/response_prompt.py (1)

1-41: LGTM! Comprehensive response generation prompt.

The prompt effectively synthesizes multiple information sources and provides clear Discord-specific formatting guidelines. The emphasis on actionable guidance and community-oriented tone aligns well with DevRel objectives.

The detailed Discord formatting requirements (numbered lists, plain URLs, simple emojis) will ensure responses display well on the platform.

backend/app/agents/devrel/github/tools/general_github_help.py (1)

11-50: LGTM! Well-structured GitHub help function.

The function effectively combines web search results with LLM knowledge to provide comprehensive GitHub assistance. The error handling is robust, and the response format is consistent with other tool functions.

The integration with existing utilities (_extract_search_query and handle_web_search) promotes code reuse and maintainability.

backend/integrations/discord/bot.py (3)

6-6: LGTM! Import path updated correctly.

The import path change from app.agents.classification_router to app.classification.classification_router properly reflects the relocation of classification logic to a dedicated module.


54-66: LGTM! Consistent integration with new triage system.

The method call change from classify_message to should_process_message and the variable name change from classification to triage_result properly align with the new triage-based classification interface. The conditional logic update maintains the same functionality while adapting to the new API.


71-103: LGTM! Method signature and internal references updated consistently.

The method signature change to accept triage_result and the corresponding updates to the dictionary key ("triage") and priority extraction are consistent with the new triage-based classification system. The priority mapping logic remains robust with proper fallback handling.

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

31-44: Manual JSON parsing works for now.

I see you're using manual JSON extraction here. Based on our previous discussions, I understand you plan to migrate this to Pydantic parser for better validation and type safety. The current implementation handles the immediate needs well.


48-59: Well-implemented error handling and fallback mechanism.

The error handling with a dedicated fallback method ensures the system gracefully degrades when classification fails, defaulting to assuming DevRel assistance is needed. This is a safe and user-friendly approach.

backend/app/agents/devrel/nodes/generate_response.py (1)

24-30: Robust error handling with user-friendly fallback.

Good implementation of error handling that provides a clear message to users while properly tracking errors in the agent state.

backend/app/agents/devrel/agent.py (1)

40-77: Clean implementation of ReAct supervisor pattern.

The refactoring to use a ReAct supervisor pattern is well-executed:

  • Clear phase separation improves readability
  • Proper tool-to-supervisor feedback loop enables iterative reasoning
  • GitHub toolkit integration follows the same pattern as other tools
  • The supervisor-driven control flow is more flexible than the previous classification-based routing
backend/app/agents/devrel/tool_wrappers.py (1)

11-57: Error handling approach aligns with tool implementations.

I notice only the GitHub toolkit wrapper has explicit error handling. Based on our previous discussions, I understand that tools like TavilySearchTool already include comprehensive error handling internally. The selective error handling here appears intentional and appropriate.

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

17-134: Well-structured GitHub toolkit implementation.

The toolkit provides a clean interface for GitHub operations with:

  • Robust intent classification with confidence scoring
  • Comprehensive error handling and fallbacks
  • Clear logging for debugging
  • Good separation between classification and execution
backend/app/agents/devrel/nodes/react_supervisor.py (3)

10-43: LGTM! Well-structured ReAct supervisor implementation.

The function correctly implements the ReAct pattern with proper state management, iteration tracking, and logging.


79-95: LGTM! Proper state management with tool result tracking.

The function correctly maintains state immutability and provides comprehensive tool result tracking.


103-112: LGTM! Clean implementation with good defaults.

The function properly handles edge cases and provides flexible history retrieval.

Comment on lines +97 to +101
def _get_latest_message(state: AgentState) -> str:
"""Extract the latest message from state"""
if state.messages:
return state.messages[-1].get("content", "")
return state.context.get("original_message", "")
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 4, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Extract duplicate function to shared utilities.

This function is an exact duplicate of _get_latest_message in generate_response.py.

Create a shared utilities module to avoid code duplication:

# backend/app/agents/devrel/utils/message_utils.py
def get_latest_message(state: AgentState) -> str:
    """Extract the latest message from state"""
    if state.messages:
        return state.messages[-1].get("content", "")
    return state.context.get("original_message", "")

Then import and use it in both files:

-def _get_latest_message(state: AgentState) -> str:
-    """Extract the latest message from state"""
-    if state.messages:
-        return state.messages[-1].get("content", "")
-    return state.context.get("original_message", "")
+from ..utils.message_utils import get_latest_message

And update the usage:

-    latest_message = _get_latest_message(state)
+    latest_message = get_latest_message(state)
🤖 Prompt for AI Agents
In backend/app/agents/devrel/nodes/react_supervisor.py lines 97 to 101, the
function _get_latest_message duplicates code found in generate_response.py. To
fix this, create a new shared utility module
backend/app/agents/devrel/utils/message_utils.py containing the function
get_latest_message with the same logic. Then, remove the duplicate function from
both files and import get_latest_message from the new utility module, updating
all calls accordingly to use the shared function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this can be aligned later in a more better way, depending on much common functionalities are present amongst tools/workflow?
currently only two files uses this, so maybe not a problem now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@smokeyScraper That makes perfect sense! You're right that with only two files currently using this function, it's premature to create shared utilities. Waiting until there are more common functionalities across the workflow will indeed allow for a more comprehensive and better-designed shared utilities approach.

I'll keep this in mind for future reviews - sometimes it's better to let patterns emerge naturally before consolidating them.

🐰 (thoughtfully noting down preferences for future reference)


✏️ Learnings added
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#90
File: backend/app/agents/devrel/nodes/react_supervisor.py:97-101
Timestamp: 2025-07-05T04:33:39.807Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer code deduplication refactoring (like extracting duplicate functions to shared utilities) until there are more common functionalities present among tools/workflow. With only two files using the same function, they consider it not a problem currently and prefer to "align later in a more better way" once more patterns emerge.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#87
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T23:15:13.374Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer test updates and fixes (like missing imports after module reorganization) to separate PRs rather than expanding the scope of module update/chore PRs to include comprehensive test refactoring.

Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: tests/test_supabase.py:1-3
Timestamp: 2025-06-28T14:45:55.244Z
Learning: In the Devr.AI project, smokeyScraper prefers to defer comprehensive test refactoring to separate PRs/efforts when doing major backend restructuring, rather than expanding the scope of the current refactoring PR to include test updates.

Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/__init__.py:2-2
Timestamp: 2025-06-08T13:15:11.074Z
Learning: In backend/app/agents/shared/base_agent.py, the BaseAgent class internally imports and re-exports AgentState, making it valid to import AgentState from shared.base_agent in addition to shared.state.

Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_technical_support_node.py:6-17
Timestamp: 2025-06-08T13:15:40.536Z
Learning: The handle_technical_support_node function in backend/app/agents/devrel/nodes/handle_technical_support_node.py is intentionally minimal and will be extended after database configuration is completed.

Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#85
File: backend/app/services/auth/management.py:32-33
Timestamp: 2025-06-28T14:44:36.819Z
Learning: In the Devr.AI project, smokeyScraper prefers using machine timezone (IST) for datetime operations during development and testing for easier debugging, with plans to switch to UTC for deployment later.

@smokeyScraper
Copy link
Contributor Author

this PR closes #89
hey @chandansgowda, could you please review and merge?

this PR structures up the whole of the agentic workflow, and connecting tools is only left now (maybe a bit of tweaks in prompts too). Have documented the whole workflow in Notion.

what this PR specifically introduces? hmm lemme think 🤔,
yes that's it think; a better thinking based approach on decisions :)

Interactions Attached

FAQ

image

image

Screenshot 2025-07-05 101214

image

Referring GitHub

image

image

image

@smokeyScraper
Copy link
Contributor Author

working on fixing the embeddings model functions and adding Falkor DB support.
will raise modular functions for workflows/tools.
whole codebase is finally structured, and now just extending functionalities seems to be left with minor refactorings :)

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: Initial setup and integration of GitHub Agent into the core workflow

2 participants