hero

How to Build Code Review Agent Using Qwen 3?

Arindam Majumdar

May 8, 2025

8 min read

Qwen has been making waves in the AI community with a rapid pace of innovation, releasing one powerful model after another. Following the impressive launches of QvQ, Qwen2.5-VL, and Qwen2.5-Omni earlier this year, the Qwen team has now introduced new models in the family: Qwen3. This newest lineup features not just one, but eight cutting-edge models, ranging from a compact 0.6 billion parameter version all the way up to the flagship Qwen3-235B-A22B, a massive 235 billion parameter model. These models are setting new benchmarks, outperforming top players like DeepSeek-R1, OpenAI's o1 and o3-mini, Grok 3, and Gemini 2.5-Pro across a range of standard evaluation tasks.

For developers and AI practitioners, Qwen3 opens up exciting opportunities — especially when it comes to building advanced AI agents and Retrieval-Augmented Generation (RAG) systems. In this article, we will focus on using qwen/qwen3-30b-a3b:free, one of the standout smaller models in the Qwen3 family. Despite its size, this 30 billion parameter model has shown remarkable performance, even outperforming older models like QWQ-32B that have nearly 10 times the activated parameters.

We will explore how to leverage Qwen3-30B-A3B specifically to build an intelligent Code Review Agent — capable of understanding, analyzing, and providing high-quality feedback on code. Whether you're a developer, a tech lead, or an AI enthusiast, this article will guide you through the process of using Qwen3's advanced capabilities to supercharge your code review workflows.

8 New Models in Qwen Family

Qwen has been rapidly reshaping the competitive AI space, pushing out one powerful model family after another. After recent successes like QvQ, Qwen2.5-VL, and Qwen2.5-Omni, the team has now introduced their most versatile and ambitious lineup yet. Qwen 3 includes eight models — spanning from the ultra-light Qwen3-0.6B (0.6 billion parameters) all the way up to the colossal Qwen3-235B-A22B, a 235 billion parameter MoE (Mixture of Experts) model that activates only 22 billion parameters per forward pass for efficient compute.

Model NameTotal ParametersActivated Parameters (for MoE models)Model Type
Qwen3-235B-A22B235 Billion22 BillionMoE (Mixture of Experts)
Qwen3-30B-A3B30 Billion3 BillionMoE (Mixture of Experts)
Qwen3-32B32 BillionN/ADense
Qwen3-14B14 BillionN/ADense
Qwen3-8B8 BillionN/ADense
Qwen3-4B4 BillionN/ADense
Qwen3-1.7B1.7 BillionN/ADense
Qwen3-0.6B0.6 BillionN/ADense

How to Access Qwen3 Models for Free in Any Region?

There are many platforms that offer a unified API for accessing large language models, but I'm using OpenRouter. It serves as a single, streamlined endpoint, making it easier to integrate and work with multiple AI models without the hassle of managing separate APIs.

Steps to get the API key for the Qwen 3 model on OpenRouter:

  1. Create an account on OpenRouter (if you haven't already).
  2. Qwen3
  3. Use the model search bar to find the Qwen 3 model.
  4. Qwen3
  5. On the Qwen 3 model's page, click "Create API key" to generate a new API key.
  6. Qwen3

Here's the sample code for Qwen 3 Access:

from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="<OPENROUTER_API_KEY>",
)

completion = client.chat.completions.create(
    extra_headers={
        "HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
        "X-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
    },
    extra_body={},
    model="qwen/qwen3-30b-a3b:free",
    messages=[
        {
            "role": "user",
            "content": "What is the meaning of life?"
        }
    ]
)

print(completion.choices[0].message.content)

Building a Code Review Agent with Qwen3-30B-A3B: A Step-by-Step Guide

Qwen3

1. Setting Up the Environment

To begin, I ensured that the necessary packages were installed:

!pip install langchain langchain-community openai
!pip install -U langchain-openai

from langchain.agents import Tool
from langchain.agents import initialize_agent
from langchain_openai import ChatOpenAI

These packages are essential for integrating language models and building agents.

