Help us shape the future of Go! Take the 2026 Go Developer Survey

memory/

directory
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT

README

Memory

Ports of the .NET memory samples. Step numbers follow upstream.

Example Demonstrates
Step 01: Chat history memory Remembering a user's preferences across two independent sessions
Step 05: Bounded chat history Keeping four recent messages and recalling older messages from vector-store overflow

Both use memory.HistoryProvider and an in-memory vector store. Memories survive new sessions, but not process restarts. The fixed UID1 scope is for demonstration; applications should use the authenticated user's identifier.

Run

Sign in with a credential supported by DefaultAzureCredential, such as az login, and configure deployed Foundry models:

$env:FOUNDRY_PROJECT_ENDPOINT = "https://<resource>.services.ai.azure.com/api/projects/<project>"
$env:FOUNDRY_MODEL = "gpt-5.4-mini"
$env:FOUNDRY_EMBEDDING_MODEL = "text-embedding-3-large"

go run .\examples\02-agents\memory\step01_chat_history_memory
go run .\examples\02-agents\memory\step05_bounded_chat_history

These samples use 3072-dimensional embeddings, matching the shared demo default, text-embedding-3-large. If your embedding deployment produces a different vector size, update the dimension argument to memory.NewHistoryProvider in the sample. Runs invoke live services and may incur charges.

Step 05 preserves the first system message outside the four-message window. Function-call and function-result messages are excluded from both retained history and archived memory. Retrieved memories are prepended to recent history and are not stored again.

Local validation

go build .\examples\02-agents\memory\...
go vet .\examples\02-agents\memory\...

Directories

Path Synopsis
This sample recalls chat messages from earlier sessions for the same user.
This sample recalls chat messages from earlier sessions for the same user.
This sample archives older chat messages and recalls them from a vector store.
This sample archives older chat messages and recalls them from a vector store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL