AutoAdmin.dk /
SECURITY NEWS
Loading security news…

AutoAdmin.dk / CTO Playbook / AI & automation

AI & automation / Intermediate

Run your first small local LLM agent

Run a local model with Ollama and let it request one harmless, explicitly allowed tool.

My approach

I start with a read-only tool and a hard limit on the agent loop. I keep the model local and never hand it a general shell, filesystem, or production credential.

Before I start

  • A computer supported by Ollama, Python 3, and enough free disk/RAM for the selected model.
  • Permission to install software and download model weights; review the model licence.
  • The downloadable example uses qwen3:4b. Smaller models trade capability for lower resource use.

Step by step

01

Install Ollama from its official site

Install the supported Ollama package for your OS. Start the local service if the installer has not started it. Downloading software and weights requires Internet access; subsequent inference in this example uses localhost.

Ollama: quickstart

02

Download and test a local model

Run the commands below. Keep a local model tag and avoid cloud model variants. My first test is a short question with no confidential data.

ollama pull qwen3:4b
ollama run qwen3:4b "Explain what a backup is in one sentence."

Ollama: quickstart

03

Create an isolated Python environment

Use the commands for your OS. Then install the Ollama client inside that environment. I keep this lab separate from system Python.

# Windows PowerShell
py -m venv .venv
.\.venv\Scripts\python -m pip install ollama

# Linux / macOS
python3 -m venv .venv
.venv/bin/python -m pip install ollama
04

Download the example agent

Save local-agent.py from the downloads below in the same folder. The only available tool returns a fictional service status. It validates the name, refuses unknown tools, and limits tool rounds. It never runs the model’s text as code.

05

Run a tool request

Use your environment’s Python executable. The result should include a TOOL line followed by a short explanation of the fictional status.

# Windows
.\.venv\Scripts\python local-agent.py "What is the status of the demo portal?"

# Linux / macOS
.venv/bin/python local-agent.py "What is the status of the demo portal?"
06

Understand the loop

The client sends the model a tool schema. The model proposes a call; the Python allowlist decides whether to execute it. The result returns to the model as a tool message. I keep these separate so a model suggestion is never itself authority to act.

Ollama: tool calling and agent loops

07

Test a refused request

Ask the agent to delete a file or read a secret. The program has no such tool, so no operation can occur. If the model claims that it performed an action, the absence of a TOOL line confirms it did not; improve instructions and keep the capability boundary.

08

Replace the demo carefully

For a real next step, I add one read-only API function with narrow inputs, least-privilege credentials, a timeout, and a small output. I retain explicit approval before any future write operation. I keep the Ollama service on localhost rather than opening port 11434 to the Internet.

How I check the result

0 of 4 checks completed

Checklist progress stays in this browser. I use it to track checks, not to certify a deployment or compliance.

If something does not work

Connection refused

Start Ollama and confirm its local service is available.

Model missing or too slow

Run ollama list, pull the exact tag, or choose a smaller tool-capable local model and update the example.

No tool call

Try an explicit demo-service question. Small models may answer without a tool; never accept that as a live status result.

My working templates

Local read-only agent example

I allow one fictional status tool, validate its inputs, and cap the loop at three rounds.

Download PY ↓
Agent test cases

I record expected answers, permission checks, failures, and evidence before release.

Download CSV ↓

Official sources I checked

I checked these sources on 13 October 2026. Product screens and legal requirements change; I verify the relevant source before a production rollout or legal decision.

What I would do next

My reference shelf

Useful Websites

Microsoft Learn & Docs ↗

Official docs for M365, Azure, Entra, Intune and Graph API.

LazyAdmin GitHub ↗

Practical PowerShell and M365 automation scripts and guides.

BleepingComputer ↗

Security news, malware analysis, and vulnerability writeups.

MXToolbox ↗

DNS, MX, SPF, DMARC, blacklist and SMTP diagnostics.

SSL Labs Server Test ↗

Deep TLS/SSL server analysis and certificate grading.

Have I Been Pwned ↗

Check if an email or password appeared in a known data breach.

VirusTotal ↗

Scan files, URLs and IPs with 70+ antivirus and threat engines.

Shodan ↗

Search engine for internet-connected devices and exposed services.

Regex101 ↗

Build, test and debug regular expressions with live explanation.

JSON Crack ↗

Visualize, edit and explore JSON structures as interactive graphs.

OneTimeSecret ↗

Share passwords and secrets securely — link expires after first read.

JWT.io ↗

Decode, verify and generate JSON Web Tokens in the browser.

Down For Everyone Or Just Me ↗

Instantly check if a website is down globally or just for you.

WhatIsMyIP ↗

IP address, ASN, geolocation and network info lookup.

Browserling ↗

Free online cross-browser testing across multiple OS and versions.

What changed

Changelog

Loading changelog…

Buy me a coffee
WordPress Appliance - Powered by TurnKey Linux