{"slug": "self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory", "title": "Self-hosting an AI agent environment with OpenCode and shared memory", "summary": "A developer documented a self-hosted AI agent environment built on OpenCode with a shared memory layout stored in Dropbox, using a global AGENTS.md (and CLAUDE.md for Claude Code) to make multiple harnesses read and update the same notes across machines. The setup requires manual confirmation for every memory write to limit sync conflicts and token spend, and the author reports it covered roughly 80% of local cross-machine work. The author rejected existing open-source agent platforms such as OpenClaw, Agent Zero and Hermes Agent to keep control of the security model — what agents can access, where they execute commands, and which actions need approval.", "body_md": "I planned this article on my phone during a train ride to Milan. Back home, I typed one word and it went live. Here's the setup behind it, starting with a little context.\n\nToday's frontier models are widely available through APIs, and a common way to use them is through a harness on your own computer, such as Claude Code or OpenCode. The harness lets an AI agent interact with local files, make changes and produce output.\n\nAn individual model invocation is stateless: to build on a previous discussion, it needs the relevant context made available to it. The harness or provider's API manages that context, which can include conversation history, summaries and selected information. Many agent systems also use persistent memory: usually notes on important facts and decisions that carry across conversations and projects.\n\n###### Shared memory first\n\nThat idea intrigued me. My own setup is spread thin: subscriptions with several providers, chats on the web, local sessions on different machines, and project work scattered across all of them.\n\n  The first problem was consolidating memory across machines and harnesses. I defined a few basic rules for a memory\n  layout in a shared folder (Dropbox in my case, but Google Drive would work just as well). Each harness is instructed\n  to read and update the relevant notes via a custom instruction in a global `AGENTS.md`, with the equivalent\n  in `CLAUDE.md` for Claude Code.\n\nThe layout itself is simple:\n\n```\n~/dropbox/memory/\n├── MEMORY.md            # rules, conventions, links to notes\n├── <note>.md            # detailed note on a concept\n└── projects/\n    └── <project>/\n        ├── MEMORY.md    # same as above with short summaries for smaller models\n        └── <note>.md    # detailed note on a concept\n```\n\nOne of the rules is that anything written to memory needs a manual confirmation. This keeps sync conflicts down and the memory lean: even with today's large context windows, every token spent on memory is one less for the actual work. It also matters for security, since anything written to memory syncs to every machine and harness that reads it.\n\nFor local work across machines, this alone got me roughly 80% of the way there, a figure measured with exactly the rigour you'd expect.\n\n###### An always-on environment\n\nThe next problem was moving between web chats and local work. If I started a discussion in a provider's web chat while on a train, I had to re-establish the context once I switched to a local harness, because those chats live outside my shared memory. So I looked into self-hosting an agent environment that would give me:\n\n- **Shared memory** across sessions and projects.\n- **Always-on access** for discussing work.\n- **Continuity across machines** , so I could continue a discussion and get work done wherever I was.\n- **Model freedom** , without being locked to a proprietary provider.\n- **Harness freedom** , without being beholden to a proprietary UI. Shared memory already makes this less of a\n    concern.\n\n###### Why not an existing platform?\n\n  These requirements rule out proprietary agent platforms, but there are several viable open-source options. [OpenClaw](https://github.com/openclaw/openclaw), [Agent\n    Zero](https://github.com/agent0ai/agent-zero) and [Hermes Agent](https://github.com/NousResearch/hermes-agent) all support general-purpose\n  agents, persistent memory and background work. One of them would probably have fit the bill, but I had two additional\n  considerations.\n\nFirst, I already had a working memory layout shared across multiple harnesses. I wanted something that would sit on top of that foundation, rather than adapting the foundation to a new platform.\n\n  Second, I wanted the freedom to extend the setup in whichever direction I chose. **I want to own the security\n    model:** what agents can access, where they can execute commands, how they are isolated and which actions require\n  my approval.\n\nA pre-built solution can be customised, of course, but I wanted to draw those boundaries from day one. Choosing and connecting the building blocks seemed more straightforward than reshaping a packaged system around my own security model.\n\n###### The setup\n\nFor me, an agent environment brings together an existing harness, shared memory, remote access and the boundaries within which the agent can work. Mine turned out to be simple:\n\n- OpenCode on a VPS, with models via OpenRouter and an OpenAI subscription.\n- My existing shared memory, synced to the VPS by the headless Dropbox client on a fixed schedule.\n- OpenCode's built-in web UI, which replaces provider web chats for me.\n- Private access through Tailscale.\n\nThe boundaries are where my security model lives:\n\n- An Ubuntu VPS with a non-sudo account running OpenCode.\n- No egress to other machines on the Tailscale network.\n- Writes limited to working directories; read access elsewhere.\n- No credentials beyond the model providers (the OpenRouter key has a usage limit) and Dropbox, which runs under a separate account and only syncs the memory folder.\n- Shared memory backed by Dropbox file versioning and regular backups.\n\n###### Ninety minutes and one leap of faith\n\nI had been exploring the idea for a few days, but the implementation took 90 minutes in total. Opus 5.5 designed and implemented the solution, and I spent most of that time insisting it give me instructions to run by hand. At roughly the 80% mark (that number again), with Tailscale and OpenCode working, I let go and asked it to SSH into the box and finish the job. Yes, I'm aware of the irony after all that talk about security models, but there were no credentials on the box anyway.\n\n###### Dogfooding the agent\n\nI came up with the idea for this article and started the discussion through the web UI. This blog runs on a custom Node.js setup, and my shared memory already had notes covering its content and style, so the agent could pick up the existing context straight away.\n\nI provided the initial text, discussed the research and structure with the agent, and worked out a plan for implementing and publishing it, which went into the blog's notes. All of this happened on my phone, on a train to Milan.\n\n  When I got back home, I opened a fresh Claude Code session in my blog project and typed `please continue`.\n  Based on my shared memory, it presented an implementation and a deployment plan. The next word I typed was\n  `go`. Five minutes later, the article was live. As a counterpoint, preparing and refining the text took\n  over two hours, which says more about me than about the setup.\n\nThat is exactly the continuity I wanted: discuss and plan the work wherever I happen to be, then pick it up on another machine. It's also my harness-freedom requirement proven in practice: the planning happened in OpenCode, the implementation in Claude Code, and shared memory was the common ground for both.\n\nIt's been working well so far, and I'd recommend giving something similar a shot. Use the building blocks in this article as a starting point to explore your own requirements and put together a setup that fits. Any frontier model can help you do the research and set it up.\n\nNow that I have one remote agent, I'm going to look at adding more for background work and other interesting tasks. The goal is to build my own vicbot ;)", "url": "https://wpnews.pro/news/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory", "canonical_source": "https://smalldata.tech/blog/2026/10/11/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory", "published_at": "2026-10-11 16:25:46+00:00", "updated_at": "2026-10-11 17:00:43.525110+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["OpenCode", "Claude Code", "Dropbox", "Google Drive", "OpenClaw", "Agent Zero", "Hermes Agent", "Nous Research"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory", "markdown": "https://wpnews.pro/news/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory.md", "text": "https://wpnews.pro/news/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory.txt", "jsonld": "https://wpnews.pro/news/self-hosting-an-ai-agent-environment-with-opencode-and-shared-memory.jsonld"}}