This example keeps memory explicit. A NAT react_agent decides when to call
get_memory and add_memory; Redis Agent Memory stores and searches the
long-term memories behind those tools.
This workflow uses NAT's react_agent, so it needs the langchain-backed NAT
agent package in addition to this plugin.
For a published install:
pip install "nvidia-nat[langchain]" "nemo-agent-toolkit-redis"For local development from this repository:
uv sync --group dev --extra testcp examples/tool_based_memory/.env.example examples/tool_based_memory/.envEdit examples/tool_based_memory/.env:
OPENAI_API_KEYfor NAT's OpenAI LLM and Redis Agent Memory extractionREDIS_AGENT_MEMORY_URLandREDIS_AGENT_MEMORY_NAMESPACEfor the memory serverHOST_REDIS_PORTandHOST_REDIS_AGENT_MEMORY_PORTif the default local ports are already occupiedREDIS_STACK_IMAGEandAGENT_MEMORY_SERVER_IMAGEif you need to override the tested image tags
Compose starts Redis Stack and Agent Memory Server for local development. Both
ports bind to 127.0.0.1, and AMS auth is disabled.
docker compose \
--env-file examples/tool_based_memory/.env \
-f examples/tool_based_memory/compose.yml \
up -dThe runner loads examples/tool_based_memory/.env automatically and passes a
stable user_id plus conversation_id into NAT so the same user can retrieve
what was stored earlier.
uv run nat validate --config_file examples/tool_based_memory/configs/config.yml
uv run python examples/tool_based_memory/run_agent.pyDefault identity:
user_id=demo-userconversation_id=demo-session
Example custom run:
uv run python examples/tool_based_memory/run_agent.py \
--user-id alice \
--conversation-id alice-session \
--input "Remember that I prefer concise answers." \
--input "How should you answer me?"If you prefer the raw NAT CLI, you can still run nat run directly against the
same config. The runner is just the easiest way to provide stable session
context locally.
docker compose \
--env-file examples/tool_based_memory/.env \
-f examples/tool_based_memory/compose.yml \
down -v- Tool-based memory depends on the LLM choosing the memory tools.
- Use
agent_auto_memorywhen every turn should be captured and hydrated automatically.