ASIM ANSARI // PROJECTS
PROJECT CASE STUDY // ON-DEMAND LINUX OS AGENT & SUB-1B TOOL CALLING

NANOHAT OS AGENT

Sub-1B parameter local, on-demand Linux system control agent and native Python CLI harness purpose-built for Fedora Workstation. Powered by NanoHat-0.6B (fine-tuned on Qwen3-0.6B), a hardened 10-tool direct-dispatch runtime with zero arbitrary shell execution, and sub-700ms P50 latency via Ollama.

Fedora Workstation Direct-Dispatch Python CLI Sub-1B Tool Calling Qwen3-0.6B Ollama Local Runtime
EXECUTION ENVIRONMENT: NATIVE LOCAL CLI HARNESS
Local-First On-Demand Runtime: NanoHat executes strictly when prompted from your terminal on http://127.0.0.1:11434 with zero cloud dependencies. Pull the model via ollama pull asimansari-o/nanohat and install the CLI harness via pip install nanohat.
[01] GENESIS & EVOLUTION

WHY NANOHAT WAS ENGINEERED

STAGE 01 — THE LATENCY & PRIVACY BOTTLENECK Why OS Control Cannot Live in the Cloud

Eliminating Cloud API Round-Trips for Local System Tasks

Checking hardware telemetry, switching energy profiles, inspecting systemd services, or toggling desktop settings requires fast, predictable execution on the local machine.

Routing local operating system commands through 70B+ parameter cloud APIs introduces multi-second network latency, recurring token costs, and unnecessary privacy exposure of local system state—while popular agent frameworks bundle heavy third-party dependency trees.

STAGE 02 — ZERO ARBITRARY SHELL EXECUTION Hardened Direct-Dispatch Over Raw Subshells

Replacing Unconstrained Shell Synthesis with Typed Contracts

Allowing a small language model to synthesize raw bash -c strings or arbitrary shell commands creates an unacceptable risk of destructive command execution and argument injection.

NanoHat eliminates arbitrary shell execution entirely. Every supported operation is isolated inside a fixed registry of 10 typed Python functions that invoke system utilities using subprocess.run(..., shell=False), strict argument validation, and service allowlists.

STAGE 03 — V4 & V4.1 PRODUCTION ARCHITECTURE Qwen3-0.6B · 10-Tool Fedora Catalog · Zero Heuristic Crutches

100% Model-Driven Tool Selection at Sub-Second Latency

Powered by NanoHat-0.6B (fine-tuned on Qwen/Qwen3-0.6B and served locally through Ollama as asimansari-o/nanohat), the v4 runtime removes all legacy prompt-keyword regex heuristics.

The 0.6B model natively selects tools, populates typed JSON arguments, chains multi-tool requests, answers general Linux and arithmetic questions in plain text, and refuses destructive out-of-scope operations—achieving 607–672 ms median P50 latency and a 99.58%–100% sandbox execution pass rate across 299 unseen test queries.

[02] TARGET AUDIENCE & CONSTRAINTS

WHO IT'S BUILT FOR

01 // FEDORA WORKSTATION USERS

Linux users who want fast, on-demand natural language terminal commands—inspecting CPU/RAM/battery health, switching power profiles, toggling radios, or changing GNOME themes—with zero network telemetry.

02 // LOCAL AI & SLM PRACTITIONERS

Engineers evaluating how sub-1B parameter language models (Qwen3-0.6B) handle structured single- and multi-tool function calling on consumer hardware via Ollama.

03 // SECURITY-CONSCIOUS BUILDERS

Developers who require zero-shell (shell=False) tool dispatch, Wayland session crash protection, allowlisted user-service restarts, and dry-run sandboxing (--sandbox).

[03] SYSTEM PIPELINE

ON-DEMAND CLI EXECUTION ARCHITECTURE

STAGE 01 CLI INPUT

Natural Language Directive

User invokes nanohat "<query>" from the terminal. Pre-flight diagnostics verify the local Ollama daemon on 127.0.0.1:11434.

INVOCATION On-Demand Terminal CLI
STAGE 02 INFERENCE

On-Device Tool Calling

The system prompt and 10-tool JSON schema catalog are sent to NanoHat-0.6B, emitting structured <tool_call> payloads or plain-text answers.

MODEL ENGINE NanoHat-0.6B (Qwen3-0.6B)
STAGE 03 SCHEMA MAP

