← All posts

Agentic AI, Part 2: Build It Locally for Free — and Nine Projects to Try

On this page

A terminal running a local agent: it lists files, requests moves, waits for approval, and prints a summary

In part 1 we opened the box: an agent is just a loop around a language model that can call tools, and we built a working one — with guardrails — against Claude’s API. Two questions came back more than any other. Can I run this without paying for an API? And what should I actually build?

This part answers both. First, you’ll run the exact same agent entirely on your own laptop — zero cost, fully private, no internet required — using Ollama and an open-weight model. Then nine projects to build, ordered from a 40-line warm-up to a proper capstone: a malware-triage agent that runs static and dynamic analysis and writes its own technical report.

The thread running through all of it: the loop never changes. Swap the cloud client for a local one, swap one set of tools for another — the agent skill you learned in part 1 is the same skill here.

Run it locally, for free

In part 1 we built the agent against Claude’s API — the fastest way to get a capable one. But you don’t need a cloud model, or a credit card, or even an internet connection. A laptop from the last few years can run a capable-enough model entirely on your own hardware — which means zero cost, full privacy, and it works on a plane. For a security person especially, “the data never leaves my machine” is sometimes the whole point.

The tool that makes this painless is Ollama. It downloads open-weight models, runs them locally, and — importantly for us — speaks native tool calling, so the exact loop you just learned works unchanged.

Your laptop CPU · RAM · GPU (Apple Silicon is great for this) Ollama runs the model, serves it on localhost:11434 Open model Llama 3.1 / 3.2, Qwen 2.5, Mistral (4-bit quantized) Your loop same code, same tools, same guardrails The only thing that changes from the cloud version is the client. The agent loop, the tools, the memory and the guardrails are identical.

Step 1 — install Ollama and pull a model. One install, one download:

# macOS/Linux (Windows has an installer at ollama.com)
curl -fsSL https://ollama.com/install.sh | sh

# Pull a tool-capable model. Start small; size up only if you need to.
ollama pull llama3.1           # 8B — the sweet spot for local agents
# ollama pull llama3.2:3b      # 3B — snappy, runs on almost anything
ollama run llama3.1 "hello"    # quick sanity check

Step 2 — match the model to your hardware. Ollama ships 4-bit quantized models, so they’re far smaller than the raw parameter count suggests. Rough guide:

Model ~Memory Runs comfortably on Feel
1–3B (llama3.2:3b, qwen2.5:3b) 3–6 GB any modern laptop, CPU-only snappy; fine for simple tool loops
7–8B (llama3.1, qwen2.5:7b) 6–10 GB 16 GB RAM, or any GPU ≥ 8 GB the local-agent sweet spot
13–14B 12–20 GB 32 GB RAM / 12–16 GB GPU stronger reasoning, slower on CPU
30B+ 24 GB+ workstation GPU / Apple Silicon with lots of unified memory diminishing returns on a laptop

Step 3 — point your agent at it. Here’s the Downloads tidy-up agent from part 1, rewritten for Ollama. Notice the tools, the loop and the approval guardrail are exactly the same — only the model call changed:

import json, shutil
from pathlib import Path
import ollama

ROOT = Path("~/Downloads").expanduser()

def list_files(folder: str = ".") -> str:
    """List files and folders inside the Downloads folder.

    Args:
        folder: Sub-folder to list, default '.'.
    """
    path = (ROOT / folder).resolve()
    if not path.is_relative_to(ROOT):
        return "Error: outside the allowed folder"
    return json.dumps([f.name + ("/" if f.is_dir() else "") for f in sorted(path.iterdir())])

def move_file(name: str, dest_folder: str) -> str:
    """Move one file into a sub-folder (created if missing). The user must approve each move.

    Args:
        name: File name inside Downloads.
        dest_folder: Target sub-folder, e.g. 'Documents'.
    """
    src, dest = (ROOT / name).resolve(), (ROOT / dest_folder).resolve()
    if not (src.is_relative_to(ROOT) and dest.is_relative_to(ROOT)):
        return "Error: outside the allowed folder"
    if input(f"  approve move {name} -> {dest_folder}/ ? [y/N] ").lower() != "y":
        return "The user declined this move."
    dest.mkdir(exist_ok=True)
    shutil.move(src, dest / src.name)
    return f"Moved {name} to {dest_folder}/"

TOOLS = {"list_files": list_files, "move_file": move_file}

