Skip to content

Conversation

@qdrddr
Copy link

@qdrddr qdrddr commented Nov 18, 2025

  • Implements the --ask-agent CLI flag for non-interactive queries
  • Introduces the ask_agent tool within MCP
  • Adds a test MCP client leveraging ask_agent tool

ask_agent - utilizes the RAG pipeline similar to the interactive mode and provides it as a tool. Often gives a better responce when used from the MCP Client.
Sometimes you want to be able to access the code-graph from CLI non-interactively by asking a single question.

- Add main_async_single_query() function to handle single query execution
- Add --question/-q parameter to start command
- Route to non-interactive mode when --question is provided
- Output response directly to stdout for easy scripting
- Maintain backward compatibility with interactive mode
- Update client to call the new **ask_agent** tool instead of ask_code_graph.
- Change CLI flag from `--question` to `--ask-agent` for clearer intent.
- Add `StdioServerParameters` and redirect server stderr to `/dev/null` to
 suppress noisy logs while keeping MCP communication intact.
- Replace the tool registration entry with **ask_agent**, expanding its
 description and input schema to guide users on asking code‑base questions.
- Adjust logging statements to reference the new tool name.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @qdrddr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the utility of the codebase RAG system by introducing a non-interactive query mode. This allows users to programmatically ask questions about the codebase via a new CLI flag or through an MCP tool, making the system more versatile for automation and integration with other tools. The changes also include improvements to logging for non-interactive use cases and an expansion of the underlying toolset available to the RAG agent.

Highlights

  • Non-Interactive CLI Query: Introduced a new --ask-agent CLI flag, enabling users to submit single, non-interactive queries to the codebase RAG system and receive output directly to stdout, which is ideal for scripting.
  • MCP Integration for ask_agent: Integrated the ask_agent functionality as a tool within the MCP (Multi-Agent Communication Protocol) framework, allowing other agents or clients to programmatically query the codebase.
  • New MCP Client: Added a dedicated MCP client (codebase_rag/mcp/client.py) that leverages the new ask_agent tool, demonstrating how external systems can interact with the codebase RAG via MCP.
  • Logging Control: Implemented a question_mode flag in the common initialization logic to suppress verbose logging (INFO/DEBUG/WARNING) during non-interactive queries, ensuring cleaner output for scripting purposes.
  • Expanded Toolset: The MCP tools have been expanded to include ShellCommander, DocumentAnalyzer, semantic_search, and get_function_source tools, enhancing the RAG agent's capabilities.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a non-interactive query mode via a new CLI flag and integrates it as an ask_agent tool within the MCP server. The changes are well-structured, with a new main_async_single_query function for single queries and a dedicated mcp/client.py for testing the MCP tool. The logging is also improved for the non-interactive mode to provide clean output. My main feedback is to ensure consistency in the naming of the new CLI flag across the application, as I've detailed in my comments on codebase_rag/main.py.

- Fix JSONRPC parsing errors by disabling ANSI colors in logging
- Redirect Rich console output to stderr to avoid stdout corruption
- Increase RAG orchestrator retries to handle output validation

Cherry-picked from dev branch (21a1b5a)
Copy link
Owner

@vitali87 vitali87 left a comment

Choose a reason for hiding this comment

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

Nice work on the ask-agent feature!

A few things to address:

  1. Silent error handling makes debugging impossible:
except Exception:
    # Fail silently without logging or printing error details
    return {"output": "There was an error processing your question", "error": True}

This is in both ask_agent (tools.py) and call_tool (server.py). Even with MCP_ENABLE_LOGGING=1, errors aren't logged anywhere.

Please log errors and include some info in the response:

except Exception as e:
    logger.error(f"ask_agent error: {e}")
    return {
        "output": "There was an error processing your question",
        "error": True,
        "error_type": type(e).__name__,
    }
  1. mcp/client.py is described as a "test" client but lives in the main package. Should it be in tests/ instead?

  2. The PR adds new MCP tools (shell_command, document_analyzer, semantic_search, get_function_source) but doesn't mention them in the description. Please document these additions.

@qdrddr
Copy link
Author

qdrddr commented Dec 9, 2025

  1. This can leak errors into MCP response and consume LLM tokens. What actually happened to me. That was the reason I made it silent. I'm open on the ideas how to better handle this situation.

@vitali87
Copy link
Owner

  1. This can leak errors into MCP response

This is actually a good point that I didn't think about. Happy to silence them for now until we find a better way. Please add documentation on metnioned on point 3, and I will approve this PR.

Thanks again @qdrddr

@qdrddr
Copy link
Author

qdrddr commented Dec 28, 2025

README.md updated with the documentation @vitali87

Copy link
Owner

@vitali87 vitali87 left a comment

Choose a reason for hiding this comment

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

Thanks for your patience and for adding the documentation as requested!

I've recently done a major refactoring to centralize strings and enforce stricter coding standards. This PR predates those changes, so there are quite a few adjustments needed to align with the new patterns (see CONTRIBUTING.md).

Given the scope of changes required, I'd like to offer you two options:

Option 1: You address the remaining items:

  • Remove all docstrings (see "No Comments or Docstrings" in CONTRIBUTING.md)
  • Replace dict[str, Any] with TypedDict
  • Move tool/parameter descriptions to tool_descriptions.py
  • Install pre-commit hooks: pre-commit install

Option 2: I can make these adjustments myself and merge, with attribution to you.

Let me know which you'd prefer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants