An experimental, just-for-fun AI agent with a feedback loop. It can call a small set of tools to work with files and run Python scripts on UNIX-like systems.
Important notes:
- Not error-proof. Expect rough edges.
- Supports only UNIX-like systems (Linux, macOS). No Windows support.
pyagent exposes four simple tool functions to the AI agent:
- List files in a directory (with basic info)
- Get the content of a file
- Write to a file
- Run a Python file
These are implemented in the functions/ package and wired through a function-calling layer used by the agent loop.
- The main feedback loop lives in
main.py. It uses Google GenAI to plan and call the available tools. - Tool routing happens in
functions/call_function.pywhich maps the model’s function calls to concrete Python functions. - The four functions are:
functions/get_files_info.py— list directory entriesfunctions/get_file_content.py— read a filefunctions/write_file.py— write/append to a filefunctions/run_python_file.py— execute a.pyfile and capture output
There is also a small sample project under calculator/ that the agent can interact with.
- Python 3.10+
- UNIX-like OS (Linux, macOS). No Windows support.
- A Google GenAI API key configured in your environment (see
config.pyfor how environment variables are read).
Using uv (recommended):
# Ensure you have uv installed: https://github.com/astral-sh/uv
uv venv
uv pip install -r pyproject.tomlUsing pip:
python -m venv .venv
source .venv/bin/activate
pip install -e .Set environment variables (see config.py for exact names). A typical setup includes:
export GOOGLE_API_KEY="your_api_key"From the project root:
python main.pyBy default, the agent is configured to operate within the calculator/ directory when using its tools. You can explore or modify that behavior in functions/call_function.py and the tool implementations.
- Ask the agent to list files in
calculator/. - Have it read
calculator/pkg/calculator.py. - Request changes to a file via the write tool.
- Run
calculator/main.pyand review the output.
Example tool intentions the agent might emit (simplified):
- get_files_info: {"path": "calculator"}
- get_file_content: {"path": "calculator/pkg/calculator.py"}
- write_file: {"path": "calculator/notes.txt", "content": "Hello"}
- run_python_file: {"path": "calculator/main.py"}
- This is a toy project; no guarantees of safety, robustness, or correctness.
- No sandboxing. Running arbitrary Python files can be dangerous. Only run trusted code.
- Limited to UNIX-like systems; paths and process handling assume POSIX semantics.
- The agent can make mistakes; always verify its changes.
main.py— entry point with the agent loopconfig.py— configuration and environment variable handlingfunctions/— tool implementations and routingcalculator/— example project the agent can manipulate