How to Build a Self-Evolving AI Agent from Scratch and Connect It to Personal WeChat
This guide walks you through building a self-evolving AI agent from the ground up: preparing a Unix-like runtime, installing the framework with a single script, configuring the model backend, connecting a personal messaging channel, and enabling tools, scheduled tasks, and reusable skill memory. It also covers the permission boundaries and hardening checklist you need before going live.
1. Start With the Goal: You Need an Agent That Works, Not a Chat Box
The capability boundary of large language models keeps expanding, yet most people still interact with nothing more than a question-and-answer dialog box. The real dividing line is whether the model can act on its own. A usable personal agent needs at least three layers of capability: perception (receiving messages you send at any time), decision-making (calling the model to plan steps), and execution (operating the terminal, reading and writing files, searching the web, calling external tool APIs).
An even more critical layer is memory and accumulation. A traditional script starts fresh every run, whereas a self-evolving agent differs in that it abstracts the completed process into reusable skill entries once a task is done, and calls them directly the next time a similar problem appears. The longer you use it, the higher the marginal efficiency. This article builds exactly such a system and finally hooks it up to the personal WeChat you use every day.
2. Environment Prep: Level the Ground First
1. Operating System Choice
Runtime environments for this kind of agent are generally built on Unix-like systems. Common supported options include mainstream Linux distributions, macOS, and the Linux subsystem on Windows (WSL2). Native Windows is generally not supported because it lacks a complete shell and package management. Android devices can run it through a terminal emulator, but extra adaptation is required.
For production, a low-spec cloud host is recommended. An entry-level 1-core, 1G instance billed hourly is enough to carry a resident process and scheduled tasks, and object storage can handle skill library and log backups.
2. Three Things to Prepare in Advance
- A networked machine (local computer or cloud host);
- An instant messaging account that can log in by scanning a QR code, used later for the message channel binding;
- A large model API key. When choosing, focus on two points only: the context window should be no less than 64K tokens, and it must support Function Calling or an equivalent tool-calling protocol; otherwise the agent cannot reliably decide “what to do next.”
3. Network and Dependencies
The install script pulls content from a code hosting platform, so machines in mainland China should configure a proxy or mirror source first. Also make sure curl, git, and a language runtime (Node.js or Python) are available, so the installation does not break midway due to missing dependencies.
3. Installation: One Command and What Happens Behind It
Linux / macOS / terminal emulator users can run the official one-line script:
curl -fsSL <official install script URL> | bashsource ~/.bashrc # zsh users should run source ~/.zshrc instead
This command actually does four things: check the runtime version, pull the main program, install dependencies, and write the executable entry into PATH. That is why “reloading the shell config” is not an optional step; otherwise you will get a command-not-found message.
Windows users need two steps. First, open PowerShell as administrator and install the Linux subsystem:
wsl --install
After rebooting and setting a username and password as prompted, enter the Linux subsystem and run the one-line script above. Note that the file system inside the subsystem and the Windows drive letters are two separate path spaces; it is better to keep the project directory on the Linux side, since cross-system reads and writes noticeably slow down file operations.
After installation, run a self-check first:
hermes --versionhermes doctor
The purpose of a doctor-style subcommand is to check the runtime, dependencies, config files, and network connectivity item by item. When troubleshooting, look at its output first.
4. Configuring the Model: Wiring Up the Agent’s “Brain”
Initializing the configuration usually has two approaches: an interactive wizard or editing the config file directly. The wizard suits beginners better, while the config file is better for version control.
model:provider: openai_compatiblebase_url: "https://<your compatible gateway URL>/v1"api_key: "${LLM_API_KEY}"context_window: 65536tools: trueagent:max_steps: 12memory: enabledskills_autoload: true
A few common pitfalls:
- Do not hardcode the key into the config file; inject it via environment variables and commit the config file itself to a private repository;
context_windowmust match the real model. Setting it too high will not raise an error, but the conversation will be silently truncated in long sessions;max_stepscontrols the maximum reasoning steps for a single task. Too small causes complex tasks to exit halfway; too large wastes tokens;- If you use a compatible gateway to unify multiple models, make sure it passes through the tool-calling fields; otherwise it shows up as “the model only chats and never acts.”
5. Connecting Personal WeChat: Moving the Entry Point to Your Phone
Personal WeChat has no third-party open messaging API, so this kind of integration generally follows a “logged-in client + local protocol adaptation layer” approach: the adapter maintains a persistent session connection, converts incoming messages into events the agent can recognize, and pushes replies back. The flow can be summarized as:
- Start the adapter module to generate a login QR code;
- Scan it with the phone to confirm, with credentials stored locally;
- Declare a whitelist of sessions allowed to interact in the config;
- Restart the main program and send a test message to verify the loop.
Example config:
channels:wechat:enabled: truemode: personalallowed_users: ["<your session identifier>"]rate_limit: 20 # max messages per minute
The risk boundary must be stressed: unofficial protocols carry the possibility of the account being restricted by risk controls, so it is advisable to use a secondary or backup account, disable unrelated permissions, and set the whitelist strictly. Once the channel is exposed, you are effectively opening a machine that can execute terminal commands to the outside. For production scenarios, the safer approach is to switch the entry point to an enterprise messaging platform or a self-hosted webhook, and keep the personal channel only when you need it.
6. Making It Actually Work: Tools, Scheduled Tasks, and Skill Accumulation
Once configured, the capability ceiling depends on the toolset you mount. A common combination is terminal execution, file read/write, web search, database queries, and external tool services connected through open protocols such as MCP. The permission principle is least privilege by default: open only necessary directories, require confirmation before write operations, and blacklist deletion commands outright.
Scheduled tasks turn the agent from passive responder into proactive patroller:
cron:- name: daily-reportschedule: "0 9 * * *"prompt: "Summarize yesterday's repository changes and alerts, and send me a brief report"
Skill accumulation is where the long-term value of this architecture lies. After a task ends, the agent writes the successful path into a skill record with trigger conditions; you can view, edit, or delete these records at any time, calibrating “the experience it summarized itself” into working standards you approve of.
7. Hardening Checklist Before Going Live
- Have a process manager supervise the resident process, with auto-restart on crash and log rotation configured;
- Feed logs into a centralized logging service, with alerts on error rate and response latency;
- Deliver keys uniformly through environment variables or a secret management service, and rotate them regularly;
- Create a separate low-privilege system user for the agent, and forbid running as root;
- Back up the skill library and config files to object storage regularly.
8. Summary
From a single install command to model integration, channel setup, tool authorization, and scheduled dispatch, the hard part of building a self-evolving personal agent has never been the installation, but the boundary design: how much permission to grant, who is allowed to trigger it, and how to fall back when something goes wrong. Once those three things are clear, what you get is not just a chatbot, but a resident assistant that genuinely shares your repetitive work. To reduce operational overhead, you can also move the resident part to a cloud container platform, with monitoring, alerting, and log services managed for you, keeping only the message entry point locally.
