DEV Community

Cover image for Building "Civic-Helper": A Multi-Agent System for Social Good with Google Gemini
Karthik K
Karthik K

Posted on

Building "Civic-Helper": A Multi-Agent System for Social Good with Google Gemini

🤖 Introduction

Bureaucracy is hard. For many citizens—especially the elderly or those uncomfortable with formal writing—reporting simple community issues like a broken streetlight or a dangerous pothole can be intimidating.

I wanted to see whether AI Agents could solve this real-world problem.

During the 5-Day AI Agents Intensive Course by Google and Kaggle, I moved beyond simple chatbots to build "The Civic-Helper," an autonomous multi-agent system that interviews citizens and automatically drafts professional correspondence to the correct government department.

Here’s a breakdown of how I built it, the technical challenges I faced (including a tricky async loop bug!), and everything I learned about orchestrating multi-agent systems.

🏗️ What I Built: The Civic-Helper Agent

My capstone project is a system designed to bridge the gap between citizens and their local government. Instead of filling out complex forms, a user simply chats with an agent.

The Workflow:

  1. The Interview: The agent acts as a friendly advocate, asking clarifying questions to get the location and specific issue.
  2. The Handoff: Once it has the details, it uses the Agent-to-Agent (A2A) protocol to call a specialized backend agent.
  3. The Action: The backend agent drafts a formal letter and simulates sending it via email to the correct department (e.g., Parks Dept vs. Sanitation).

The Architecture

I used a Sequential Multi-Agent design:

  • Agent 1 (The Advocate): Powered by Google Gemini 2.5 Flash-Lite. Its persona is empathetic and patient. It uses Memory to retain context across the conversation.
  • Agent 2 (The Drafter): A specialized expert running on a simulated backend server. It has strict instructions for formal business writing and access to custom tools.

đź§  Key Learnings & Technical Challenges

This course pushed me far beyond basic prompting. Here are my biggest takeaways:

1. Orchestrating Agents (The A2A Protocol)

I learned that a single prompt isn't enough for complex tasks. By using the A2A Protocol, I could separate concerns. The frontend agent handles the "human" element, while the backend agent handles the "logic" and tooling. This made the system much more reliable—the frontend agent couldn't "accidentally" hallucinate a letter before it had all the facts.

2. State Management is Critical

Initially, the agent would forget context. If a user said "It's on Main Street" in the second message, the agent would forget they were talking about a "broken swing" from the first message.
I implemented InMemorySessionService to manage the session state, ensuring the agent retained the full context of the interview.

3. The "Loop Amnesia" Bug (My Big Blocker)

The hardest technical challenge was integrating the Gradio UI with the Agent Runner.
Because Gradio runs on its own event loop and the Agent Runner expects its own async context, I encountered persistent RuntimeError crashes where the loops were fighting for control.

The Fix:

  • Used nest_asyncio to patch the event loop
  • Re-initialized the agent runner inside the Gradio chat function
  • Re-structured the async workflow

4. Verification with "LLM-as-a-Judge"

I didn't just hope the agent worked; I verified it. Using the concepts from Day 4, I built a custom evaluation script.
It acts as a "Judge," running test cases (like a noise complaint or a pothole) and grading the agent's final output on Professionalism, Tone, and Accuracy. My agent achieved a perfect score on the test set!

🚀 Conclusion

The Google AI Agents Intensive was a fantastic deep dive into the future of software. I went from simple prompting to designing a system with memory, tool use, inter-agent communication, evaluation workflows, and a full UI.

đź”— GitHub Repository: https://github.com/karthik-k11/civic-helper-agent

Thanks for reading!

GoogleAI #Kaggle #AIAgents #Gemini #SocialGood

Top comments (0)