liveBook · Manning

Message list

As explained in Building Reliable AI Systems

An ordered collection of messages that can retain a conversation's history.

A message list keeps a conversation’s turns in chronological order. In a conversational agent, it provides short-term context without a separate memory class: LangChain models accept a list of `HumanMessage` and `AIMessage` objects directly. section 6.2.2 section 6.5

from langchain_core.messages import HumanMessage, AIMessage  

chat_history = []  

chat_history.append(HumanMessage(content="What's the weather in Paris?"))
chat_history.append(AIMessage(content="It's sunny and 25°C."))

# Inspect the history
for msg in chat_history:
    role = "Human" if isinstance(msg, HumanMessage) else "AI"
    print(f"{role}: {msg.content}")

The Python listing appends a human turn and an AI reply, then prints the stored history. It demonstrates storage and inspection, not a model call. section 6.2.2

Keeping every turn verbatim makes earlier exchanges available, but the list grows with the conversation. Use full-history retention for short or limited-scope interactions. For longer conversations or tighter context limits, an LLM-generated running summary can condense less-relevant details while preserving core context. Persistent memory serves a different need: retaining information across sessions. section 6.2.2 section 6.5

How Building Reliable AI Systems covers it

How deep it goes
Shows direct construction and inspection with LangChain message objects, then contrasts full retention with summarization; does not specify persistent storage.
Examples
Uses a Python list containing a weather question and reply, then prints each message’s role and content.
What it assumes
Assumes familiarity with Python lists while showing the LangChain message imports and append operations needed for the example.
What you can do after
Build it from scratch as a Python list of LangChain messages for short conversations, and recognize when growth calls for summarization.
How it connects
Connects short-term memory to conversation summarization and distinguishes it from persistent memory across sessions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.