2. Initializing the Qwen3-30B-A3B Model

I utilized the ChatOpenAI class from LangChain to interface with the Qwen3-30B-A3B model via OpenRouter:

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="your-api-key", # Replace with your actual API key
    model="qwen/qwen3-30b-a3b:free"
)

This setup allowed me to leverage Qwen3-30B-A3B's capabilities through an OpenAI-compatible API.

3. Defining the Tools

I created three tools to handle code generation, review, and correction:

Code Generator: Generates initial Python code based on a prompt.

def generate_code(prompt):
    response = llm.predict(f"Write Python code for: {prompt}")
    return response

Code Reviewer: Reviews the generated code for correctness and suggests improvements.

def review_code(code_snippet):
    review_prompt = f"Review the following Python code for correctness and suggest improvements:\n\n{code_snippet}"
    review = llm.predict(review_prompt)
    return review

Code Corrector: Provides the corrected version of the code with improvements applied.

def correct_code(code_snippet):
    correction_prompt = f"Correct and provide the final Python code with improvements applied:\n\n{code_snippet}"
    corrected = llm.predict(correction_prompt)
    return corrected

Each function utilizes the llm.predict() method to interact with the model.

4. Creating Tool Wrappers

Using LangChain's Tool class, I wrapped each function:

from langchain.agents import Tool

CodeGeneratorTool = Tool(
    name="Code Generator",
    func=generate_code,
    description="Generates initial Python code based on prompt"
)

CodeReviewerTool = Tool(
    name="Code Reviewer",
    func=review_code,
    description="Reviews Python code and suggests improvements or fixes"
)

CodeCorrectorTool = Tool(
    name="Code Corrector",
    func=correct_code,
    description="Corrects and provides the improved version of the Python code"
)

These wrappers provide metadata and structure for each tool, facilitating their integration into the agent.

5. Initializing the Agent

I combined the tools into a list and initialized the agent:

from langchain.agents import initialize_agent

tools = [CodeGeneratorTool, CodeReviewerTool, CodeCorrectorTool]
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent_type="zero-shot-react-description",
    verbose=True,
    return_intermediate_steps=True
)

This setup allows the agent to select and utilize the appropriate tool based on the input prompt.

6. Running the Agent

To test the agent, I provided a prompt:

# Example Run using agent.run()
prompt = """create Fibonacci series code and check if it is correct
 First, generate Python code for Fibonacci series.
 Then, pass that code to the Code Reviewer.
 Then, pass it to the Code Corrector."""
response = agent.run(prompt)

# Display in Markdown (if running in a Jupyter notebook)
from IPython.display import Markdown, display
display(Markdown(response))

The agent sequentially:

  1. Generated the code.
  2. Reviewed the code for correctness and suggested improvements.
  3. Provided the corrected version of the code.

7. Displaying the Output

To display the response in a readable format (especially in Jupyter notebooks), I used:

from IPython.display import Markdown, display
display(Markdown(response))

This rendered the agent's output as formatted Markdown.

Output:

Qwen3Qwen3Qwen3Qwen3Qwen3

Complete Code Review Agent Implementation

!pip install langchain langchain-community openai
!pip install -U langchain-openai

from langchain.agents import Tool
from langchain.agents import initialize_agent
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key="sk-or-v1—--",
    model="qwen/qwen3-30b-a3b:free" # Changed to a known working model
)

# Tool: Code Generator
def generate_code(prompt):
    response = llm.predict(f"Write Python code for: {prompt}")
    return response

CodeGeneratorTool = Tool(
    name="Code Generator",
    func=generate_code,
    description="Generates initial Python code based on prompt"
)

# Tool: Code Reviewer
def review_code(code_snippet):
    review_prompt = f"Review the following Python code for correctness and suggest improvements:\n\n{code_snippet}"
    review = llm.predict(review_prompt)
    return review

CodeReviewerTool = Tool(
    name="Code Reviewer",
    func=review_code,
    description="Reviews Python code and suggests improvements or fixes"
)

