Pular para o conteúdo
← Back to Skalablog

Published article

OpenClaw tutorial: 4 files that shape your agent

Software EngineeringAnthropicOpenAI

This OpenClaw tutorial explains how to deploy a self-hosted AI agent that keeps structured memory files, runs scheduled tasks, and reaches you on Telegram. You install it on a cloud VPS with a one-click template, bring your own model API key, and connect Google Workspace through OAuth, without writing code at the command line.

OpenClaw Tutorial: What You Deploy and What Stays Yours

This OpenClaw tutorial walks through deploying a self-hosted personal AI agent on a cloud VPS, connecting it to Telegram and Google Workspace, and scheduling recurring tasks. The agent is open source and ships without a built-in model, so you supply API keys from a provider such as Anthropic OpenAI, and you pay that provider directly.

The workflow in the source video, published in May 2026, runs from planning questions to a working flight-price monitor in about an hour. The pieces worth understanding before you start are the four workspace files, the scheduling primitives, and the credential handling. Those decide whether the agent feels useful or becomes an expensive background process.

Start from the canonical project documentation at docs.openclaw.ai rather than a video timestamp. Version numbers, model names, and template screens in any walkthrough go stale faster than the concepts do.

The Three Capabilities That Separate It From a Chatbot

OpenClaw differs from a hosted chatbot in three ways: it keeps structured memory in editable files, it runs on a schedule without being prompted, and it takes actions in connected apps such as Gmail and Google Calendar. A chatbot answers questions; this agent performs work and reports back.

The memory difference is concrete rather than philosophical. Hosted assistants keep a compressed summary of past chats that you cannot inspect or correct. OpenClaw writes plain files such as user.md and memory.md inside the workspace, and you can ask the agent to update them or edit them yourself in the dashboard.

What memory files look like in practice

The four files named in the walkthrough are agents.md, soul.md, user.md, and memory.md. agents.md holds behavioural rules, soul.md holds persona and tone, user.md accumulates facts about you, and memory.md logs interactions before a compression pass rewrites it.

Updates happen conversationally. Telling the agent to add a quiet-hours rule writes that rule into agents.md, and the dashboard shows the change after a refresh. Nothing in that loop requires terminal access.

Choosing Where to Run the Agent: Laptop, Hardware, or VPS

A cloud VPS is the recommended starting point because the agent stays reachable while your laptop is closed, and a rebuild from scratch costs one redeploy rather than a reinstall. Local hardware is a legitimate long-term home, but it inherits your home power and network.

The trade-offs are worth stating plainly, because the hosting choice drives both uptime and your exposure surface.

HostUptimeUpfront costIsolation
Personal computerOnly while the machine is onNoneAgent can reach every local file
Dedicated hardware (Mac Mini, Raspberry Pi, spare laptop)Depends on home power and internetSeveral hundred dollarsSandboxed from your main machine
Cloud VPSAlways onA few dollars per monthSeparate from personal files, easy to wipe

The isolation argument is the one people underestimate. An agent with OAuth access to Gmail and Calendar is a credential holder, and a compromised or misconfigured credential holder on your daily machine reaches everything you have saved locally.

The Four Core Workspace Files and How to Shape Them

Four files drive most of the agent's behaviour: agents.md, soul.md, user.md, and memory.md. You shape all of them by asking the agent in chat, and the dashboard exposes an editor for manual changes.

Bootstrap writes a first draft during onboarding, and that draft is thin. A default soul.md reads something like "be helpful, not performatively helpful", which produces generic replies. Replacing it with a specific persona, tone, and set of preferences is the difference between a tool and something that feels like yours.

agents.md is the rule book, soul.md is the personality

agents.md carries operational rules: confirm destructive actions, prefer calendar over email when scheduling, do not check mail between certain hours. These are guardrails the agent applies on every task, and they are the right place to encode approval requirements.

soul.md carries voice. Asking for a travel-agent persona that is dry, direct, and cost-conscious changes reply length and framing immediately. Neither file requires manual editing, though the dashboard will let you do it.

user.md and memory.md grow on their own

user.md holds durable facts about you and grows as conversations reveal them. memory.md is the interaction log, written automatically, and it becomes the input to the compression process described later.

Connecting Telegram and Google Workspace Safely

Telegram pairing gives you a phone interface to the agent, and Google Workspace access is granted through OAuth so the agent never sees your password. Both connections are one-time setups, and both create credentials you should treat as secrets.

The Telegram side starts with BotFather, Telegram's official bot-creation account, which issues a bot token and a username ending in "bot". The token goes into the hosting panel's environment variables, never into a chat log. The agent then replies with a pairing code you paste back into the dashboard.

