LangChainLangChain 1.4 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
43 small wins to finish your pathNext lesson

What each thread keeps

Each customer has a thread, and the checkpointer holds it. What is in that thread is exactly what the model saw, masked card number and all.

Example
from chat import say
from desk import agent

say("ravi", "My card 4111 1111 1111 1111 was charged. Where is A17?", "ravi-1")
say("ravi", "How long does a refund take?", "ravi-1")
state = agent.get_state({"configurable": {"thread_id": "ravi-1"}})
print(len(state.values["messages"]), "messages saved")
print(state.values["messages"][0].text)

Two questions left eight messages: each one added a question, a tool call, a tool result and an answer. The first message is the card question, and the number in it is masked, because masking happened before the checkpointer ran.

Mei's thread holds none of this. A thread id is what separates two customers, and forgetting to pass one is how a support desk tells a customer about somebody else's order.

Try it yourself
  • Print state.values["messages"][-1].text and compare it with what say printed.
  • Ask Ravi a third question and count the messages again.
  • Read the same thread id as Mei and see whose messages come back.

Little by little, you're building something great.