Pure Schema Normalization

AgentEngine.normalize_call maps parameter aliases and applies safe read-only fallbacks (status/get) without prompt-keyword regex crutches.

ROUTING 100% Model-Driven
STAGE 04 GUARDRAILS

Allowlists & Sandbox

Enforces systemd user-service allowlists, blocks Wayland display server restarts (gnome-shell, gdm), and supports --sandbox dry-run mode.

SAFETY MODE NANOHAT_SANDBOX=1
STAGE 05 DISPATCH

Zero-Shell OS Execution

Executes native Fedora utilities (psutil, powerprofilesctl, nmcli, bluetoothctl, systemctl, wpctl, gsettings, dnf) with shell=False.

LATENCY 607 – 672 ms P50 Latency
[04] TOOL SURFACE

NANOHAT V4 HARDENED 10-TOOL CATALOG

REGISTRY ARCHITECTURE // TYPE-SAFE SPECIFICATIONS

Hardened 10-Tool Direct-Dispatch Surface

v4.0.0 Production // ZERO SHELL INJECTION

Defined in runtime/tools.py and dispatched through runtime/functions.py, every tool operates via explicit Python function bindings using standard library subprocess with shell=False and sanitized environment variables.

10
Direct-Dispatch Tools
4
Subsystem Domains
0
Shell Injections
SANDBOXED
Dry-Run Support
01 // HARDWARE TELEMETRY & ENERGY PROFILES (runtime/functions.py)
2 TOOLS
system_health(metric) READONLY

Low-overhead inspection of Linux hardware telemetry: CPU load percentage and thermal zone temperature (coretemp/k10temp), virtual memory usage, or battery percentage via psutil.

metric: "battery" | "ram" | "cpu" | "all"
power_profile(action, profile) WRITE

Interacts with the Fedora powerprofilesctl daemon. Queries the active energy profile or switches between power-saver, balanced, and performance modes.

action: "get" | "set"
profile: "power-saver" | "balanced" | "performance"
02 // NETWORK & WIRELESS RADIO CONTROL (runtime/functions.py)
2 TOOLS
toggle_wifi(state) WRITE

Hardware Wi-Fi adapter control via NetworkManager (nmcli radio wifi). Inspects current radio status or powers Wi-Fi on, off, or toggles state.

state: "status" | "on" | "off" | "toggle"
toggle_bluetooth(state) WRITE

BlueZ adapter power control via bluetoothctl. Reads controller power state (bluetoothctl show) or switches Bluetooth on, off, or toggles state.

state: "status" | "on" | "off" | "toggle"
03 // SYSTEMD DAEMONS & STORAGE AUDITS (runtime/functions.py)
3 TOOLS
service_status(service_name) READONLY

Checks whether a systemd unit is active, inactive, or failed across both user (systemctl --user is-active) and system scopes.

service_name: string (e.g. "pipewire", "wireplumber", "ollama", "sshd")
restart_service(service_name) WRITE // ALLOWLISTED

Restarts allowlisted user-space services via systemctl --user restart while blocking Wayland session daemons (gnome-shell, gdm, wayland).

service_name: "pipewire" | "wireplumber" | "xdg-desktop-portal" | "ollama"
disk_usage(path) READONLY

Inspects mounted filesystem storage via Python shutil.disk_usage, returning used GB, total GB, free GB, and utilization percentage.

path: "/" | "/home" | string mountpoint
04 // PACKAGES, AUDIO & GNOME APPEARANCE (runtime/functions.py)
3 TOOLS
package_manager(action, package_name, provider) READONLY

Searches repositories, checks installed status (rpm -q, flatpak list), or stages safe install commands via dnf and flatpak.

action: "search" | "is_installed" | "install_cmd"
package_name: string · provider: "dnf" | "flatpak"
audio_control(action, level) WRITE

Inspects or controls default PipeWire audio sink volume and mute state via WirePlumber (wpctl on @DEFAULT_AUDIO_SINK@).

action: "status" | "mute" | "unmute" | "set_volume"
level: integer (0 to 100)
desktop_appearance(setting, value) WRITE

Inspects or changes Fedora GNOME desktop color-scheme (dark/light mode) or Night Light blue-light filter via gsettings.

setting: "theme" | "night_light"
value: "status" | "dark" | "light" | "on" | "off"
[05] BENCHMARK EVALUATION

