Project Case Study

LLM Agent

Terminal-Based Tool Calling Agent

Ravi Rai
2 min read

Developed a terminal-based conversational agent running locally on Ollama utilizing Llama 3 for tool use and structured JSON parsing.

Overview#

1

Developed a terminal-based conversational agent running locally on Ollama utilizing Llama 3 for tool use and structured JSON parsing.

2

Designed a robust control loop orchestrating a system prompt, dynamic tool schemas, and a history array passed to the model on every iteration.

3

Implemented a runtime dispatcher in Python executing functions like weather fetching or SQLite database operations based on the model’s tool calls.

4

Engineered strict Pydantic models mapping tool calls to Python functions ensuring robust JSON validation and error handling.

5

Managed conversational state utilizing a local SQLite store persisting interaction histories and minimizing latency for rapid testing.

Tech Stack#

Python

Control loop & dispatcher

Ollama

Local model inference

Llama 3

Tool calling LLM

SQLite

Conversational state store

Pydantic

Data & schema validation

Ravi Rai

Ravi Rai

AI Engineer & Full Stack Developer · Germany

Expert in Generative AI, LLMs, and Data Engineering. Passionate about building intelligent, agentic systems and scalable full-stack applications.

More about the author →
© 2026 Ravi Rai. All rights reserved.|Privacy