AI Agents with Hands: A Technical Look at Local Agent Architecture

    This article breaks down the architecture behind local, always-on AI agents that can actually execute actions on your machine. It covers why these systems favor a local-first daemon written in TypeScript, how a multi-channel message gateway unifies inputs from platforms like Telegram, WhatsApp, and Slack, and how LLM routing and tool-calling mechanisms such as ReAct and Plan-and-Execute drive decisions. It also explains sandboxing, permission control, and human-in-the-loop safeguards, followed by practical use cases in DevOps, knowledge management, and coding assistance. Developers will learn the core components and engineering practices needed to build safe, reliable agents that give AI real "hands."

    Introduction: The Shift from “Language Model” to “Acting Entity”

    Traditional large language model (LLM) interaction is fundamentally a “request-response” pattern: the user submits a prompt, and the model returns text. In this mode, the AI is a “brain with no hands or feet.” It can offer advice, generate code, or draft copy, but it cannot directly operate the operating system, call local APIs, or manage the file system.

    In recent years, the industry has popularized a vivid concept: the “LLM with hands.” This does not refer to a change in model structure, but to the evolution of the AI agent architecture. By introducing a tool use (function calling) mechanism, the LLM gains the ability to drive an external execution environment. These systems are commonly referred to as “local always-on agents” or “personal AI agents.”

    The core logic of such systems is straightforward: an always-on daemon process running on the user’s machine serves as the core, an instant messaging application acts as the interaction entry point, a large model serves as the decision-making hub, and commands are ultimately executed within a local security sandbox—running shell commands, reading and writing files, or automating a browser. Setting aside specific commercial products, this article examines the technical architecture, core components, and engineering practices behind building this kind of “AI execution entity.”


    1. Core Architecture: Why Choose an Always-On Process Model?

    Unlike traditional web SaaS services, this kind of “personal AI assistant” typically adopts a local-first architecture. At its core is an always-on daemon process deployed on the user’s PC or a private server.

    1.1 Technology Choice: The Advantages of TypeScript and CLI

    In the open-source community, why do such projects tend to use TypeScript rather than Python or Go to build CLI applications?

    • Async I/O and event-driven design: An agent must simultaneously handle commands from a message queue, requests from HTTP APIs, and callbacks from child processes. Built on the Node.js event loop model, TypeScript is naturally suited to high-concurrency I/O operations without blocking the main thread.
    • Type safety: Agents involve complex data structures such as message schemas, tool definitions, and configuration objects. TypeScript’s static type checking catches most low-level errors at compile time, which is critical for a daemon that runs long-term and handles sensitive system calls.
    • Cross-platform compatibility: Running on the Node.js runtime, TypeScript-compiled code runs seamlessly on Windows, macOS, and Linux, with no need to rewrite low-level call logic for each operating system.

    1.2 Process Model and Lifecycle

    This process does not expose itself externally as a web server. Instead, it runs as an event-driven middleware. Its lifecycle typically includes:

    1. Initialization: loading configuration files (API keys, channel tokens, permission allowlists) and registering the toolchain.
    2. Listening: establishing a long-lived connection or webhook listener with external communication channels (such as the Telegram Bot API, WhatsApp Business API, or Slack Events API).
    3. Execution: receiving a message, parsing intent, calling the LLM, generating an action plan, executing tools, and returning results.
    4. Supervision: using tools like Systemd, Launchd, or PM2 to automatically restart after a crash and ensure continuous availability.

    2. Connection Layer Design: A Message Gateway That Breaks Down App Silos

    If the AI assistant could only interact with the user through a CLI, its value would be greatly diminished. Therefore, a multi-channel gateway is the lifeline of such systems.

    2.1 Unified Message Abstraction Layer

    To support different IM platforms, the system must internally design a unified message model. Regardless of which platform a message comes from, it is ultimately converted into a standard { sender, channel_id, content, timestamp } structure.

    1. interface UnifiedMessage {
    2. id: string;
    3. userId: string;
    4. channel: 'telegram' | 'whatsapp' | 'slack' | 'discord';
    5. text: string;
    6. attachments?: Buffer[]; // Handle images or files
    7. timestamp: number;
    8. }

    2.2 Channel Adapter Pattern

    Because different messaging platforms have different API characteristics (such as Telegram’s Bot API limits or WhatsApp’s encryption protocol), the system needs an adapter layer.

    • Telegram: Uses long polling or webhooks to receive messages, suitable for rapid prototyping.
    • WhatsApp/Signal: Usually requires unofficial libraries or a commercial API gateway to bridge, handling end-to-end encryption concerns.
    • Slack/Discord: Built on WebSocket or HTTP Events APIs, supporting more complex Block Kit interactive UIs.

    This design means the core agent logic does not need to care about the message source and can focus solely on the “understand-decide-execute” flow.


    3. The Intelligence Hub: LLM Routing and Tool-Calling Mechanisms

    The key to having “hands” is tool use. The LLM itself does not know how to execute shell commands; it can only generate structured JSON instructions, which the host program parses and executes.

    3.1 Model Routing Strategy

    To balance cost and performance, a mature agent system usually does not bind to a single model but supports multi-model routing:

    • Complex reasoning tasks: Call a top-tier cloud model (such as Claude 3.5 Sonnet, GPT-4o, or Qwen Max) for code generation and complex logical planning.
    • Simple classification/formatting: Call a lightweight model or a small locally fine-tuned model (such as Llama 3 8B or Qwen-7B) to reduce latency and token costs.
    • Privacy-sensitive tasks: Process through a locally deployed inference service (such as Ollama or vLLM) to ensure data never leaves the internal network.

    3.2 ReAct and Plan-and-Execute Patterns

    Agent execution logic usually follows one of two mainstream paradigms:

    1. ReAct (Reason + Act): The model alternates between generating “thoughts” and “actions.” For example:
      • Thought: The user asked me to organize the desktop, so I need to list the files first.
      • Action: execute_shell(command="ls -la ~/Desktop")
      • Observation: [file list]
      • Thought: There are temporary files that need to be deleted…
    2. Plan-and-Execute: A planner LLM first generates a complete multi-step plan, then an executor carries it out step by step. This pattern suits long-chain tasks and reduces the number of model calls, but it is less fault-tolerant.

    3.3 Tool Registration and Description (Tool Schema)

    An agent’s capability boundary is determined by the tools it registers. At the code level, this is usually implemented through a registry:

    1. const toolRegistry = new Map();
    2. toolRegistry.set('read_file', {
    3. description: 'Read the contents of a local file; supports txt, md, and code files',
    4. parameters: {
    5. path: { type: 'string', required: true }
    6. },
    7. execute: async (params) => fs.promises.readFile(params.path, 'utf-8')
    8. });

    The LLM decides whether to call a tool and what parameters to pass by analyzing its description and parameters. Therefore, precise natural-language tool descriptions are key to strong agent performance.


    4. Execution Layer: Local Sandbox and Security Protection

    Giving AI direct root access to operate a computer is extremely dangerous. Therefore, the “hands” must be confined within a sandbox.

    4.1 Permission Control Strategy

    • Path allowlist: Restrict the AI to specific directories (such as ~/Projects or ~/Downloads) and forbid access to sensitive system paths (such as /etc or Windows’ System32).
    • Command filtering: Before executing a shell command, intercept dangerous instructions (such as rm -rf /, dd, or mkfs) using regular expressions or AST parsing.
    • Human-in-the-loop (HITL): For high-risk operations (such as deleting files, sending emails, or running sudo commands), the system must pause and request a second confirmation from the user.

    4.2 Sandbox Isolation Technologies

    To further isolate risk, the following technology stack can be used:

    • Containerization: Use Docker or Podman to encapsulate the agent’s execution environment so that even if it is compromised, the host machine is unaffected.
    • Virtual file system: Use a library like memfs to simulate a file system in memory so that the testing phase never touches the real disk.
    • Environment variable injection: Manage sensitive API keys through environment variables or a .env file, and never hardcode them in prompts or code.

    5. Typical Use Cases and Engineering Practices

    Based on the architecture above, such local AI assistants can be widely applied in the following scenarios:

    1. Automated operations and DevOps: By sending “restart the test environment service” in a chat window, the agent automatically SSHs into the server, runs the script, and returns the logs.
    2. Personal knowledge management (PKM): Watch a specific folder, automatically parse downloaded PDFs, extract summaries, and store them in a local vector database (such as ChromaDB or Qdrant).
    3. Intelligent coding assistance: Beyond generating code, automatically run tests, capture errors, fix bugs, and resubmit, forming a closed loop.
    4. Cross-platform task orchestration: For example, “when a GitHub PR notification arrives, automatically pull the code, run the CI script, and if it fails, analyze the logs and comment.”

    6. Summary and Outlook

    The popularity of the “Claude with hands” concept marks the official transition of AI applications from the “information provision” stage to the “productivity replacement” stage. Although the specific mascots and product forms mentioned in the original content each have their own characteristics, the underlying technical logic—an always-on local process built with TypeScript + a multi-channel message gateway + an LLM-driven tool-calling chain + strict sandbox security mechanisms—has become the industry-standard paradigm.

    For developers, understanding and mastering this architecture means being able to build intelligent agents that genuinely solve user pain points. Future competition will no longer be solely about model parameter scale, but a comprehensive contest of agent engineering capability, toolchain ecosystem richness, and safety alignment mechanisms. What we need to focus on is not a specific “lobster” or “cat,” but how to give AI safe, reliable, and efficient “hands” within our own technology stack.