Link copied!
Building a Context-Aware AI Assistant with AgentCore and OpenClaw Technical Log

TechiesAIE Journal

Building a Context-Aware AI Assistant with AgentCore and OpenClaw

TechiesAIE
TechiesAIE
Lead Developer · TechiesAIE
4 min read 671 words

Based on the sources linked below.

Cover image: FireEmerald · CC BY-SA 4.0 · License · Image source

Off-the-shelf AI assistants excel at answering individual questions but struggle with continuity. A user might discuss their garden's fast-draining raised beds one day, only to have the assistant forget these details the next. This context reset forces users to repeatedly explain their situation. However, a new architecture combining OpenClaw, an open-source agentic system, with Amazon Bedrock's AgentCore memory solves this problem by giving assistants persistent memory across sessions.

The Problem: Stateless Assistants

Traditional AI assistants are stateless, meaning each interaction starts from scratch. While they can provide accurate answers, they lack the ability to remember previous conversations or user preferences. This limitation creates a poor user experience, as individuals must constantly repeat information. For example, a gardening assistant would forget a user's preferred organic fertilizer or the struggling petunias mentioned weeks earlier.

The Solution: Persistent Memory with AgentCore

Amazon Bedrock's AgentCore memory introduces persistence to AI assistants. By storing conversation history and metadata, assistants can recall previous interactions and provide contextually relevant responses. When combined with OpenClaw's agent framework, this enables the creation of domain-specific assistants that accumulate knowledge over time.

Architecture Overview

The system consists of several key components, all deployed via a single AWS CloudFormation template. At its core is the AgentCore runtime, a serverless container service that hosts the assistant. This runtime integrates with OpenClaw, which provides the agent loop, tool usage, and skill system. Memory storage and retrieval are handled by AgentCore memory, while Amazon Bedrock's Converse API connects to language models for text and vision tasks.

Two entry points trigger the assistant: Telegram messages processed by a webhook Lambda function, and scheduled events from Amazon EventBridge. Both routes invoke the AgentCore runtime, which coordinates OpenClaw, memory retrieval, and model inference. Supporting services include Amazon S3 for storage, AWS KMS for encryption, and Amazon CloudWatch for monitoring.

Key Components

AgentCore Runtime

The AgentCore runtime provides a serverless execution environment for the assistant. It uses consumption-based pricing, charging only for active compute time. This model is cost-effective for personal assistants used intermittently. The runtime enforces a simple container contract, requiring a health check endpoint and an invocation handler. The container is built for linux/arm64 architecture, using a multi-stage Dockerfile that combines the OpenClaw image with a Python wrapper.

OpenClaw Agent Framework

OpenClaw serves as the agent's operational framework, managing the conversation loop, tool integration, and skills. A Python wrapper adapts OpenClaw to the AgentCore runtime's HTTP protocol. This wrapper handles container startup, health checks, and invocation requests. It ensures OpenClaw is running and restarts it if necessary before processing each request. This pattern allows any local agent framework to integrate with AgentCore without modifications.

Model Routing by Task

The assistant routes tasks to different models based on their requirements. Text conversations use Claude Haiku 4.5 for its speed and cost-efficiency, while image analysis tasks leverage Claude Sonnet 4.5 for stronger multimodal reasoning. This routing is controlled via environment variables, allowing model swaps without rebuilding the container. Images bypass the OpenClaw gateway to ensure the model receives the raw image data, while maintaining a consistent system prompt across both paths.

Skills System

Capabilities are defined as skills in a JSON manifest. A deploy-time script integrates these skills into the container, making the assistant adaptable to various domains. The example gardening assistant includes weather, reminders, and plant notes skills. By swapping the manifest, the same architecture can power assistants for different use cases, such as customer support or fitness coaching.

Deployment and Cost

The entire system deploys via a single CloudFormation template, requiring no additional build tools. Prerequisites include access to Amazon Bedrock AgentCore, compatible language models, Docker with linux/arm64 support, a Telegram bot token, and basic familiarity with agent concepts and CloudFormation. For light personal use, costs are estimated at $1-2 per month, significantly lower than traditional always-on EC2 instances.

This architecture demonstrates how combining AgentCore's memory capabilities with OpenClaw's flexibility enables the creation of context-aware AI assistants. By persisting user context and leveraging task-specific models, these assistants provide a more natural and efficient user experience across various domains.

Sources