Eric Jin← Back to projects
PythonOpenAIFunction CallingAgent LoopTool Use

Mini Agents — Tool-Use Loop

OpenAI function-calling agent that plans and solves problems using a live todo list

Overview

Built a minimal but complete AI agent using OpenAI's function-calling API. The agent receives an open-ended problem, autonomously breaks it into steps via a todo list, executes each step in order, and returns a final answer — all without human intervention. The project demonstrates the core loop behind every tool-using agent: model decides → tool executes → result feeds back → repeat until done.

Live Demo

Mini Agents — Live Demo

AI

Type any problem. The agent plans steps, executes them, and returns an answer.

Try:
Results will appear here

Methods

Defined two Python tools: create_todos (adds a list of steps) and mark_complete (marks a step done with notes)
Described each tool as a JSON schema and registered them with the OpenAI chat completions API
Implemented dynamic dispatch via globals() — tool name from the model maps directly to a Python function call
Built the agent loop: call model → if finish_reason is tool_calls, execute tools and append results → repeat until text response
Used Rich console markup for colored, strikethrough-rendered todo output
Tested on a multi-step math problem (two-train meeting time) requiring estimation and sequential reasoning

Key Findings

  • The model reliably decomposes open-ended problems into ordered, executable steps before acting
  • Dynamic dispatch via globals() keeps the loop generic — any registered Python function becomes a callable tool
  • The agent self-corrects by marking steps complete with notes, creating a readable audit trail of its reasoning
  • Structured system prompting (plan first, then execute, no clarifying questions) is key to autonomous behavior

Results

Full agent loop in under 60 lines of Python — no framework required

Agent correctly solved the two-train problem end-to-end: estimated Boston–NYC distance, computed meeting time

Todo list rendered live with Rich — completed steps shown in green strikethrough as the agent works

Reusable pattern: swap tools and system prompt to build any tool-using agent on the same loop

Ask About This Project

Have a technical question? Ask here.