Off-the-shelf AI assistants reply particular person questions properly, however they fall brief on a special axis: continuity. Ask a stateless assistant about your backyard right this moment and it has no thought that you simply talked about your fast-draining raised beds three weeks in the past, that you simply solely use natural fertilizer, or that your petunias have been struggling by means of a warmth wave. Each dialog begins from zero, and the burden of re-explaining context falls on the person.
The issue isn’t the standard of the solutions, however that the assistant has no reminiscence of you. This put up reveals the way to construct a private assistant that accumulates context utilizing OpenClaw, an open supply agentic system, working on AgentCore runtime, a functionality of Amazon Bedrock AgentCore. AgentCore reminiscence, a functionality of Amazon Bedrock AgentCore, turns disposable chats into sturdy information. Additionally, you will see the way to tag these recollections with structured metadata to retrieve data that matter for the query at hand.
Our working instance is Sprout, a gardening assistant, however the structure is domain-agnostic. Swap the persona and the abilities manifest, and the identical pipeline serves a help bot, a health coach, or an inside assist desk. All the system lives in a single AWS CloudFormation template, deploys with one command, and runs on a consumption-based mannequin that prices just a few {dollars} a month for gentle private use. Alongside the best way, we share design pointers you possibly can apply to assistants you construct on this stack.
Resolution overview
AgentCore is a platform to construct, join, and optimize brokers at scale, with any framework or mannequin. The next diagram reveals the end-to-end request circulate, from an inbound Telegram webhook by means of the AgentCore runtime, and its supporting AWS providers.
Determine 1: Telegram webhooks and Amazon EventBridge schedules each invoke the identical AgentCore runtime agent, which coordinates the OpenClaw gateway, AgentCore reminiscence, and Amazon Bedrock
Two entry factors converge on one agent. Telegram messages arrive by means of Amazon API Gateway and a webhook AWS Lambda operate, whereas scheduled jobs equivalent to morning watering reminders arrive by means of Amazon EventBridge Scheduler and a cronjob Lambda operate. Each name the InvokeAgentRuntime API on the AgentCore runtime, the place a skinny server.py course of coordinates the OpenClaw gateway, AgentCore reminiscence, and the Amazon Bedrock Converse API. Amazon Easy Storage Service (Amazon S3) supplies workspace storage, AWS Key Administration Service (AWS KMS) handles encryption, AWS Secrets and techniques Supervisor holds the bot token, and Amazon CloudWatch captures logs and metrics.
Conditions
To deploy your personal model utilizing the Launch Stack button or scripts/deploy.sh (described within the Develop your personal part), you will have:
- Amazon Bedrock AgentCore entry, together with AgentCore runtime and AgentCore reminiscence.
- Mannequin entry granted for the fashions you intend to path to: Claude Haiku 4.5 for textual content and Claude Sonnet 4.5 for imaginative and prescient (or the equivalents out there in your account).
- Docker with
linux/arm64construct help, plus the AWS Command Line Interface (AWS CLI) configured. That is wanted provided that you intend to construct and push your personal picture. - A Telegram bot token (from BotFather) to function the assistant’s entrance door.
- Fundamental familiarity with agent orchestration ideas and CloudFormation.
The structure: A serverless agent on AgentCore runtime
Each part lives in a single CloudFormation template, and no construct tooling is required to launch. The next sections stroll by means of the load-bearing choices.
AgentCore runtime: Pay just for lively compute
The agent lives in a container on AgentCore runtime, which makes use of consumption-based pricing. You’re billed for the compute your agent actively consumes, not for wall-clock uptime, and also you don’t pay for the time when ready for I/O equivalent to mannequin response. For a private assistant utilized in brief bursts, that’s the distinction between an roughly $1–2/month baseline and an roughly $35/month always-on Amazon Elastic Compute Cloud (Amazon EC2) occasion. These figures are estimates for gentle private use as of July 2026. Consult with AgentCore pricing for present charges.
The runtime enforces a minimal container contract: pay attention on port 8080, and expose GET /ping for well being and POST /invocations because the agent entry level. Our container is linux/arm64, constructed multi-stage from the official OpenClaw picture plus a Python layer.
OpenClaw because the agent substrate
OpenClaw supplies the agent loop, instrument use, and a expertise system. It runs a wrapper (server.py) that adapts it to AgentCore HTTP protocol contract:
- On container begin,
server.pylaunchesopenclaw gateway runas a subprocess and health-checks it. GET /pingreturns wholesome shortly, so the AgentCore readiness probe passes.POST /invocationsdoes the actual work: parse the payload, retrieve reminiscence, assemble context, ahead the flip to the gateway, and persist the outcome. One callout: AgentCore can thaw a frozen container whose subprocess has exited. So invocation path doesn’t assume the gateway is alive, it calls anensure_openclaw_ready()helper that re-checks well being (and restarts the gateway if wanted) earlier than forwarding the flip.
This wrapper sample generalizes to different use instances. Any agent framework that runs as an area course of may be tailored to the AgentCore runtime the identical method, with out modifying the framework itself.
Two fashions, routed by process
Textual content chat and picture understanding have totally different price and high quality tradeoffs, so the assistant routes them to totally different Claude fashions on Bedrock:
- Claude Haiku 4.5 for textual content: Quick and low cost for the high-volume conversational turns that dominate day by day use.
- Claude Sonnet 4.5 for imaginative and prescient: Stronger multimodal reasoning for the much less frequent however tougher process of diagnosing a plant from a photograph.
Textual content turns circulate by means of the OpenClaw gateway, which brings expertise and session state. Picture turns name the massive language mannequin (LLM) from Bedrock instantly from server.py, passing the picture bytes as multimodal content material blocks. We route photos across the gateway intentionally: the in-container OpenClaw construct dropped the image_url content material elements earlier than they reached Bedrock, so calling the Converse API instantly from server.py makes certain the mannequin sees the precise pixels. Each paths share the identical system immediate (persona plus reminiscence), so the expertise stays constant.
The mannequin IDs are surroundings variables (MODEL_ID, VISION_MODEL_ID), so you possibly can swap fashions per deployment with out rebuilding the picture.
Abilities because the reusable functionality unit
Capabilities are declared as expertise in a community-skills.json manifest. A deploy-time script materializes them into the container and registers them within the OpenClaw config earlier than the picture is constructed. Sprout ships with climate, reminders, and plant notes expertise on the time of publishing this put up. Swap the manifest and the identical pipeline serves a special area. That is what makes the entire thing a reusable sample and never just one bot.
Telegram because the serverless entrance door
Telegram is a sensible channel for a private assistant because it’s webhook-based, and it retains all the pieces serverless. It requires no shopper growth, works on each gadget the person already owns, and helps textual content, photos, and wealthy formatting by means of an easy bot API. BotFather points a bot token, which is saved in Secrets and techniques Supervisor. The deployment registers a webhook that factors Telegram on the API gateway endpoint. When the person sends a message, Telegram delivers it to the webhook Lambda operate to validate the payload and name InvokeAgentRuntime. The reply travels again by means of the telegram bot API.
One formatting lesson to notice: Telegram’s legacy markdown mannequin is unforgiving about unescaped characters and a single stray underscore in a mannequin response could make the entire message fail to ship. Rendering replies as HTML is dependable so the assistant converts mannequin output to Telegram-safe HTML earlier than sending.
Reminiscence: Turning disposable chats into sturdy information
The structure described to date is a succesful, low cost, serverless agent, however by itself it nonetheless forgets you between conversations. Reminiscence is what adjustments that. Think about mentioning weeks in the past that you simply backyard organically, and right this moment the assistant recommends a therapy and provides, by itself, that it picked the natural choice since you don’t use artificial fertilizer. A stateless mannequin can’t try this.
AgentCore reminiscence has two layers. Brief-term reminiscence shops each dialog flip as an occasion by means of CreateEvent, keyed by actorId (the Telegram chat ID) and sessionId. That is the uncooked transcript. Lengthy-term reminiscence is produced asynchronously by managed extraction methods into sturdy, structured data. We configured three methods:
USER_PREFERENCE: express selections the gardener acknowledged (“I solely use natural fertilizer”).SEMANTIC: inferred details (“grows Mexican petunias in a Corten metal raised mattress”).SUMMARIZATION: episodic session summaries (“mentioned yellowing decrease leaves throughout a warmth wave”).
Namespaces: One backyard per gardener
Sprout information data into per-user namespaces, so no two chats ever combine:
sprout/{chat_id}/long_term: preferences and semantic details.sprout/{chat_id}/episodic/{session_id}: session summaries.
The chat ID is the one variable section, which makes isolation easy to cause about and to check: every distinctive gardener maps to precisely one namespace, and no two gardeners collide.
The retrieval, meeting, and injection pipeline
On each flip, the agent retrieves the related long-term data, ranks them, and injects them into the system immediate. Here’s what occurs on each single message, inside server.py:
- Retrieve. Name
RetrieveMemoryRecordsin opposition tosprout/{chat_id}/long_term, utilizing the person’s message because the search question, capped at 50 outcomes, below a 3-second funds. If retrieval instances out or errors, we degrade gracefully and reply with out reminiscence relatively than failing.
Snippet 1: Retrieving long-term data for the present flip (consultant. See the repo for full supply).
Assemble operate provides extra customized logic. We would like the specific preferences to rank forward of inferred details, order is steady inside every class, and the result’s capped earlier than injection:
Snippet 2: The meeting step ranks express preferences earlier than inferred details.
Metadata: Subgrouping recollections inside a namespace
Namespaces reply whose reminiscence a report is, however metadata solutions what it’s about. Inside sprout/{chat_id}/long_term, a semantic seek for “my petunias are wilting”, would return all the pieces that’s shut in which means. For a gardener, meaning a fertilizer desire from March, and a fig tree pruning be aware are ranked alongside data that really matter. And structured metadata helps us slim down the scope of recollections earlier than it reaches the immediate.
One rule shapes each determination right here. A metadata key’s solely filterable server-side if you happen to declare it as an listed key. You may learn extra in Structured reminiscence filtering with metadata in Amazon Bedrock AgentCore Reminiscence. On this case, sprout makes use of three listed keys:
Every entry names a key, which should match an listed key to be filterable, and units extractionType to both STRICTLY_CONSISTENT, handed by means of from the occasion, or LLM_INFERRED, extracted from the dialog. For inferred keys, an extraction configuration can limit values to a set checklist. Sprout does that precisely, so each write paths would create the identical vocabulary and a filter means the identical factor no matter which half created the report.
Persisting the flip and shutting the loop
After the mannequin responds, server.py calls CreateEvent with each the person flip and the assistant flip. That new occasion feeds the extraction methods, which enrich the long-term retailer for subsequent time.
Snippet 3: Persisting the flip so the extraction methods can enrich long-term reminiscence asynchronously.
Extraction is asynchronous, so a reality talked about on this session usually turns into retrievable in a later one. Design for that delay: short-term session occasions cowl the present dialog, and long-term data cowl all the pieces earlier than it.
Placing it collectively: A personalised watering plan
Right here is the place the complete pipeline works end-to-end. Over just a few conversations you catalog your entire backyard, one plant at a time, in plain language. Every point out turns into an occasion. The extraction methods extract details about the plant, its location, and its solar publicity into sprout/{chat_id}/long_term. This morning the person asks a query, “Do you keep in mind the opposite crops in my backyard?” Retrieval pulls the data again, meeting ranks them, and so they trip into the system immediate. The assistant solutions with the person’s location, solar publicity, mattress development, soil conduct, and plant stock, none of which appeared within the message itself.
Determine 2: Sprout solutions a query concerning the backyard by recalling the saved plant stock and rising circumstances
Utilizing the scheduler talent on the Amazon EventBridge → Cron path, Sprout also can flip that plan into proactive reminders (“skip the herbs, the soil continues to be damp from yesterday”) and adjusts them in opposition to the climate talent when rain or a warmth wave is coming.
Reminiscence and imaginative and prescient additionally compound one another. When the person sends a photograph of a wilting plant, the picture goes to Claude Sonnet 4.5 whereas the system immediate nonetheless carries all the pieces the reminiscence layer is aware of. The assistant matches the photograph to the Mexican petunias already within the person’s saved stock and diagnoses wilt stress in context relatively than analyzing an nameless plant photograph chilly.
Determine 3: Imaginative and prescient and reminiscence working collectively. The photograph goes to the imaginative and prescient mannequin whereas the system immediate carries the person’s saved backyard context
Imaginative and prescient fashions aren’t infallible. In an earlier alternate with out the stock context, the identical plant was confidently recognized as a morning glory, a species with related trumpet-shaped purple flowers. Grounding the imaginative and prescient mannequin with the person’s personal saved stock is what turned a plausible-sounding guess into an accurate, personalised prognosis, and it’s a good illustration of why reminiscence improves accuracy and never solely tone.
Conserving inference prices low with immediate caching
Injecting reminiscence into each flip makes the system immediate giant, and a naive implementation would pay for these tokens on each request. Immediate caching on Amazon Bedrock addresses this. The assistant constructions its immediate in order that the steady prefix, the persona and the assembled reminiscence block, comes first and the risky person message comes final. Bedrock caches the processed prefix throughout requests, so repeated turns inside a dialog skip recompute of the unchanged portion. Immediate caching can cut back prices by as much as 90 % and latency by as much as 85 % for supported fashions.
The ordering rule issues greater than any single setting: put steady content material first, risky content material final, and hold the reminiscence block’s inside ordering deterministic (which the previous meeting operate facilitates) so the prefix truly matches between requests.
Design pointers to construct on AgentCore and OpenClaw
Sprout is one assistant, however the choices behind it generalize. For those who’re constructing your personal assistant on this stack, the next pointers are those we might carry to any area.
- Wrap, don’t fork. Adapt your agent framework to the AgentCore container contract with a skinny HTTP wrapper relatively than modifying the framework. The contract is small, port 8080 with
/pingand/invocations, and a wrapper retains you on the framework’s improve path. - Design namespaces earlier than you retailer something. Reminiscence namespaces are your isolation boundary. Make the person ID the one variable section, and select it from a channel-native ID you already belief, such because the chat ID. Multi-tenant designs get audits and deletion requests finally. A clear namespace scheme makes each trivial.
- Deal with reminiscence as an enhancement, by no means a dependency. Each reminiscence operation ought to be allowed to fail gracefully. Retrieval failures ought to produce a memoryless reply with out blocking the reply. Customers forgive a forgetful flip much more readily than a failed one.
- Route fashions by process. Use a quick, cost-effective mannequin for high-volume textual content and reserve a stronger multimodal mannequin for the turns that want it. Preserve mannequin IDs in surroundings variables so routing adjustments are configuration, not code.
- Order prompts for the cache. Steady persona and reminiscence first, risky person enter final, deterministic ordering all through. This one structural behavior is the place a lot of the inference financial savings come from.
- Plan for extraction latency. Lengthy-term reminiscence is extracted asynchronously, so don’t promise same-session recall of latest details. Let short-term session occasions cowl the present dialog and long-term data cowl prior ones.
- Put a funds on it from day one. A consumption-based agent is cheap till a retry loop or a chatty person makes it in any other case. An AWS Budgets alert at 80 % and one hundred pc of a month-to-month cap prices nothing and catches surprises early.
- Preserve expertise small and single-purpose. A talent ought to do one factor a person would identify in a sentence, equivalent to examine the climate or set a reminder. Small expertise are independently testable, independently swappable, and simple for the mannequin to pick appropriately. A do-everything talent forces the mannequin to guess which of its behaviors you meant.
Develop your personal
Two methods to plant it, similar backyard:
- Single-step Launch Stack: the CloudFormation template factors at a public Amazon Elastic Container Registry (Amazon ECR) picture, so it deploys nothing however a Telegram bot token.
- Construct your personal: The scripts/
deploy.shscript validates the template, builds and pushes your personal ARM64 picture to your non-public Amazon ECR repository, deploys the stack, and registers the Telegram webhook, for a totally customizable construct.
Gentle private use runs about $5–9/month as of July 2026 (roughly $2 infrastructure, $1–3 Haiku textual content, $2 Sonnet imaginative and prescient), with a built-in AWS Price range that alerts at 80 % and one hundred pc of a cap you set.
The total supply code is on the market within the sample-agentcore-memory-openclaw GitHub repository.
Clear up
If you find yourself achieved experimenting, tear all the pieces right down to keep away from ongoing costs. As a result of the entire system is one CloudFormation stack, cleanup is generally a single delete:
- Delete the CloudFormation stack. This removes the AgentCore runtime agent, API Gateway, the Lambda features, the Amazon EventBridge schedule, and the related AWS Id and Entry Administration (IAM) roles.
- Delete the AgentCore reminiscence retailer (and its namespaces) so no person data are retained.
- Delete any photos you pushed to your non-public ECR repository, and the repository itself if it’s now not wanted.
- Take away the AWS Price range alert if you happen to created one exterior the stack.
- Revoke Telegram’s webhook (or delete the bot by means of BotFather), and revoke Bedrock mannequin entry if you happen to now not want it.
Conclusion
The reusable core of this answer is a serverless agent on Amazon Bedrock AgentCore with a expertise system and managed reminiscence. AgentCore reminiscence removes the necessity to construct customized vector shops and extraction pipelines whereas leaving you full management over what the agent remembers and forgets, consumption-based compute plus immediate caching retains a genuinely personalised assistant at just a few {dollars} a month, and the OpenClaw expertise manifest makes the entire sample transportable throughout domains. Personalization additionally compounds: the extra a person interacts, the extra helpful the assistant turns into.
To go additional, begin with a single area equivalent to watering reminders and develop reminiscence scope incrementally, discover episodic reminiscence so the agent can reference particular previous conversations (“final time we mentioned the fig tree, you determined to carry off on fertilizer”), or fork the repository, swap in your personal persona and expertise, and develop no matter assistant you want.
To study extra, confer with the AgentCore documentation. The next associated posts cowl the constructing blocks in additional depth:
In regards to the authors

