Critic’s Cut 🎥 Powering Multilingual, Context-Aware Movie Reviews with ADK & Gemini 2.0
The landscape of conversational AI is rapidly evolving. Conversational AI is no longer just about simple Q&A. Modern agents need to understand dialogue history, integrate external tools, adhere to safety protocols, and ideally, communicate across language barriers. This post provides a technical deep dive into "Critic's Cut", a movie review agent built to embody these principles using:

Overview
The goal of this project is to demonstrate a simple agent that:
- PII redaction (Presidio Analyzer).
- Toxicity/offensive content blocking (Better-Profanity).
- Language, formatting, and content quality checks
The Blueprint: Google's Agent Development Kit (ADK)
The ADK serves as the backbone, providing a structured approach to agent development:
Defining the Persona = google.adk.agents.Agent
instruction
parameter, a detailed prompt that guides the LLM (Gemini 2.0 Flash in this case). # From notebook cell: Agent Definition
movie_review_agent = Agent(
name="MovieReviewAgent",
model="gemini-2.0-flash", # Or your MODEL_GEMINI_2_0_FLASH variable
instruction="""
You are Critic's Cut...
(Detailed instructions on review structure, context handling,
multilingual responses, source citation, off-topic replies, etc.)
""",
tools=[google_search]
)
Supported functionalities include:
tools
interfaceExtending Capabilities with Tools = google.adk.tools.google_search
Google Search Tool
. Memory & Context = google.adk.sessions.InMemorySessionService
SessionService
, particularly InMemorySessionService
for this project, is crucial for context-awareness. APP_NAME
and the specific session_service
instance across all operations.Orchestration with Runner = google.adk.runners.Runner
SessionService
to provide conversational context, coordinating any tool calls initiated by the agent, and streaming back the Event
objects that detail the agent's thought process and final output.The Brain: Gemini 2.0 Flash
The cognitive power behind Critic's Cut comes from Google's Gemini 2.0 Flash model.
The Guardian: Automated Evaluation & Safety Pipeline
To ensure responsible and high-quality interactions, and inspired by ADK safety guidelines, Critic's Cut incorporates a critical pre-response evaluation pipeline. Before any generated content is surfaced to the user, it's vetted through a series of automated checks:
# Conceptual flow within the ask_movie_agent helper:
# 1. Obtain raw_agent_response_text from runner.run_async
# 2. Perform safety_checks:
# if not check_toxicity(text) or not check_pii(text) or not check_prompt_injection(text):
# safety_breach = True
# display_text = "🛡️ Response withheld for safety..."
# 3. If not safety_breach, perform content_checks:
# if not check_language(text, lang): feedback.append("Lang issue")
# # ... other checks for formatting, sources, rejection ...
# display_text = f"✨ Agent Response:\n{text}"
# 4. Display display_text and all feedback messages.
is_movie_or_show_query(...)
is a regex-based function provides a first-pass filter on the user's prompt to determine if it's movie-related, helping to gate subsequent, more intensive evaluations. It prevents unnecessary compute cycles and enforces topic safety.- Toxicity Screening:
better-profanity
is a Python library for detecting and censoring profanity in text. So we useprofanity.contains_profanity()
to filter out inappropriate language. - PII Shielding:
presidio-analyzer
is a part of the Presidio framework by Microsoft for detecting PII (Personally Identifiable Information) in text. Our tool employsanalyzer.analyze()
to detect and prevent leakage of entities like email addresses and phone numbers. - Prompt Injection Defense: A custom check using regular expressions, refer
check_prompt_injection(...)
, scans for common phrases indicative of attempts to manipulate the agent or reveal its system prompts.
- Language Consistency:
langdetect
is a Python library for language detection, supporting a wide range of languages.check_language(...)
verifies if the agent's primary response language aligns with theexpected_lang_code
(usually derived from the user's query language). - Rejection Logic
check_rejection(...)
is a function, supported by the refinedis_topic_movie_for_rejection_check
logic (which infers topic from agent response format for follow-ups), assesses if the agent correctly declined off-topic queries or appropriately handled on-topic ones without undue rejection. - Review Structure Compliance:
check_has_ratings_and_emojis(...)
andcheck_has_sources(...)
validate that essential review components (star ratings, emojis, source links) are present. - Source Faithfulness:
check_faithfulness(...)
verifies that cited sources, when a review is provided, include names from a predefined list of reputable (currently English-centric) domains (e.g., IMDb, Rotten Tomatoes, BBC). This might flag valid foreign-language sources if they are not on this list.
Some Insights & The Path Forward
The development of Critic's Cut highlighted several key engineering considerations:
asyncio
correctly in Google Colab, especially ensuring that setup operations like session creation are fully awaited before dependent operations commence, is vital for stability. Wrapping cell logic in a main async def function and using top-level await proved effective.google_search
yields, while still attempting to engage in the user's language.Why This Matters
This project showcases how Google ADK allows rapid prototyping of production-ready agents that are multilingual, safe, and intelligent. Integration of tools like search, moderation, and semantic scoring can be done with minimal setup. The agent exemplifies evaluation-driven development: each layer, from detection to moderation, contributes to building trusted AI experiences.
Final Thoughts
Intelligent agents must also be:
Google ADK provides a strong foundation to build such systems. This project illustrates the capabilities achievable with just a few lines of code. Future expansions could include voice-based or mobile integrations, feasible with ADK’s modular framework.
Hope you enjoyed this piece, check out the entire code on github 🎓
Huge thanks to the Google ML Developer team for organizing #AISprint ✨ Google Cloud credits are provided for this project. #BuildWithAI #BuildWithGemini #VertexSprint #VertexAISprint #AISprint #GeminiSprint