Skip to content

Agent memory langgraph long-term-memory using semantic search #42

Closed
jennsun wants to merge 4 commits intobbqiu/mainfrom
long-term-langgraph-stateful-agent
Closed

Agent memory langgraph long-term-memory using semantic search #42
jennsun wants to merge 4 commits intobbqiu/mainfrom
long-term-langgraph-stateful-agent

Conversation

@jennsun
Copy link
Copy Markdown
Collaborator

@jennsun jennsun commented Dec 17, 2025

Created copy of agent-langgraph and added long term memory features

Note: frontend e2e-chatbot-app interface does not support passing in custom input/thread id, only invocation calls on the endpoint. Have filed a ticket to support passing in chatcontext via frontend interface so we can use user id for namespacing

example app: https://eng-ml-agent-platform.staging.cloud.databricks.com/apps/j-longtermagent?o=2850744067564480

Example local testing:

curl -X POST http://localhost:8000/invocations \
  -H "Content-Type: application/json" \
  -d '{
    "input": [{"role": "user", "content": "Remember that my favorite color is blue"}],
    "context": {"user_id": "test@example.com"}
  }'

output from above:

{"object":"response","output":[{"type":"function_call","id":"lc_run--019b059a-09ec-79c3-bcf2-640edb80d37a","call_id":"toolu_bdrk_013tUwgLNctjrTSSSUBWShXQ","name":"save_user_memory","arguments":"{\"memory_key\": \"favorite_color\", \"memory_data_json\": \"{\\\"favorite_color\\\": \\\"blue\\\"}\"}"},{"type":"function_call_output","call_id":"toolu_bdrk_013tUwgLNctjrTSSSUBWShXQ","output":"Successfully saved memory with key 'favorite_color' for user."},{"type":"message","id":"lc_run--019b059a-20c5-76a1-be57-308598158d43","content":[{"text":"Got it! I've remembered that your favorite color is blue. 💙","type":"output_text","annotations":[]}],"role":"assistant"}]}

Follow-up:

curl -X POST http://localhost:8000/invocations \
  -H "Content-Type: application/json" \
  -d '{
    "input": [{"role": "user", "content": "What is my favorite color?"}],
    "context": {"user_id": "test@example.com"}
  }'

Output:

{"object":"response","output":[{"type":"function_call","id":"lc_run--019b059e-a723-76f3-98cb-46737a1ae5f4","call_id":"toolu_bdrk_01QXVHEFgp3VedAuc63HW1b6","name":"get_user_memory","arguments":"{\"query\": \"favorite color\"}"},{"type":"function_call_output","call_id":"toolu_bdrk_01QXVHEFgp3VedAuc63HW1b6","output":"User memories:\n- {\"favorite_color\": \"blue\"}"},{"type":"message","id":"lc_run--019b059e-cbd9-7252-86ff-2ae05615c341","content":[{"text":"Your favorite color is blue!","type":"output_text","annotations":[]}],"role":"assistant"}]}

seeing store tables are ready in app logs:
image

ensure user preferences are stored in lakebase:
image

Currently, cannot use long-term memory via frontend because user id is not passed in to context. Also made sure you cannot access another user's memories via frontend

image

App postman request:
image

@jennsun jennsun changed the title Agent memory langgraph long-term-memory using semantic search in databrickssore Agent memory langgraph long-term-memory using semantic search Jan 2, 2026
jennsun added a commit to databricks/databricks-ai-bridge that referenced this pull request Jan 7, 2026
…syncCheckpointSaver, AsyncDatabricksStore (#255)

This PR adds async versions of the Lakebase connection pool (AsyncLakebasePool), LangGraph checkpoint saver (AsyncCheckpointSaver) and LangGraph PostgresStore(AsyncDatabricksStore) so they can be used in async workflows such as async agent servers and streaming applications

Changes
**Core Library (databricks-ai-bridge)**
src/databricks_ai_bridge/lakebase.py
Added AsyncLakebasePool class that wraps [psycopg_pool.AsyncConnectionPool](https://www.psycopg.org/psycopg3/docs/api/pool.html#psycopg_pool.AsyncConnectionPool)

**LangChain (databricks-langchain)**
**integrations/langchain/src/databricks_langchain/checkpoint.py**
Added AsyncCheckpointSaver class extending [langgraph.checkpoint.postgres.aio.AsyncPostgresSaver](https://pypi.org/project/langgraph-checkpoint-postgres/)

**integrations/langchain/src/databricks_langchain/store.py**
Added AsyncDatabricksStore class extending [AsyncBatchedBaseStore](https://reference.langchain.com/python/langgraph/store/#langgraph.store.postgres.AsyncPostgresStore)
Uses AsyncLakebasePool for connection pooling
Creates short-lived AsyncPostgresStore instances for each operation

Added unit tests for new classes 

Used in agent on apps langgraph examples:
short-term: bbqiu/agent-on-app-proto#39
long-term: bbqiu/agent-on-app-proto#42
@jennsun jennsun requested a review from bbqiu January 16, 2026 23:32
@jennsun jennsun closed this Jan 16, 2026
@jennsun jennsun reopened this Jan 16, 2026
@bbqiu
Copy link
Copy Markdown
Owner

bbqiu commented Jan 17, 2026

databricks/app-templates#86

closing for this PR

@bbqiu bbqiu closed this Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants