alesanchezr/the-most-basic-agent

★ 0Forks 0PythonGitHub ↗Compare

README

Basic Agent Loop (Python)

Minimal agent loop: observe → decide → act → observe until the model returns a final answer.

Setup

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

Set your Groq API key (e.g. in .env or export):

export GROQ_API_KEY=your-key-here

Run

python agent.py "Fetch https://api.github.com and tell me the current_user_url."

With no argument, it uses a default prompt.

How it works

  • Observe: Messages list (user input + assistant messages + tool results).
  • Decide: One LLM call with tools; it can reply with text only (done) or request tool calls.
  • Act: Run the requested tool (get_request) and append results to messages.
  • Loop: Repeat until the model responds without tool calls or max_steps is reached.

Single tool: get_request(url) — performs a GET request to any URL and returns status and body.

Contributors

alesanchezr

Issues