LangChain LangGraph
Module 1 Module 2 Module 3
Module 3 · Middleware and HITL
1 3.2 Managing Msgs
2 3.3 HITL
3 3.4 Dyn Models
4 3.4 Dyn Prompts
5 3.4 Dyn Tools
6 3.5 Email Agent
SUM Module Summary
HomeLangChainModule 3 · Middleware and HITLModule Summary
LANGCHAIN MODULE 3 · SUMMARY

Middleware, Dynamic Control and Human Approval
Middleware, Control and Human Oversight

Learn how to manage messages, add human approval, and use middleware to switch models, prompts and tools dynamically.

6lessons
4middleware patterns
1project
Open Module 3 home
Learning Map
1
Messages
Messages
Compress or delete messages to control which history enters the model context.
2
HITL
HITL
Add approve, reject and edit approval flows for high-risk tool calls.
3
Dynamic Models
Dynamic Models
Switch models based on conversation length or task complexity.
4
Dynamic Prompts
Dynamic Prompts
Generate different system prompts from runtime context.
5
Dynamic Tools
Dynamic Tools
Restrict tool visibility based on user role or authentication state.
Lesson Summary
1

3.2 Managing Messages

Open the explained page

Manage message history with SummarizationMiddleware and RemoveMessage.

  • summary
  • trim
  • RemoveMessage
2

3.3 Human-in-the-loop

Open the explained page

Pause high-risk tools such as sending email for human approval.

  • approve
  • reject
  • edit
3

3.4a Dynamic Models

Open the explained page

Use wrap_model_call to switch between a standard model and a larger model at runtime.

  • model routing
  • override
  • metadata
4

3.4b Dynamic Prompts

Open the explained page

Generate system prompts dynamically from the user language context.

  • dynamic_prompt
  • context
  • language
5

3.4c Dynamic Tools

Open the explained page

Use user_role to restrict external users to Web Search only.

  • tool permissions
  • role
  • security
6

3.5 Email Agent

Open the explained page

Build an email Agent by combining authentication, dynamic tools, dynamic prompts and HITL.

  • auth
  • email
  • HITL
Completion Criteria