DEV Community

Guru Ashutosh
Guru Ashutosh

Posted on

CodeZero: Building an AI Agent That Learns Using Hindsight

AI assistants are becoming increasingly capable, but one major limitation remains: they often don't remember what happened before.

A conversation can contain important business information, decisions, preferences, and context. Without persistent memory, that information can easily be lost.

For HackwithHyderabad 3.0, we built CodeZero, an AI assistant designed to explore how persistent memory can make AI agents more useful over time.

๐Ÿง  What is CodeZero?

CodeZero is a conversational AI application that can store relevant information from previous interactions, retrieve it when needed, and use it to provide more contextual responses.

The core of the project is Hindsight by Vectorize, which provides the persistent memory layer.

Instead of treating every interaction as completely new, CodeZero can retrieve relevant memories and use them alongside the current conversation.

๐Ÿ’ก The Idea

Imagine you're using an AI assistant for your business.

During one conversation, you tell it:

Information about your products
Your target customers
Marketing strategies
Previous campaign decisions
Business goals

Later, you ask:

"What should we focus on for our next campaign?"

A traditional chatbot may only have access to the current conversation.

CodeZero can retrieve relevant information from previous interactions and use that context when generating its response.

That's the core idea behind our project:

AI shouldn't just answer. It should remember and learn from experience.

๐Ÿง  How Hindsight Fits In

Hindsight acts as the memory layer of CodeZero.

When a user sends a message:

User โ†’ Flutter โ†’ FastAPI โ†’ Hindsight

Hindsight retrieves memories that are relevant to the current query.

Those memories are then provided to the LLM along with the user's current message.

The LLM generates the response, and the interaction can then be stored as a new memory.

This creates a simple loop:

Remember โ†’ Retrieve โ†’ Reason โ†’ Respond โ†’ Learn

๐Ÿ—๏ธ Architecture

Our application consists of four main parts:

Frontend โ€” Flutter

We built the user interface using Flutter.

The application provides:

User authentication
Chat interface
Multiple chat sessions
Chat history
New conversations
Persistent user accounts
Backend โ€” FastAPI

FastAPI acts as the bridge between the Flutter application, memory system, and LLM.

It handles:

Chat requests
Memory creation
Memory retrieval
LLM requests
Storing new interactions
Memory โ€” Hindsight

Hindsight is the most important part of the architecture.

It allows CodeZero to retrieve relevant information from previous interactions instead of relying only on the current conversation.

LLM โ€” Ollama + Qwen

For response generation, we use Ollama with Qwen, allowing the model to run locally.

This also helped us keep the project lightweight and cost-conscious during development.

๐Ÿ”„ Example Workflow

A simplified request looks like this:

User
โ†“
Flutter App
โ†“
FastAPI Backend
โ†“
Retrieve relevant memories
โ†“
Hindsight
โ†“
Combine memory + current question
โ†“
Qwen
โ†“
AI Response
โ†“
Store new interaction
๐ŸŽฏ Our Demo

For the demonstration, we use a fictional business scenario.

We first provide CodeZero with information about the business, its customers, marketing activities, and previous decisions.

Later, we ask questions that depend on information from those earlier interactions.

CodeZero retrieves the relevant memories through Hindsight and uses them to generate a contextual response.

This demonstrates the difference between an AI that simply responds and an AI agent that can build context over time.

๐Ÿ› ๏ธ Tech Stack

Frontend

Flutter

Backend

FastAPI
Python

Memory

Hindsight by Vectorize

LLM

Ollama
Qwen

Authentication & Database

Firebase Authentication
Firebase Firestore
๐Ÿš€ What We Learned

Building CodeZero helped us understand that adding memory to an AI system isn't simply about storing every previous message.

The important part is being able to:

Store useful information
Retrieve relevant memories
Combine them with the current context
Let the AI decide how that information should influence its response

This is what makes persistent memory interesting for AI agents.

๐Ÿ”ฎ Future Improvements

There are several directions we would like to explore further:

More advanced memory organization
Long-term user preferences
Better business analytics
Multi-user business workspaces
More sophisticated memory retrieval
Improved agent reasoning and planning
๐Ÿ† HackwithHyderabad 3.0

CodeZero was built for the HackwithHyderabad 3.0 โ€” AI Agents That Learn Using Hindsight challenge.

The project gave us the opportunity to explore how persistent memory can change the way we interact with AI agents.

๐Ÿ”— Project Links

GitHub:
www.github.com/guru-012/codezero

Demo Video:

๐Ÿ‘จโ€๐Ÿ’ป Team CodeZero

Built with curiosity, experimentation, and a lot of debugging. ๐Ÿš€

AI #AIAgents #Hindsight #Vectorize #GenerativeAI #Flutter #FastAPI #Ollama #Qwen #Firebase #Hackathon #HackwithHyderabad #MachineLearning #ArtificialIntelligence

Top comments (0)