def run(goal: str, model: str = "llama3.1", max_steps: int = 15):
    messages = [
        {"role": "system", "content": "You are a careful file-organizing assistant. Look before you act."},
        {"role": "user", "content": goal},
    ]
    for _ in range(max_steps):
        res = ollama.chat(model=model, messages=messages, tools=[list_files, move_file])
        msg = res.message
        messages.append(msg)                        # keep the assistant turn (it may hold tool_calls)
        if not msg.tool_calls:                       # no tool wanted -> the model is done
            print("🤖", msg.content)
            return
        for call in msg.tool_calls:
            name = call.function.name
            args = call.function.arguments           # Ollama hands you a dict already
            print("🔧", name, args)
            output = TOOLS[name](**args)
            messages.append({"role": "tool", "tool_name": name, "content": output})
    print("Stopped: step limit reached")

if __name__ == "__main__":
    run("Tidy up my Downloads folder: group files into sensible sub-folders.")
pip install ollama && python tidy_local.py       # no API key, nothing leaves your machine

Honest expectations: a local 8B model is not Claude. It reasons less deeply, follows long instructions less reliably, and will sometimes fumble a tool call. The fixes are practical: pick a model that genuinely supports tool calling (Llama 3.1/3.2, Qwen 2.5, Mistral), keep the toolset small (2–5 tools), write crisp tool descriptions, and lower the temperature for steadier behaviour. For learning the mechanics, for private data, and for simple-to-moderate tasks, local is more than enough — and the skills transfer straight back to the cloud version.

Privacy win: because the model runs on your box, the files, emails and logs your agent reads never touch a third party. That is exactly why local models are worth knowing for sensitive work — the phishing-triage and malware ideas below are built on it.

Nine agents worth building

Reading about agents only gets you so far. Here are nine worth building — most are an evening each, the last is a proper capstone. They track the work I actually do: file chores, phishing and log triage, knowledge retrieval, SOC alert explanation, detection engineering, incident reporting, cloud posture and malware analysis. Every one is the same loop with different tools; each lists the tools you give it and the steps to get there.

🗂️ 1 · Downloads tidy-up sorts Downloads into sub-folders — you already built this one tools: list · move 📧 2 · Phishing triage reads .eml, extracts IOCs, verdicts — all offline & private tools: read · extract 🌙 3 · Night-shift log greps + counts a log, summarizes the anomalies for you tools: grep · count 📚 4 · Notes assistant answers from your own notes, cited — says when unsure tools: search · read 🚨 5 · Alert explainer SIEM/EDR alert → plain English, ATT&CK + what to do next tools: parse · enrich 🎯 6 · Detection writer a behaviour → Sigma + KQL, syntax-checked and explained tools: draft · validate 📝 7 · IR report writer rough notes → an exec-ready incident write-up tools: outline · draft ☁️ 8 · Cloud posture scans IaC for mis- configs, ranks the fixes by real risk tools: scan · explain 🔬 ★ CAPSTONE 9 · Malware report static + dynamic → full technical report with snippets & shots static · detonate · report

Idea 1 — The Downloads tidy-up agent (your warm-up)

Start here, because you already wrote it — it’s the tidy_local.py from the section above. Point it at ~/Downloads, give it list_files and move_file, and keep the approve-each-move guardrail. It’s the ideal first agent: the blast radius is tiny, the feedback is instant, and every core idea (a goal, a couple of tools, a loop, a human gate) is on display in 40 lines.

  1. Run the version you have. python tidy_local.py — watch it list, propose moves, and wait for your y.
  2. Add a dry run. A plan_only flag that prints the moves it would make without touching anything builds the habit of previewing an agent before you let it act.
  3. Give it better judgement. Add a file_info(name) tool (size, modified date, extension) so it can sort by age or type, not just by name — more context, better decisions.
  4. Then let go of the wheel. Once you trust it, drop the per-move prompt for low-risk types (images, archives) while keeping it for anything it’s unsure about. That graduation — from confirm-everything to confirm-what-matters — is the whole trust curve in miniature.

Idea 2 — A private phishing-triage agent

