nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

langchain/Messages

Structure the conversation so the model knows who said what and what it should do.

12 QuestionsBeginnerHigh Priority ~8 min read

LangChain represents conversations using messages rather than treating everything as one large string. Different message types can represent instructions from the system, requests from the user, responses from the model, and information returned by tools.

This structure becomes especially important when building agents because a single workflow may contain several model and tool interactions. Keeping these messages organized gives the model the context it needs to understand what has already happened.

What you'll walk away knowing

How system, user, assistant, and tool messages differ
How messages are passed to language models
How tool results become part of the conversation
Why message structure matters for agent workflows
1What is RemoveMessage in LangGraph and how do you use it to surgically delete specific messages from agent state?Intermediate2How do you persist and restore a full message history across sessions using a checkpoint saver in LangGraph?Intermediate3What is a Message in LangChain and how does it differ from a plain string prompt?Intermediate4How do you convert LangChain messages to OpenAI's raw API format and back — when would you need to do this?Intermediate5How does the messages reducer in LangGraph handle message updates — why can you append, replace, or delete messages by ID?Intermediate6How do you use LangSmith to inspect the exact message array sent to the LLM at every step of an agent run?Intermediate7What is the difference between SystemMessage and HumanMessage — how does the LLM treat them differently under the hood?Intermediate8What are the core message types in LangChain — HumanMessage, AIMessage, SystemMessage, ToolMessage, FunctionMessage — and when do you use each?Intermediate9What is MessagePlaceholder in a ChatPromptTemplate and how does it let you inject dynamic message history into a prompt?Intermediate10Your LLM is returning inconsistent tool call formatting across providers (OpenAI vs Anthropic vs Gemini) — how do LangChain messages abstract this away?Intermediate11Your agent is hitting the context window limit after 20 turns — what is your strategy to manage message history without losing critical context?Intermediate12How do you trim messages to stay within the LLM's context window without losing important conversation context?Intermediate13What is a multimodal message and how do you pass images or file data inside a message content block?Intermediate14A user's message contains both text and an image — how do you construct the correct multimodal HumanMessage content block for a vision model?Intermediate15What is mergeMessageRuns() and when would you use it to preprocess a message list?Intermediate16What is a BaseMessage and why does LangChain model all messages as objects instead of raw strings?Intermediate17How do you construct a conversation history as a BaseMessage[] array and pass it correctly to a Chat Model?Intermediate18What is the difference between AIMessage.tool_calls and AIMessage.additional_kwargs.function_call — why do both exist?Advanced19How do you implement a sliding window memory — keeping only the last N messages — without losing the system prompt?Intermediate20What is the difference between storing messages in MemorySaver vs an external store like Redis or PostgreSQL via a custom BaseCheckpointSaver?Advanced21How do you handle token counting per message — accounting for role overhead, tool schemas, and system prompt tokens — to accurately predict context usage?Advanced22How does LangGraph's MessagesAnnotation work and why is it the recommended state shape for agent graphs?Advanced23How does AIMessage carry tool call requests and how does ToolMessage carry the result back — walk through the full round trip?Intermediate24How do you attach custom metadata to a message (e.g. timestamps, user IDs, trace IDs) without breaking LLM compatibility?Intermediate25What is the content field in a message and why can it be either a string or an array of content blocks?Intermediate26How do you design a multi-tenant message store where conversation histories are isolated per user and per session?Advanced27How do you implement message deduplication in a LangGraph state to avoid the same message being added twice?Intermediate28How do you stream individual message chunks using AIMessageChunk and how do you aggregate them into a complete AIMessage?Intermediate29You need to replay a past conversation from a database and continue it — how do you reconstruct the message state correctly in LangGraph?Advanced30How do you filter messages by type (e.g. only keep HumanMessages) using LangChain's built-in message utilities?Intermediate31What are the security implications of injecting user-supplied content directly into a SystemMessage — how do you prevent prompt injection attacks?Advanced32How do you implement conversation summarization — replacing old messages with a summary message to save tokens?Intermediate
All Topics
1
Basics
Models
Messages
2
Agents
Tools
Middleware
Memory
3
MCP
Multi Agents
Human in the loop
4
RAG
Context Engineering
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.