Provides AI memory management for CrestApps.Core with session, past conversation, and durable user memory. Covers Entity Framework Core and YesSql stores, Elasticsearch/Azure AI Search/PostgreSQL backends, background indexing, and safety validation.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Three kinds of memory share one registration:
| Kind | Remembers | Switch | Covers |
|---|---|---|---|
| Session memory | the earlier part of a long conversation | MemoryMetadata.EnableSessionMemory; ChatInteractionMemoryOptions.EnableSessionMemory (default true) | the conversation itself, including anonymous visitors |
| Past conversations | the user's earlier conversations with the same profile | MemoryMetadata.EnablePastConversations | signed-in users only |
| User memory | durable facts (preferences, projects, roles) | MemoryMetadata.EnableUserMemory; ChatInteractionMemoryOptions.EnableUserMemory (default true) | signed-in users only |
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
.AddAIMemory(memory => memory
.AddEntityCoreStores())) // or .AddYesSqlStores()
.AddIndexingServices(indexing => indexing
.AddEntityCoreStores()
.AddElasticsearch(
builder.Configuration.GetSection("CrestApps:Elasticsearch"),
elasticsearch => elasticsearch.AddAIMemory()))
.AddEntityCoreSqliteDataStore("Data Source=app.db"));
builder.Services.Configure<AIMemoryOptions>(options =>
{
options.IndexProfileName = "user-memories"; // an index profile of type AIMemory
options.TopN = 5;
});
AddAIMemory(...) calls AddCoreAIMemory() and AddCoreAIMemoryIndexing(). AddCoreAIMemory() registers IAIMemorySafetyService, IAIMemorySearchService, ITextTokenizer, AIMemoryOrchestrationHandler, ConversationMemoryOrchestrationHandler, AIMemoryPreemptiveRagHandler, the options, the four user-memory tools and the three conversation tools.AddCoreAIMemoryIndexing() registers the ICatalogEntryHandler<AIMemoryEntry> that queues every saved or deleted memory and a hosted background service that writes it to the index, so a save never waits on an embedding call and a failed embedding does not fail the save. A host with its own indexing handler calls services.AddCoreAIMemory() alone, or memories are indexed twice.IAIMemoryStore (and ICatalog<AIMemoryEntry>). YesSql hosts also create the index table with CreateAIMemoryEntryIndexSchemaAsync(...).AddAIMemory() registers the AIMemory index-profile source, its profile handler and the keyed IMemoryVectorSearchService. Indexing and search use the same embedding deployment, read from the index profile's property or its metadata.AIMemoryOptions.IndexProfileName names an index profile of type AIMemory. It is optional: see the fallback below.using CrestApps.Core.AI.Models;
profile.Put(new MemoryMetadata
{
EnableUserMemory = true,
EnableSessionMemory = true,
EnablePastConversations = true,
});
GeneralAIOptions.EnablePreemptiveMemoryRetrieval (default true) on its own: turning off site-wide preemptive RAG no longer stops memory retrieval. A custom IPreemptiveRagHandler with its own switch returns true from RunsWhenPreemptiveRagIsDisabled (default false) to get the same behavior.ClaimTypes.NameIdentifier, falling back to ClaimTypes.Name.IAIMemorySearchService falls back to the memory store when no index profile is configured, the configured one is missing, is not an AIMemory profile, has no vector-search provider or no resolvable embedding deployment (one warning per profile name), or the index holds nothing for the user. The fallback reads up to 200 of the user's memories and ranks them by the share of query terms found in name, description and content, then by most recently updated.
With a positive past-messages count, messages that fall outside the window are no longer simply dropped:
AIChatSession or ChatInteraction as AIConversationMemory (Summary, SummarizedMessageCount, UpdatedUtc), about every three turns. Usage purpose AIUsagePurposes.ConversationSummarization. On a ChatInteraction the handler does not save the interaction itself: it sets AICompletionContextKeys.SaveInteractionAfterTurn and the hub saves the summary on the interaction read again after the answer, so no second interaction is added.search_conversation, which reads only the older messages placed on the current AIInvocationScope, never a store.search_past_conversations and list_recent_conversations search the signed-in user's own conversations with the same profile, newest first, matching title, stored summary and transcript. The store query filters with AIChatSessionQueryContext.UserId, and every result is checked again against the user and profile, so a store that ignores the filter leaks nothing and logs a warning. They are not offered to anonymous visitors. Tool purposes: AIToolPurposes.ConversationMemory and AIToolPurposes.PastConversations.
AIChatHubCore calls AuthorizeSessionAsync before it loads, continues, rates or acts on a session by id. By default only the signed-in user who started it, or the same visitor, gets in; another id is reported as not found, and a message sent to it starts a new session. Override it to let staff open other users' conversations (see crestapps-core-chat-interactions).
| Tool | Use |
|---|---|
save_user_memory | create or update a memory by name |
search_user_memories | semantic search over the user's memories (store fallback without an index) |
list_user_memories | list what is already known |
remove_user_memory | forget a memory |
search_conversation | search the earlier part of the current conversation (session memory) |
search_past_conversations | search the user's earlier conversations with the profile |
list_recent_conversations | list the user's most recent earlier conversations with the profile |
The conversation tools are offered only when their feature is on and there is something to read.
| Contract | Role |
|---|---|
IAIMemoryStore | ICatalog<AIMemoryEntry> plus CountByUserAsync, FindByUserAndNameAsync, GetByUserAsync |
IAIMemorySearchService | shared semantic retrieval |
IMemoryVectorSearchService | provider-keyed vector search adapter |
IAIMemorySafetyService | TryValidate(name, description, content, out errorMessage) before a write |
AIMemoryEntry holds UserId, Name, Description, Content, CreatedUtc and UpdatedUtc.
using CrestApps.Core.AI.Memory;
public sealed class StrictMemorySafetyService : IAIMemorySafetyService
{
private static readonly string[] _blockedWords = ["password", "api key", "secret"];
public bool TryValidate(string name, string description, string content, out string errorMessage)
{
var text = $"{name} {description} {content}";
foreach (var word in _blockedWords)
{
if (text.Contains(word, StringComparison.OrdinalIgnoreCase))
{
errorMessage = "Memories cannot contain credentials or secrets.";
return false;
}
}
errorMessage = null;
return true;
}
}
builder.Services.AddScoped<IAIMemorySafetyService, StrictMemorySafetyService>();
The default registration is a TryAdd, so register your implementation before or after AddAIMemory(...); a plain AddScoped registered later wins for single resolution.
Implement IMemoryVectorSearchService.SearchAsync(SearchIndexProfile indexProfile, float[] embedding, string userId, int topN, CancellationToken) and register it keyed by the provider name of the memory index profile. Always filter by userId so one user can never retrieve another user's memories.
ICatalogEntryHandler<AIMemoryEntry> that indexed memories lived in the sample hosts. A host that calls AddAIMemory() and still registers its own indexing handler removes it, or each memory is indexed twice. A host that calls AddCoreAIMemory() alone (as the Orchard Core module does) is unaffected.AIMemorySearchService takes an IAIMemoryStore and an ITextTokenizer for its store fallback; code that constructs it directly passes both.Content: line.AuthorizeSessionAsync.What SKILL.md sets; muted values are Claude Code's defaults
/crestapps-core:crestapps-core-ai-memoryfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job