Google access follows the standard OAuth shape described in Google's OAuth 2.0 documentation. You create a project in Google Cloud Console, enable the individual APIs you want, configure an OAuth consent screen, add yourself as a test user, and create a desktop-app client. The walkthrough author reports this step takes roughly 10 to 15 minutes, and it is the most tedious part of the build.

One detail in the video deserves correction: during the consent flow the agent returns a localhost redirect URL that fails to load in the browser. That failure is expected. You copy the full URL from the address bar and paste it back into the chat to complete the exchange.

Scheduling: Cron Versus Heartbeat and the Cost Difference

Use cron for scheduled tasks and reserve heartbeat for work that genuinely needs continuous checking. Cron runs a task at a fixed time, while heartbeat wakes the agent on an interval, and every heartbeat tick is a fresh paid model call.

That distinction is the single largest driver of a surprising bill. An agent checking a flight price three times a day on cron makes three calls. The same task on a five-minute heartbeat makes 288 calls per day at the same tier, for nearly identical information.

Matching model tier to task

Model routing follows a three-tier mental model: premium models for reasoning, research, and orchestration; mid-tier models for routine chat and simple tasks; cheap or open-weight models for trivial exchanges. The walkthrough recommends a rule in agents.md that defaults conversation to a mid-tier model and escalates when reasoning or tools are involved.

The reported saving from that single routing rule is a claim from the video creator, not an independent measurement. Treat the 80% figure as an illustration of direction rather than an audited number, and check your own provider dashboard for actual spend.

Reading your real usage

A workspace Usage panel shows tokens and estimated cost per session across time ranges. The walkthrough notes this panel is not exact and recommends the provider's own billing dashboard, such as the Anthropic Console, as the authoritative figure for spend.

Memory Compression, Sub-Agents, and What to Verify Yourself

Two features reduce long-run cost and wall-clock time: a background memory-compression pass, and sub-agents that research separate items in parallel. Both consume tokens to save tokens later, so both belong after you know the agent is useful to you.

Memory compression runs while you are not using the agent, rewriting accumulated logs into a smaller form and promoting durable facts into user.md. The output is a summary, not a reversible transformation: the original log entries are condensed, so treat the compressed memory as a derived record rather than a reconstructable archive.

Sub-agents, parallel work, and their limits

Asking for three tools compared in parallel spawns three sub-agent sessions that each handle one item, and the main session merges the results. Each sub-agent makes its own model calls, so parallel research multiplies token spend even as it shortens waiting time.

Vendor claims, model names, and dating

Three verification notes belong here. Model names given in the video are examples that change frequently, so confirm current tiers and pricing on the provider's own pages. The walkthrough attributes its one-click deployment and backup features to hosting infrastructure rather than to OpenClaw itself. And the migration path to local hardware is documented at docs.openclaw.ai/install, where credentials such as the Telegram bot token, Google authorization, and provider API keys must be reissued on the new machine by design.

Troubleshooting, Backups, and the Credential-Expiry Pattern

Most failures fall into three buckets: an exhausted provider balance, an expired OAuth credential, or a skill error visible in the logs. Asking the agent what an error means resolves the majority of cases before you OpenAI log file.

A silent agent that stops replying usually means a zero balance at the model provider. Topping up restores service without further configuration. If the balance is fine, check for an authentication error in a connected service, which is fixed by re-running the authorization flow for that service.

The dashboard's log view lists every action, warning, and error, and the agent can read its own logs when you ask it to investigate. For badly broken configurations, restore from a daily backup or a manual snapshot taken before major changes. This is the practical argument for paying for automated backups during your first month.

FAQ

  • Is OpenClaw free? The agent software is open source and free to run, but it ships without a built-in model. You pay a model provider such as Anthropic OpenAI for API usage, and you pay separately for whatever server hosts the agent.
  • Do I need to write code to set it up? The cloud template path covers install, configuration, and Telegram pairing through a browser and a phone. Terminal work appears only in the local-hardware migration, where documented commands copy a backup onto the new machine.
  • What is the difference between cron and heartbeat? Cron runs a task at a fixed time, such as 8:00 AM daily, and consumes one model call per run. Heartbeat wakes the agent every interval to check for changes, and each check is a separate paid call, which is why it is the usual cause of a runaway bill.
  • How much does running an agent cost per month? Hosting for a small VPS is a few dollars monthly. Model spend depends on routing: the walkthrough reports a daily cost of roughly one dollar in its own setup, and that figure scales with how many premium-tier calls you schedule.
  • Can it run on a Raspberry Pi or Mac Mini? Yes, and the documented migration path supports it. Credentials do not transfer, so the Telegram bot token, Google authorization, and provider API keys must be reissued on the new hardware.

Source video