Flagship capability: MemoryAgent · Track 1 — Qwen Cloud Hackathon
Most AI agents are built to answer questions, not to preserve useful experience. That creates a familiar tradeoff: either the system forgets too much between sessions, or it holds onto too much and becomes noisy, expensive, and hard to reason about.
BonsaiCore is designed around a different assumption: memory should be a first-class system, not an afterthought. It gives agentic applications a structured way to store context, consolidate repeated signals, and prune what no longer matters.
BonsaiCore is the broader framework. MemoryAgent is the first flagship module that demonstrates how the architecture works in practice.
The platform is organized around three core ideas:
- MCP as the control plane for memory operations.
- A memo-based memory architecture for organizing short-term, episodic, and semantic knowledge.
- Intentional forgetting so long-lived context stays efficient and relevant.
MemoryAgent is BonsaiCore’s first implementation of persistent memory. It shows how an agent can move beyond raw chat history and instead operate over structured memory that evolves over time.
The memory model behaves like a bonsai tree:
- Leaves hold the current conversational context.
- Branches store episodic memos with metadata and reinforcement signals.
- Roots preserve stable facts and user preferences for durable recall.
Repeated signals are reinforced and consolidated. Low-value context decays and is pruned. The result is memory that is selective rather than cumulative.
The Model Context Protocol layer is the orchestration boundary between the agent and its memory systems. The agent does not query storage directly; instead, it calls MCP tools that keep retrieval, consolidation, and pruning consistent and inspectable.
| Tool | Purpose |
|---|---|
store_memory(payload) |
Persist a new memo or semantic fact. |
query_memory(query, filters) |
Retrieve only the most relevant context. |
consolidate_memory() |
Promote reinforced episodic memos into semantic memory. |
decay_memory() |
Prune stale memory that no longer earns its place. |
This is what makes the system feel architectural instead of ad hoc: the memory layer is explicit, modular, and easy to evolve.
BonsaiCore uses Qwen Cloud for inference, a custom MCP server for memory orchestration, and a hybrid storage backend for episodic and semantic state.
| Layer | Responsibility | Backing |
|---|---|---|
| Application | User-facing agent experience | MemoryAgent UI |
| Control plane | Memory orchestration and tool routing | MCP server |
| Episodic store | Recent interactions and memo metadata | Vector store |
| Semantic store | Stable facts and user preferences | Graph / relational store |
| Inference | Tool-calling LLM execution | Qwen Cloud |
⚡ Fast local boot: Start the MCP server with an in-memory mock for evaluation:
pip install -r requirements.txt && MOCK_DB=true python src/mcp_server/main.py- Agent inference: Qwen Cloud with tool calling.
- Memory protocol: Custom MCP server.
- Storage: Hybrid vector + graph / relational backend.
- Deployment: Alibaba Cloud, with proof and configs in
deploy/. - UI: A real-time “Memory Bonsai” visualization of growth, consolidation, and pruning.
src/mcp_server/ MCP server implementation and memory tool logic
src/memory/ Database adapters and decay algorithms
src/ui/ Memory Bonsai visualization
deploy/ Deployment scripts, configs, and proof-of-deployment artifacts
# Install dependencies
pip install -r requirements.txt
# or
npm install
# Configure environment
export DASHSCOPE_API_KEY=your_qwen_api_key
export DATABASE_URL=postgresql://user:pass@host:5432/bonsaicore
# Run database migrations
alembic upgrade head
# Start the MCP server
python src/mcp_server/main.py
# Verify the service
curl http://localhost:8000/health
curl -X POST http://localhost:8000/mcp/tools -H "Content-Type: application/json" -d '{"method":"tools/list"}'- Baseline amnesia: Show a standard agent failing to recall prior preferences across sessions.
- Memory growth: Run a few themed sessions, such as coding and journaling, and watch the UI grow new branches and roots.
- Smart recall and pruning: Demonstrate a nuanced recall from deep memory while stale, low-reinforcement memos are actively pruned.
- Qwen Cloud inference: Verified integration via DashScope SDK in
src/config/qwen_client.py. - Alibaba Cloud infrastructure: Deployment footprints, VPC configuration, and runtime documentation are in
deploy/alibaba_cloud.md. - Open source readiness: Released under the permissive MIT License for public submission eligibility.
- No hardcoded secrets; use environment variables or Alibaba Cloud KMS.
- Database access stays inside the VPC.
- RAM roles follow least-privilege access.
- API Gateway is restricted to approved frontend origins.
Contributions are especially welcome in these areas:
- MCP tool design and extensibility.
- Memory scoring, decay, and consolidation.
- Visualization improvements.
- Deployment hardening and observability.
This project is licensed under the MIT License — see the LICENSE file for the full legal text.
BonsaiCore is completely open-source and permissible for community extension, modifications, and commercial usage. This explicit licensing ensures full compliance with the open-source eligibility requirements for the Global AI Hackathon Series with Qwen Cloud.
BonsaiCore is the framework. MemoryAgent is the first flagship capability.