Gentmini

๐Ÿ“‚ Repo: github.com/babanini95/gentmini

I’ve been curious about AI agent for a while now. It has been a hot topic in some of my social media timelines. And recently, Iโ€™ve been diving deeper into how AI agents work. Not just from the outside as a user of ChatGPT or Gemini, but how you can wire up a language model with tools and make it interact with an environment.

To make the learning process hands on, I built Gentmini: a minimal AI agent using Googleโ€™s Gemini API. Itโ€™s not a full fledged framework, but a focused learning project that helped me practice Python, functional programming, and understand the building blocks of agent design.


๐ŸŽฏ Motivation & Learning Goals

The goals of this project are pretty simple:

  • Explore multidirectory Python project structures
  • Understand how AI agents work under the hood instead of treating them as black boxes
  • Practice Python + functional programming in a practical setting

The point wasnโ€™t to reinvent the wheel by training a new LLM, but to see how to build an agent layer on top of an existing LLM.


โš™๏ธ How Gentmini Works

At a high level, Gentmini acts as a bridge between user input, the Gemini API, and a set of predefined functions.

Hereโ€™s the flow:

  1. User enters a task. Example: โ€œAdd a new function to the calculatorโ€.
  2. Gemini processes the instruction.
  3. The agent checks if it needs to call one of its tools (functions). If needed, it calls the function with the right parameters. The checks and function call run in an iteration until the task is complete or a max step count is reached.
  4. The function executes inside a controlled working directory (a simple calculator app).
  5. The result is passed back through the agent to the user.

Currently, Gentmini comes with four core functions:

  • Get file info
  • Read a file
  • Write to a file
  • Run Python code

This allows the agent to inspect, edit, and execute code in a constrained environment.


๐Ÿ—‚๏ธ Project Structure

gentmini/
โ”œโ”€โ”€ calculator/                 # A simple calculator app. Used for agent's working directory
โ”œโ”€โ”€ functions/                  # Functions that the agent can call
โ”‚   โ”œโ”€โ”€ function_schema.py      # Function schemas for declaration
โ”‚   โ”œโ”€โ”€ get_file_content.py     
โ”‚   โ”œโ”€โ”€ get_files_info.py
โ”‚   โ”œโ”€โ”€ run_python.py
โ”‚   โ””โ”€โ”€ write_file.py         
โ”œโ”€โ”€ call.py                     # Function that agent uses to call functions
โ”œโ”€โ”€ config.py                   # Configuration file for the project
โ”œโ”€โ”€ main.py                     # Main entry point for the agent
โ”œโ”€โ”€ pyproject.toml              # Project metadata and dependencies
โ”œโ”€โ”€ tests.py                    # Tests for the project
โ””โ”€โ”€ README.md                   # Documentation

๐Ÿงฉ Challenges & Learnings

A few key things I learned while building Gentmini:

  • Schemas matter: structuring function definitions makes it easier for the LLM to call them reliably.
  • Descriptions matter: writing clear, concise descriptions for each function helps the model understand their purpose. Few times, I had to iterate on the wording to make the agent behave as expected.
  • Safety first: even though this was a toy project, itโ€™s important to limit execution to a specific directory to avoid destructive file operations.
  • Structure helps learning: organizing code into clear modules (instead of a single messy script) made it easier to see how everything connected.

This gave me a much clearer sense of whatโ€™s really happening when you hear the term โ€œAI agent.โ€


๐Ÿ”ฎ Whatโ€™s Next?

Gentmini is small by design, but there are plenty of directions it could grow:

  • Add more tools (web search, data analysis).
  • Improve error handling and logging.
  • Expand beyond the calculator directory into broader environments.

__