langgraph/how-tos/persistence_postgres/ #894
Replies: 35 comments 61 replies
-
How do I pass config and recursion limit together while streaming the graph? Currently, I'm getting this error - TypeError: Pregel.stream() takes from 2 to 3 positional arguments but 4 were given |
Beta Was this translation helpful? Give feedback.
-
Can you also update this guide but for JS version, and maybe a seperate general guide to explain in detail how to create a custom checkpointer and each component a checkpointer should have? I feel like this is a really important feature to bring LangGraph to production and there should be more guidance for it. |
Beta Was this translation helpful? Give feedback.
-
Please add a specific section on accessing and modifying the state variables of nodes from outside the node functions. |
Beta Was this translation helpful? Give feedback.
-
William
Thanks for the reply, this is not exactly what I am looking for. Consider a simple scenario that an attribute in the state object has to be modified.
I have a state object and want to modify a string parameter and set it to a value , for e.g. plan attribute . A simple document to modify state attributes with examples will be useful.
class AgentState(TypedDict):
task: str
plan: str
draft: str
critique: str
content: List[str]
revision_number: int
max_revisions: int
workflow = StateGraph(AgentState)
rampi
…________________________________
From: William FH ***@***.***>
Sent: 09 July 2024 03:47
To: langchain-ai/langgraph ***@***.***>
Cc: Ramprasad ***@***.***>; Comment ***@***.***>
Subject: Re: [langchain-ai/langgraph] langgraph/how-tos/persistence_postgres/ (Discussion #894)
You mean like this? https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/edit-graph-state/<https://eu-central-1.protection.sophos.com/?d=langchain-ai.github.io&u=aHR0cHM6Ly9sYW5nY2hhaW4tYWkuZ2l0aHViLmlvL2xhbmdncmFwaC9ob3ctdG9zL2h1bWFuX2luX3RoZV9sb29wL2VkaXQtZ3JhcGgtc3RhdGUv&i=NWY1NzY4MDNhOGI2OTAwZWFlOGRmNDI2&t=QkNXVHhueXB5K0FEKzQ2eFNNSEpXelZJTCtEbCs5VGdscllybnBqZThGdz0=&h=afb31f07d9264eedb4c62fc9d0a21266&s=AVNPUEhUT0NFTkNSWVBUSVY6K0T94M0wPyDMzKN9BocAHrXlbSFJ3THbbw-AzQ3TEw>
—
Reply to this email directly, view it on GitHub<https://eu-central-1.protection.sophos.com/?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2xhbmdjaGFpbi1haS9sYW5nZ3JhcGgvZGlzY3Vzc2lvbnMvODk0I2Rpc2N1c3Npb25jb21tZW50LTk5OTIwOTM=&i=NWY1NzY4MDNhOGI2OTAwZWFlOGRmNDI2&t=V0pKTnpNS3A2clF5NG54MUJYeStraGNLOHoxcVZBRklqU3dQV0xMbGF5RT0=&h=afb31f07d9264eedb4c62fc9d0a21266&s=AVNPUEhUT0NFTkNSWVBUSVY6K0T94M0wPyDMzKN9BocAHrXlbSFJ3THbbw-AzQ3TEw>, or unsubscribe<https://eu-central-1.protection.sophos.com/?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL25vdGlmaWNhdGlvbnMvdW5zdWJzY3JpYmUtYXV0aC9CRjVDSlQyVkNRUFJLTFFMWTZDVkdLVFpMTUZZSEFWQ05GU002QUFBQUFCS0U0N1RENlZISTJEU01WUVdJWDNMTVY0M1NSREpPTlJYSzQzVE5GWFc0UTNQTlZXV0szVFVITTRUU09KU0dBNFRH&i=NWY1NzY4MDNhOGI2OTAwZWFlOGRmNDI2&t=SDdWRUxYR1o5RmROWXNnNWhrdktVWGVvZW9rOXY0eDBlbWdsWXdjcVZUST0=&h=afb31f07d9264eedb4c62fc9d0a21266&s=AVNPUEhUT0NFTkNSWVBUSVY6K0T94M0wPyDMzKN9BocAHrXlbSFJ3THbbw-AzQ3TEw>.
You are receiving this because you commented.Message ID: ***@***.***>
This E-MAIL message is a property of Premjiinvest and is intended for use only by the individual or entity to which it is addressed. The information contained may be confidential and privileged. If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the company. If you have received this message by mistake, kindly notify the sender by return E-MAIL and delete this message. Premjiinvest will not be responsible for any viruses or defects or any forwarded attachments emanating either from within or outside. Premjiinvest reserves the right to monitor and review the content of all messages sent to or from Premjiinvest E-MAIL addresses. Messages sent to or from this e-mail address may be stored on the Premjiinvest E-MAIL system or elsewhere.
|
Beta Was this translation helpful? Give feedback.
-
Hello, How can I limit the memory, avoiding the graph to continuously have more history on its prompt? E.g., by limiting to the last 10 messages |
Beta Was this translation helpful? Give feedback.
-
I am currently implementing a customer support bot and have been exploring the use of persistent memory to manage user interactions. My initial approach was to load the memory for a specific user from persistent storage, ensuring that all interactions from different users remain isolated. This seemed straightforward for maintaining user-specific contexts across sessions. However, I am a bit confused about the specific utility of threads in this context. I understand that threads can provide additional granularity by keeping separate interactions within the same user session, but I am struggling to come up with concrete use cases where this granularity would be beneficial. One example I am considering is within a single chat interaction. Even with persistent memory loaded through a checkpointer, it seems possible to add more granularity by using threads to manage multiple sub-interactions within a single user session. For instance, in a customer support bot scenario, a user might request multiple tasks, and these could be managed as separate threads within the same interaction. My question is about the practical management of this granularity. How does the agent determine which thread to use at any given time within an ongoing interaction? Are there specific strategies or examples where combining both checkpointers and threads has proven particularly effective? I would greatly appreciate insights from those with more experience in this area. |
Beta Was this translation helpful? Give feedback.
-
Any plans to add to the documentation an explanation of the "state' structure once its persisted? e.g: To understand what each of those values here represent :) |
Beta Was this translation helpful? Give feedback.
-
Why we need the |
Beta Was this translation helpful? Give feedback.
-
It should have docs about the way checkpointer work. |
Beta Was this translation helpful? Give feedback.
-
I get this error from get_tuple: CheckpointTuple.new() got an unexpected keyword argument 'pending_writes' and sure enough it doesn't: class CheckpointTuple(NamedTuple): Anybody any ideas? |
Beta Was this translation helpful? Give feedback.
-
Hi folks! We just released a new Postgres checkpointer library -- you can install it with Please let me know if you run into any issues with the library! |
Beta Was this translation helpful? Give feedback.
-
from psycopg_pool import AsyncConnectionPool
async with AsyncConnectionPool(
# Example configuration
conninfo=DB_URI,
max_size=20,
kwargs=connection_kwargs
) as pool, pool.connection() as conn:
checkpointer = AsyncPostgresSaver(conn)
# NOTE: you need to call .setup() the first time you're using your checkpointer
# await checkpointer.setup()
graph = create_react_agent(model, tools=tools, checkpointer=checkpointer)
config = {"configurable": {"thread_id": "4"}}
res = await graph.ainvoke(
{"messages": [("human", "what's the weather in nyc")]}, config
)
checkpoint = await checkpointer.aget(config) Regarding this piece of pool code, the pool has 20 connections available, but the code only takes one connection from the pool and assigns it to Does this mean that an AsyncPostgresSaver will always have only one connection? Additionally, I have a similar question to @GaryFail: how exactly should I compile the graph and the checkpointer in the API? |
Beta Was this translation helpful? Give feedback.
-
Any idea on which implementation works the best for the production environment ..?
|
Beta Was this translation helpful? Give feedback.
-
Hey when I run my agent outside of LangGraph studio it's accessing the DB fine. I've even used ngrok to expose to TCP port. But from the langgraph studio docker container it won't connect. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
i am getting error on imports error:
|
Beta Was this translation helpful? Give feedback.
-
I am using postgres checkpointer to save STATE and creating THREADS for follow-up questions. I want to understand if there is a way to filter certain state variables before checkpointers saves them? I want to avoid saving RAG searches in my DB? |
Beta Was this translation helpful? Give feedback.
-
Whats the actual implementation for thread checkpoint rollback ? i mean, if a specific thread gets an exception during execution which leads to a "broken" state i.e. ai_messages with tool calls without tool_messages. Whats the best way to have the last valid checkpoint being the last again ? |
Beta Was this translation helpful? Give feedback.
-
How do we select which schema do use? |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Are there any examples that don't use async context managers? The examples are good for simple graphs but creating complex graphs everytime we call a query eats a lot of time. I'm also having connection leaks and errors after running a large amount of queries in a short period |
Beta Was this translation helpful? Give feedback.
-
Why using psycopg3 instead of asyncpg? Is there any motivation behind? |
Beta Was this translation helpful? Give feedback.
-
How can we do memory management with this case, lets say i want the last 3 checkpointers to work as chat_history of the agent, if this cannot be done then how the current implementation works under the hood, Kindly share if someone have some idea? |
Beta Was this translation helpful? Give feedback.
-
Even if I add something to the checkpoint namespace under
In sample code above, the checkpoint with the corrrect threadId and initialised. But checkpoint_ns is still empty in the database. |
Beta Was this translation helpful? Give feedback.
-
Is there any way we can use sqlalchemy |
Beta Was this translation helpful? Give feedback.
-
when i used AsyncPostgresStore ,version 2.0.8
build a graph,and async node中的 await store.age should deadlock ,like this
but if like this no problem
add sleep then no problem
why???
change pool no problem |
Beta Was this translation helpful? Give feedback.
-
How to use Checkpointer if I am using LangGraph Cloud? |
Beta Was this translation helpful? Give feedback.
-
I keep getting the following error in checkpointer.setup(), what could be the problem? InvalidSchemaName: no schema has been selected to create in |
Beta Was this translation helpful? Give feedback.
-
Looks like a lot of documentation is missing. For example a table |
Beta Was this translation helpful? Give feedback.
-
I am using supabase and postgres sql saver. It seems to work ok. My usecase is sales agent that collects orders. In my UI I would like to present the conversation history, so I am planning to create a view in supabase, do you have any suggestions how to do it, as the structure is not clearly documented? |
Beta Was this translation helpful? Give feedback.
-
What’s the best way to do data retention for the Postgres checkpoint save? I want to make sure the data is deleted after 30 days from the Postgres DB. |
Beta Was this translation helpful? Give feedback.
-
langgraph/how-tos/persistence_postgres/
Build language agents as graphs
https://langchain-ai.github.io/langgraph/how-tos/persistence_postgres/
Beta Was this translation helpful? Give feedback.
All reactions