# Tool: Code Corrector
def correct_code(code_snippet):
    correction_prompt = f"Correct and provide the final Python code with improvements applied:\n\n{code_snippet}"
    corrected = llm.predict(correction_prompt)
    return corrected

CodeCorrectorTool = Tool(
    name="Code Corrector",
    func=correct_code,
    description="Corrects and provides the improved version of the Python code"
)

# Initialize Agent
tools = [CodeGeneratorTool, CodeReviewerTool, CodeCorrectorTool]
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent_type="zero-shot-react-description",
    verbose=True,
    return_intermediate_steps=True
)

# Example Run using agent.run()
prompt = """create Fibonacci series code and check if it is correct
First, generate Python code for Fibonacci series.
Then, pass that code to the Code Reviewer.
Then, pass it to the Code Corrector."""
response = agent.run(prompt)

# Display in Markdown (if running in a Jupyter notebook)
from IPython.display import Markdown, display
display(Markdown(response))

Personal Insights and Observations

  • Efficiency: The Qwen3-30B-A3B model, despite being a Mixture of Experts (MoE) model with only 3 billion activated parameters, performed exceptionally well in generating and reviewing code.
  • Flexibility: The agent's modular design, facilitated by LangChain, allowed for easy addition or modification of tools, making it adaptable to various coding tasks.
  • Performance: The model's ability to understand and process complex prompts resulted in accurate code generation and insightful reviews.

How This Mirrors Real-World AI Code Review Platforms

As I was building this Code Review Agent with Qwen3-30B-A3B, I couldn't help but notice how closely this setup aligns with what many modern AI-driven code review platforms are doing in production. These platforms go beyond basic static analysis — they're designed to integrate directly into the development pipeline, offering intelligent feedback, flagging vulnerabilities, and helping teams ship better code, faster.

What I've built here is, in many ways, a simplified version of what powers these enterprise-grade systems. The modular approach using LangChain tools like Code Generator, Code Reviewer, and Code Corrector reflects the core logic behind these advanced platforms. They often use similar architecture: a powerful language model at the core, surrounded by purpose-specific tools that handle generation, analysis, and correction — just like my agent does.

In the real world, these platforms are used to:

  • Automatically assess code quality — catching bugs, anti-patterns, or security issues as developers write or submit code.
  • Boost team productivity — giving fast, intelligent suggestions without the need to wait for manual reviews.
  • Scale expert insight — bringing senior-level review capabilities even to smaller teams or junior developers.
  • Support multiple languages and frameworks — adapting to whatever stack the team is using.

Seeing how well Qwen3 handled these tasks in my own implementation gave me a deeper appreciation for how far AI code review technology has come — and how close we are to fully intelligent, real-time development assistants. It's exciting to realize that tools like the one I built aren't just proof of concept; they're the foundation of what's already being used in production by some of the most forward-thinking companies out there.

If you're working on anything code-related — whether you're a solo developer or part of a large engineering team — I highly encourage you to start experimenting with AI Code review agents. It's easier than ever to prototype real-world tools with powerful open models like Qwen3. Who knows? You might end up building the next great AI-driven development tool yourself.

Conclusion

Building a Code Review Agent using Qwen3-30B-A3B has been both a technically enriching and eye-opening experience. What began as a simple prototype turned into a glimpse of what the future of software development could look like — intelligent assistants that not only generate code but also review, correct, and improve it in real-time.

Thanks to the flexibility of LangChain and the performance of Qwen3, I was able to construct a modular, responsive code review workflow that mirrors the capabilities of modern AI-powered platforms used in production environments. And the best part? It's accessible — with open model APIs and tools, anyone can get started.

Whether you're a developer looking to automate parts of your workflow, a startup exploring AI tooling, or simply curious about practical LLM use cases, this is the perfect time to dive in.

hero

Streamline your Engineering Team

Get started with a Free Trial or Book A Demo with the founder
footer
logo

Building artificial
engineering intelligence.

Product

Home

Log In

Sign Up

Helpful Links

OSS Explore

PR Arena

Resources

Blog

Changelog

Startups

Contact Us

Careers