A small command-line AI coding agent that uses Google's Gemini models with function calling to safely inspect and manipulate a sandboxed project directory. The agent can:
- List files and directories within a configured working directory
- Read file contents (with size limits)
- Run Python files with optional arguments
- Write or overwrite files (creating directories as needed)
All tool operations are constrained to the configured working directory to prevent access outside the sandbox.

- Fallback: Watch the full MP4
- Python 3.13+
- A Google Gemini API key
Python dependencies are managed via pyproject.toml and installed using your preferred tool (e.g., uv, pip).
Using uv (recommended):
# From the project root
uv syncEnvironment variables are loaded via .env (using python-dotenv). Create a .env file in the project root containing:
GEMINI_API_KEY=your_api_key_hereOther runtime configuration lives in config.py:
WORKING_DIR: sandboxed directory for all tool calls (default:./calculator)MAX_CHARS: max characters returned when reading files (default: 10000)MAX_ITERS: safety limit for agent turns (default: 20)
From the project root:
python main.py "Your request here" [--verbose]Examples:
python main.py "List files in the project"
python main.py "Open calculator/main.py and explain the bug" --verbose
python main.py "Run calculator/tests.py"--verboseprints token usage, tool invocations, and intermediate outputs.
Entry point: main.py
- Loads
.env - Builds a conversation with your user prompt
- Calls Gemini (
gemini-2.0-flash-001) with a system instruction (prompts.py) and tool declarations - Handles model tool calls via
dispatcher/call_function.py - Continues until the model returns a final text response or
MAX_ITERSis reached
prompts.py defines the agent’s capabilities and constraints for tool usage.
Declared in dispatcher/call_function.py and implemented under functions/:
-
get_files_info(directory='.')- Lists files in a directory within
WORKING_DIR, returning name, size, and is_dir. - Enforced sandbox: prevents escaping the working directory.
- Lists files in a directory within
-
get_file_content(file_path)- Reads a file within
WORKING_DIRup to 10,000 characters; truncates if larger.
- Reads a file within
-
run_python_file(file_path, args=[])- Executes a Python script inside
WORKING_DIRwith optional args. - Captures stdout/stderr; reports non-zero exit codes.
- Executes a Python script inside
-
write_file(file_path, content)- Writes text to a file inside
WORKING_DIR; creates parent dirs as needed.
- Writes text to a file inside
- Adjust
WORKING_DIRinconfig.pyto target a different sandbox. - Extend tools by adding new functions in
functions/and wiring their schemas intodispatcher/call_function.py. - Keep I/O constrained to
WORKING_DIRto maintain safety.