Local Agents
Those agents are focused on building real, useful local agents.
You can actually build your won mini Copilot/Cursor locally.
1. File System Agent
A file system agent can read, search, and modify files on you computer.
It lets an AI understand your folders, logs, or notes and act on them.
It is the foundation for things like:
"Explain my logs"
"Search all files for bugs"
Log file example:
2026-04-25 10:15:32 INFO Starting application
2026-04-25 10:15:33 INFO Connecting to database
2026-04-25 10:15:34 ERROR Database connection failed: timeout
2026-04-25 10:15:35 WARN Retrying connection (attempt 1)
2026-04-25 10:15:37 INFO Connection established
2026-04-25 10:16:02 INFO User login attempt: user=admin
2026-04-25 10:16:03 ERROR Authentication failed for user=admin
2026-04-25 10:16:10 INFO User login attempt: user=test_user
2026-04-25 10:16:11 INFO Authentication successful for user=test_user
2026-04-25 10:17:45 ERROR Failed to load resource: /api/data (500 Internal Server Error)
2026-04-25 10:18:01 WARN Disk usage at 85%
2026-04-25 10:18:30 ERROR File not found: config.yaml
2026-04-25 10:19:00 INFO Shutting down application
Agent code:
import os
from dotenv import load_dotenv
from pathlib import Path
from openai import OpenAI
load_dotenv()
client = OpenAI()
BASE_DIR = Path(__file__).resolve().parent
PROJECT_PATH = BASE_DIR / "."
def find_log_files(root):
logs = []
for dirpath, _, filenames in os.walk(root):
for file in filenames:
if file.endswith(".log"):
logs.append(os.path.join(dirpath, file))
return logs
def read_file(path):
with open(path, "r", errors="ignore") as f:
return f.read()
def llm(prompt):
response = client.chat.completions.create(
model = "gpt-4.1-mini",
messages = [{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
log_files = find_log_files(BASE_DIR / ".")
for log in log_files:
content = read_file(log)
summary = llm("Summarize errors:\n" + content)
print(f"\n {log}\n{summary}")
2. Command Execution (Safe)
Agents can run shell commands (like git, npm, ls).
You must restrict them to safe commands to avoid dangerous execution.
import os
from dotenv import load_dotenv
from openai import OpenAI
import subprocess
load_dotenv()
client = OpenAI()
ALLOWED_COMMANDS = ["ls", "pwd", "git status"]
REPO_DIR = "/var/docker/minte9/m9github/"
def llm(prompt):
response = client.chat.completions.create(
model = "gpt-4.1-mini",
messages = [{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
def run_command(cmd):
if not any(cmd.startswith(allowed) for allowed in ALLOWED_COMMANDS):
return "Command not allowed"
try:
result = subprocess.check_output(
cmd,
shell=True,
text=True,
cwd=REPO_DIR
)
return result
except Exception as e:
return str(e)
user_input = "pwd"
output = run_command(user_input)
response = llm(f"Explain this output:\n{output}")
print(response)
3. Refactor Function
Given a function, AI improves readability, performance and structure.
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
client = OpenAI()
code =
prompt =
def llm(prompt):
response = client.chat.completions.create(
model = "gpt-4.1-mini",
messages = [{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
new_code = llm(prompt + code)
print(new_code)