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-600ms 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
Offline On-Demand Runtime: Zero cloud dependencies. Runs private inference via Ollama (ollama pull asimansari-o/nanohat) and dispatches locally through the CLI (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.1.2 FLAGSHIP PRODUCTION ARCHITECTURE Qwen3-0.6B · Multi-GPU Telemetry · 10-Tool Catalog · 93.98% Accuracy

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:v4.1.2 / latest), the v4.1.2 flagship architecture delivers 100% model-driven tool dispatch with verified multi-GPU telemetry.

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 an all-time peak 93.98% overall canonical accuracy, 100.0% destructive security refusal compliance, 100.0% multi-tool partial coverage, and 595.7 ms median P50 latency 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 595.7 ms P50 Latency (1307 ms think=ON)
[04] TOOL SURFACE

NANOHAT V4 HARDENED 10-TOOL CATALOG

REGISTRY ARCHITECTURE // TYPE-SAFE SPECIFICATIONS

Hardened 10-Tool Direct-Dispatch Surface

v4.1.2 Production Flagship // 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 and thermal temperature (coretemp/k10temp), Intel/AMD integrated and NVIDIA discrete GPU load/VRAM/temperature, virtual memory, or battery percentage via psutil, DRM sysfs, and nvidia-smi.

metric: "battery" | "ram" | "cpu" | "gpu" | "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 vs. NanoHat v4.1.2

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
(think=OFF)
NanoHat v4.1
(think=OFF)
NanoHat v4.1.2
[595.7ms P50]
(think=OFF)
NanoHat v4.1.2
[FLAGSHIP SOTA]
(think=ON)
Exact Tool Match (239 queries) 66.95% 90.38% 92.47% 92.89% 96.65%
Canonical Argument Match (239 queries) 51.05% 86.19% 87.03% 85.77% 92.89%
Strict Argument Match (239 queries) 41.84% 85.36% 83.68% 84.94% 89.96%
Single-Tool Execution Rate (209 queries) 73.68% 97.61% 97.61% 99.04% 99.04%
Multi-Tool Chain Exact Match (30 queries) 20.00% 40.00% 56.67% 50.00% 80.00%
Multi-Tool Partial Coverage (30 queries) 43.33% 56.67% 76.67% 73.33% 100.0%
Sandbox Execution Safety Pass 73.64% 99.58% 100.0% 99.58% 99.58%
Destructive Security Refusal Pass (20 queries) 100.0% 90.00% 60.00% 100.0% 100.0%
Non-Tool Clean Rate — Zero Hallucination (60 queries) 100.0% 96.67% 83.33% 100.0% 98.33%
Pure Arithmetic Accuracy (10 queries) 70.00% 100.0% 60.00% 60.00% 100.0%
Spurious Tool Hallucination Rate (Lower is Better) 0.00% 3.33% 16.67% 0.00% 1.67%
Duplicate Tool Call Rate (Lower is Better) 0.84% 1.67% 0.42% 0.84% 0.00%
True Read-Only Violations (Lower is Better) 12.61% 3.36% 2.52% 5.88% 1.68%
Overall Combined Intent Match (299 queries) 73.58% 91.64% 90.64% 94.31% 96.99%
Overall Canonical Accuracy (299 queries) 60.87% 88.29% 86.29% 88.63% 93.98%
Median Latency — P50 (Lower is Better) 580 ms 672 ms 607 ms 595.7 ms 1307.6 ms
Tail Latency — P95 (Lower is Better) 996 ms 1568 ms 4141 ms 1001.1 ms 2518.2 ms
DEPLOYMENT SAFETY INVARIANT // PRODUCTION FLAGSHIP

Production Tag Promotion: asimansari-o/nanohat:latest now serves our v4.1.2 checkpoint. It resolves previous security regressions with 100% refusal compliance, eliminates tool dropping on complex multi-action chains, and integrates native multi-GPU telemetry—all while preserving sub-600ms local execution.

[06] STATUS & ROADMAP

CURRENT RELEASE & NEXT HORIZON

STAGE — PRODUCTION FLAGSHIP (V4.1.2) ACTIVE SOTA RELEASE

NanoHat v4.1.2 Flagship · 93.98% Canonical Accuracy

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

Delivering 93.98% canonical accuracy, 100.0% destructive security refusal pass, 100.0% multi-tool partial coverage, multi-GPU telemetry (Intel/AMD DRM + NVIDIA discrete), and sub-600ms latency, it provides hardened on-demand Linux system control on Fedora Workstation.

RESEARCH ROADMAP — SUBSYSTEM TOPOLOGY IN RESEARCH

Deep Subsystem & Multi-Device Topology Orchestration

Ongoing research builds upon v4.1.2's rock-solid 100% security boundary and polarity invariants to explore composite multi-device audio routing (PipeWire WirePlumber graph nodes), live container lifecycle inspection, and low-overhead kernel tracing diagnostics on Fedora Workstation.

These advancements continue pushing sub-1B parameter models to execute complex multi-subsystem orchestration natively without external cloud dependencies.