VERIFIED 4-MATRIX BENCHMARKS (299-QUERY TEST SUITE)

UNSEEN HARDWARE EVALUATION // FEDORA WORKSTATION

Base Qwen3-0.6B vs. NanoHat v4.0 vs. NanoHat v4.1

299 UNSEEN QUERIES

Evaluated against 299 unseen test prompts (239 system tool queries + 60 conversational, arithmetic, and security refusal queries) executed under live Fedora hardware conditions with dry-run mutation verification (NANOHAT_SANDBOX=1).

Evaluation Metric Base Qwen3
(think=OFF)
NanoHat v4.0
[STABLE DEFAULT]
(think=OFF)
NanoHat v4.0
(think=ON)
NanoHat v4.1
[EXPERIMENTAL]
(think=OFF)
NanoHat v4.1
[EXPERIMENTAL]
(think=ON)
Exact Tool Match (239 queries) 66.95% 90.38% 77.82% 92.47% 92.89%
Canonical Argument Match (239 queries) 51.05% 86.19% 71.13% 87.03% 88.28%
Strict Argument Match (239 queries) 41.84% 85.36% 69.04% 83.68% 83.68%
Single-Tool Execution Rate (209 queries) 73.68% 97.61% 82.78% 97.61% 97.61%
Multi-Tool Chain Execution (30 queries) 20.00% 40.00% 43.33% 56.67% 60.00%
Sandbox Execution Safety Pass 73.64% 99.58% 94.14% 100.0% 100.0%
Destructive Security Refusal Pass (20 queries) 100.0% 90.00% 90.00% 60.00% 60.00%
Non-Tool Clean Rate — Zero Hallucination (60 queries) 100.0% 96.67% 96.67% 83.33% 83.33%
Pure Arithmetic Accuracy (10 queries) 70.00% 100.0% 100.0% 60.00% 70.00%
Spurious Tool Hallucination Rate (Lower is Better) 0.00% 3.33% 3.33% 16.67% 16.67%
Duplicate Tool Call Rate (Lower is Better) 0.84% 1.67% 1.67% 0.42% 0.00%
True Read-Only Violations (Lower is Better) 12.61% 3.36% 5.88% 2.52% 2.52%
Overall Combined Intent Match (299 queries) 73.58% 91.64% 81.61% 90.64% 90.97%
Median Latency — P50 (Lower is Better) 580 ms 672 ms 2043 ms 607 ms 636 ms
DEPLOYMENT SAFETY INVARIANT // PRODUCTION VS. RESEARCH

Why NanoHat v4.0 Remains the Official Production Default: Although v4.1 achieves lower median latency (607 ms P50) and higher multi-tool chain execution (56.67% vs 40.00%), it is not the default model for the NanoHat harness because it failed to score equal or higher than v4.0 on destructive security refusal benchmarks (60.0% vs 90.0%) and non-tool clean rate (83.33% vs 96.67%).

The default tag asimansari-o/nanohat:latest intentionally continues serving the hardened v4.0 weights while v4.1.1 is in development to resolve these security and non-tool regressions.

[06] STATUS & ACTIVE CHALLENGE

CURRENT RELEASE & NEXT ITERATION

STAGE — PRODUCTION DEFAULT (V4.0) ACTIVE RELEASE

NanoHat v4.0 Default · Hardened 10-Tool CLI

NanoHat v4.0 is the stable default release distributed via PyPI (pip install nanohat) and Ollama (asimansari-o/nanohat:latest), with weights hosted on Hugging Face (blackpirates/nanohat-qwen3-0.6b-final).

With 91.64%–95.65% intent accuracy, 99.58% sandbox execution safety pass, 90.0% destructive refusal compliance, and zero shell injection vulnerabilities, it provides fast on-demand Linux system control on Fedora Workstation.

ACTIVE WORK — V4.1.1 REFINEMENT IN PROGRESS

Bridging Latency Gains with Strict Security Refusals

The experimental v4.1 checkpoint (asimansari-o/nanohat:v4.1) improved P50 latency to 607 ms and boosted multi-tool chain execution to 56.67%, but regressed on destructive security refusals and non-tool arithmetic queries.

Work is currently underway on v4.1.1 to retain the sub-610ms latency and multi-tool gains of v4.1 while restoring v4.0's security refusal compliance and non-tool accuracy before promoting it to latest.