The agent reads a folder of saved .eml files, pulls out the indicators, and gives each a verdict — and because it’s local, sensitive mail never leaves your laptop.

  1. Set the stage. Drop suspect emails as .eml files into ./inbox/.
  2. Give it three read-only tools: list_emails(), read_email(name) (parse the MIME parts into plain text — the same email module trick from my email-spoofing post), and extract_iocs(text) (regex out URLs, domains and IPs).
  3. Write the brief in the system prompt: “You are a SOC triage assistant. For each email: read it, extract indicators, and decide phishing or benign with one line of reasoning. Never open or fetch any link.”
  4. Run the loop over each email. The agent calls read_email, then extract_iocs, then writes its verdict.
  5. Keep it read-only. No tool should click a link or send anything — defang the URLs in output (hxxp://). This is the safe, useful version of the automated triage I warned about in the prompt-injection post: it assists, it never acts.

Idea 3 — A “what happened overnight?” log summarizer

Point it at a log file and get a plain-English morning brief of the anomalies, instead of scrolling thousands of lines.

  1. Pick a log — auth.log, a web access log, a firewall export, or a sample.
  2. Give it query tools, not the whole file: tail_log(n), grep_log(pattern), and count_by(field) (e.g. count failed logins by source IP). Returning summaries instead of raw megabytes keeps a small model focused.
  3. Brief it: “Summarize unusual activity in the last 12 hours. Call out repeated failures, rare source IPs and off-hours access. End with three things a human should check next.”
  4. Loop. The agent greps for failures, counts by IP and user, and writes the brief.
  5. Guardrail: every tool is read-only — it can look, it can’t touch. This is a gentle, safe on-ramp to the detection thinking in my SIFT and Windows DFIR posts.

Idea 4 — An assistant that actually knows your notes

Ask questions and get answers grounded in your Markdown notes, with the source file cited — a tiny, private retrieval agent.

  1. Point it at ~/notes (or your Obsidian vault).
  2. Reuse two read tools — search_notes(keyword) and read_note(name) — the same shape as the MCP notes server in part 1.
  3. Constrain it hard: “Answer only from the notes. Cite the filename you used. If the answer isn’t in the notes, say ‘not in my notes’ — do not guess.” That one instruction is what turns a confident liar into a trustworthy assistant.
  4. Ask away. The agent searches, reads the best matches, and answers with citations.
  5. Level up later: swap keyword search for semantic search by generating embeddings locally (ollama pull nomic-embed-text) and matching on meaning instead of exact words — the “lite” version of RAG from the memory section.

Idea 5 — A SOC alert explainer

An EDR or SIEM fires a cryptic alert at 2 a.m. This agent turns the raw JSON into a plain-English explanation: what triggered it, how serious it is, which ATT&CK technique it maps to, and what to check first. The fastest way to make tier-1 triage less lonely.

  1. Feed it one alert. The raw alert JSON from whatever you run — Defender, Sentinel, CrowdStrike.
  2. Give it two tools: parse_alert(json) (pull out the fields that matter — process, parent, user, host, command line) and lookup_technique(id) (map a signal to its MITRE ATT&CK technique from a local copy of the ATT&CK data).
  3. Brief it: “Explain this alert to a tier-1 analyst in five lines: what happened, severity, the ATT&CK technique, whether it reads like a true positive, and the first three things to check.”
  4. Loop. It parses the alert, maps the technique, and writes the brief.
  5. Keep it advisory. It triages and explains — it does not isolate hosts or close tickets. That stays the analyst’s call. It pairs naturally with the hunting mindset in my Unified Sentinel & Defender XDR and Windows DFIR posts.

Idea 6 — A detection-rule writer

Describe a behaviour — “PowerShell spawned by Word, pulling from a raw GitHub URL” — and get back a draft Sigma rule and the equivalent KQL, syntax-checked, with the logic explained. Your specialty, with the boilerplate removed.

  1. Describe the behaviour in a sentence, or hand it a sample log line.
  2. Give it tools: write_sigma(spec) / write_kql(spec) to draft, and validate(rule) to run the draft through a Sigma/KQL linter so you never ship broken syntax.
  3. Brief it: “Draft a Sigma rule and the equivalent KQL for this behaviour. Explain each condition, call out likely false positives, and suggest a test that proves it fires.”
  4. Loop. It drafts, validates, explains — you refine by sharpening the description.
  5. Test before you trust. A generated rule is a starting point: fire it against known-good and known-bad data before it goes near production — exactly the validation loop from my Atomic Red Team post. The agent drafts; you prove it.

Idea 7 — An incident-report writer

Turn your rough IR notes — the messy timeline, the IOCs, the half-sentences — into a clean, exec-ready report with the sections leadership actually expects. This is the one that buys back your evening after a long case.

  1. Dump your notes. A scrappy Markdown file of what happened, when, and what you found.
  2. Give it: read_notes() and write_report(sections) (render to Markdown/PDF with your house template).
  3. Brief it with the structure: “Produce an incident report with: Executive summary (non-technical), Timeline, Impact, Root cause, Containment & eradication, Lessons learned. Keep the summary leadership-ready and the detail faithful to my notes — never invent facts.”
  4. Loop. It orders the timeline, drafts each section, and flags anything your notes don’t cover rather than filling the gap with a guess.
  5. You own the facts. It’s a phrasing-and-formatting accelerant, not the author of record — read every line, because a report with your name on it is yours. That “never invent facts” rule is what keeps it honest, and it turns the blank-page problem from my DFIR field kit into an editing problem.

Idea 8 — A cloud-posture reviewer

Point it at your infrastructure-as-code — Terraform, Bicep, an ARM template — and get back a ranked list of misconfigurations, each with the fix, before it ships.

  1. Point it at a folder of IaC or exported config.
  2. Give it: list_resources(), read_resource(name), and check_resource(name) — your own checks, or wrap a free scanner like Checkov or tfsec and let the agent reason over its output.
  3. Brief it: “Review these resources for security misconfigurations — public exposure, weak identity, missing encryption, over-broad roles. Rank findings by real-world risk and give the exact fix for each.”
  4. Loop. It reads each resource, runs the checks, and writes a prioritised report.
  5. Advisory, not auto-apply. It proposes; a human applies the fix through the normal pipeline. The same read-and-recommend discipline, pointed at the hardening work in my Microsoft 365 hardening checklist.

Idea 9 — The capstone: a malware-triage agent that writes the report

This is the ambitious one, and it’s squarely in our lane. Point it at a sample inside your isolated lab; it runs the standard static-then-dynamic triage, collects the output, and writes a full technical report — snippets, screenshots and IOCs — in the shape TCM Security’s Practical Malware Analysis & Triage course teaches (the same structure I walk through in my PMAT field guide). It won’t replace an analyst. It will do the grind — hashing, strings, IOC collection, formatting — so you spend your time on judgement.

🧰 Isolated lab REMnux / FLARE VM snapshot first 🔍 Static hashes · strings PE · imports · capa 💣 Dynamic detonate (approve) capture IOCs + pcap 📄 Report Markdown → PDF snippets + screenshots A human approves the detonation; the sample never touches your host. The agent orchestrates the lab — it doesn't fight the malware.
  1. Stage the sample in the lab — and only the lab. Drop the sample (zipped, password-protected, defanged) into the analysis folder of an isolated REMnux / FLARE-VM VM with controlled networking (INetSim or FakeNet), and snapshot it so you can roll back. The agent runs here, not on your daily driver.
  2. Give it a grouped tool belt. Static: hashes(path) (MD5/SHA-256, plus a VirusTotal lookup if you allow network), strings_and_capa(path) (strings + capability detection), pe_info(path) (headers, imports, sections, entropy). Dynamic: detonate(path) (runs it in the sandbox — gated behind your approval, same pattern as move_file), collect_iocs() (Noriben/procmon + packet capture → processes, files, registry, network). Reporting: screenshot(target) (grab the process tree or network graph) and write_report(sections) (render Markdown → PDF).
  3. Brief it with the report template. “You are a malware-triage analyst. Work in order: basic static, then basic dynamic, then IOCs and a YARA rule. Produce a report with these sections — Executive summary, Technical summary, Malware composition (hashes), Static analysis, Dynamic analysis, Indicators of compromise, YARA/Sigma, Appendix. Embed tool output as code blocks and screenshots. Never run the sample outside the lab; ask before detonating.”
  4. Run the loop. It hashes and strings the file, reasons over the imports and capa output, asks your approval, detonates, calls collect_iocs and screenshot, then assembles write_report. The same perceive → reason → act → observe loop — just with heavier tools.
  5. Review before you trust it. Treat the output as a first draft from a keen junior: verify the IOCs, sanity-check the YARA rule, and never ship a report you haven’t read. The win isn’t autonomy — it’s that the tedious 80% is done and formatted by the time you sit down.

One hard guardrail: this agent orchestrates analysis tools inside a sandbox — it does not “use AI to fight malware,” and the model never executes the sample itself. Detonation stays human-approved and lab-bound. Keep the local model for this if the sample is sensitive: nothing about the case leaves your network. (A bigger model reasons better over disassembly — a fair trade-off to make per sample.)

The pattern underneath: all nine are the identical loop — goal, tools, observe, repeat — with sharp tools, one clear system prompt, and a human gate on anything that acts. Build the first and you’ve effectively built them all; the agent skill is reusable, and the tools are the only thing that changes from a Downloads sorter to a malware-triage analyst.

Where this leaves you

Two posts in, you’ve seen the whole arc: an agent is a loop around a model that can call tools, it runs just as well on a free local model as on a frontier API, and the difference between a demo and something you’d trust is the tools you expose and the gates you put in front of them. Pick one, build it this week, and read the traces — that’s how the idea stops being abstract.

Worth reading next: go back to part 1 for the loop, tools, memory and MCP; Anthropic’s Building effective agents; and the Ollama docs for the local models and tool-calling API used here.