ShallowCodeResearch: An Award-Winning Multi-Agent AI Code Assistant
This project is a sophisticated multi-agent research and code assistant that won the $5,000 Modal Labs Choice Award at the Gradio Agents & MCP Hackathon 2025.

ShallowCodeResearch: What Is It?
A few weeks ago I came across a post on LinkedIn from Gradio announcing their Agents & MCP Hackathon 2025. It was late at night, and I thought this could be a great activity to work on and keep my mind occupied. There have been a few occasions where I've wanted or even tried to do something like this, but I never managed to finish and submit any of those.
This time, I was determined to see it through. I spent the next week planning and building a multi-agent AI code assistant using Gradio's Model Context Protocol (MCP) server functionality. The initial aim was to make a deep research tool that could be used to replace using Google or OpenAI's offerings. Then, I thought, I wanted something quick, something you could run in your Integrated Development Environment (IDE) and get results quickly. Shallow "Code" Research was born.
The idea was to create a sophisticated multi-agent research and code assistant that could automate the process of research and code generation. This would be a great tool for a beginner developer, they could ask a question and get a tested code snippet back, trusting that it would work. And if that's not enough, there would be a web search response with references so the user could learn more about the topic.
Problem Statement
Developers and researchers often need to quickly gather information, generate code, and test it. This process can be time-consuming and requires switching between multiple tools. ShallowCodeResearch addresses this by providing a single, integrated platform that automates the entire workflow, from research to code execution.
Technical Approach
The application uses a multi-agent architecture where each agent is responsible for a specific task. The agents work together in an orchestrated linear workflow to provide a seamless user experience.
1. Multi-Agent Architecture
The core of the application is its multi-agent system, which includes:
- Question Enhancer Agent: Refines user queries into detailed sub-questions for more detailed research by the web search agent.
- Web Search Agent: Gathers information from the web using the Tavily API.
- LLM Processor Agent: Summarizes and analyzes the results of the web search using a Large Language Model.
- Citation Formatter Agent: Formats citations for the sources used.
- Code Generator Agent: Generates Python code based on the user's request and the research context.
- Code Runner Agent: Here's the key to the magic: Executes the generated code in a secure Modal sandbox.
- Orchestrator Agent: Manages the entire workflow, coordinating the other agents.
2. Secure Code Execution with Modal
To ensure the safe execution of generated code, ShallowCodeResearch uses Modal to create secure, isolated sandboxes. This includes a warm sandbox pool to minimize cold-start latency, which is crucial for a responsive user experience. The application can also dynamically install any required packages before execution.
3. Interactive User Interface with Gradio
The user interface is built with Gradio, which provides a simple and intuitive way to interact with the application. The way Gradio has designed the interface allows for the app to work via MCP but also a web application. This means that you can open up the app for interaction in your browser if that's what you prefer, or you can use the MCP server functionality to run the app locally.
4. MCP Server Functionality
The term MCP is talked about everywhere I look nowadays, with its promise of simplifying the way we can build AI
applications and interactive with external data sources. Now, the MCP setup in Gradio couldn't be simpler; all you need
is to pass mcp_server=True
into the gr.launch()
method. This builds the server, with documentation, just like
your typical API library like FastAPI or Flask.
To use the MCP server, it's as simple as running the Gradio application, for example, in a Hugging Face Space, and then setting up your IDE to use the MCP server as a custom LLM provider. For this example, I'll demonstrate how I set this up with Cline in Visual Studio Code.
By installing the Cline extension in VS Code, you can configure it to use the MCP server. Open up Cline, select
the MCP button, go to Installed
, and press on the Configure MCP Servers
button. This will open up a configuration
file where you can configure the MCP server, using a JSON schema.
{
"mcpServers": {
"gradiocodeassist": {
"autoApprove": [],
"disabled": false,
"timeout": 300,
"type": "sse",
"url": "https://agents-mcp-hackathon-shallowcoderesearch.hf.space/gradio_api/mcp/sse",
"headers": {}
}
}
}
Now it's as simple as turning it on and starting interacting with the MCP server. From my testing, I found that all I needed to do was type the main agent function name to ensure the right tool is picked.
For example, "agent research request: How do you write a python script to perform scaling of features in a dataframe"
Now the magic happens!!!
4. End-to-End Orchestration
The OrchestratorAgent
manages the entire process, from taking the user's initial request to delivering the final
summary, code, and execution results.
The real power of ShallowCodeResearch lies in its ability to automate the entire research and coding process, with code execution in a secure Modal sandbox. This was key to achieving my original goal, I want real code that works, and that means it needs to be tested and executed. I also needed this to be quick, and this is where Modal shines.
Using the Modal sandboxes, I was able to create a warm pool of sandboxes that would be ready to execute code immediately, ensuring a responsive user experience. Although there are warmed sandboxes, if for any reason a new sandbox is needed, I needed the application to not delay the user experience by waiting for the sandbox to be created with all the bells and whistles included. To achieve this, basic images are used, with some common packages pre-installed, think of your numpys, pandas etc. that are reasonably quick to install. Then, additional packages are dynamically installed when needed, delaying only on a case-by-case basis. Modal and Agents, the combination of these two technologies, allowed me to achieve this seamlessly.
Feel free to watch my demo, showing this live as scikit-learn is installed dynamically, which I demonstrated by design to show how the application can handle dynamic package requirements.
Implementation Details
- Backend: Python handles the core logic, including agent orchestration and interaction with external APIs.
- NLP Pipeline: The application leverages various LLM providers, including Nebius, OpenAI, Anthropic, and Hugging Face, for natural language processing tasks.
- API Key Management: API keys are managed through environment variables for security.
- Code Generation: To ensure the generated code is accurate and relevant, there are additional checks in place
to ensure that the code does not contain powerful imports or commands that could cause harm to the system. This is achieved
with key word checks and simple prompt engineering. For example, a simple check for
input()
is performed to ensure that the application execution doesn't stall waiting for user input. - Code Execution: Modal is used for secure code execution, with a warm pool of sandboxes to minimize latency.
Results and Impact
ShallowCodeResearch demonstrates the power of a multi-agent approach to AI-assisted development:
- Enhanced Productivity: By automating the research and coding process, the application allows developers to work more efficiently.
- Improved Accuracy: The use of web search for grounding ensures that the generated code is based on up-to-date and relevant information.
- Secure and Reliable: The use of Modal sandboxes for code execution provides a secure environment, and the application's fault tolerance features ensure reliability.
Future Enhancements
Potential future improvements for ShallowCodeResearch include:
- Adding support for more programming languages.
- Expanding the capabilities of the research agents to handle more complex queries.
- Adding a user feedback loop to ensure the user is satisfied with the generated code and research results.
- Tightening up on exception handling and error management to ensure a smooth user experience.
- Ensuring the application is robust and secure, especially in the context of code execution.
Conclusion
ShallowCodeResearch is a powerful and innovative tool that showcases the potential of multi-agent AI systems. Its success at the Gradio Agents & MCP Hackathon 2025 is a testament to its robust architecture and user-friendly design. By providing a seamless and efficient workflow for research and code generation, ShallowCodeResearch is poised to become an invaluable tool for developers and researchers alike.
Technologies Used
Share This Project
Interested in This Project?
Have questions or want to discuss a similar project? Feel free to reach out.
Contact Me