[PR #880] [MERGED] docs: update agent examples to use middleware for dynamic behavior #1109

Closed
opened 2026-02-17 17:21:44 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/880
Author: @christian-bromann
Created: 10/14/2025
Status: Merged
Merged: 10/14/2025
Merged by: @christian-bromann

Base: mainHead: cb/js-fixes


📝 Commits (3)

  • 2c3086b docs: update agent examples to use middleware for dynamic behavior
  • cc1c45f Update src/oss/langchain/agents.mdx
  • 344bb05 Update src/oss/concepts/context.mdx

📊 Changes

8 files changed (+57 additions, -58 deletions)

View changed files

📝 src/oss/concepts/context.mdx (+25 -32)
📝 src/oss/javascript/integrations/tools/stagehand.mdx (+2 -2)
📝 src/oss/langchain/agents.mdx (+20 -10)
📝 src/oss/langchain/mcp.mdx (+1 -1)
📝 src/oss/langchain/multi-agent.mdx (+1 -1)
📝 src/oss/langchain/short-term-memory.mdx (+1 -1)
📝 src/oss/langchain/test.mdx (+6 -10)
📝 src/oss/langchain/tools.mdx (+1 -1)

📄 Description

Updates agent documentation examples to reflect the current API where createAgent accepts a string-based model parameter and uses middleware for dynamic behavior.

Changes

1. Dynamic Model Selection Pattern (agents.mdx)

Before: Used a function passed to the llm parameter that returned a chat model instance with tools bound
After: Uses middleware with wrapModelCall to dynamically select models based on state

2. Dynamic System Prompts (context.mdx)

Python:

  • Replaced create_react_agent with prompt parameter
  • Now uses create_agent with @dynamic_prompt decorator middleware

JavaScript:

  • Replaced createReactAgent with stateModifier parameter
  • Now uses createAgent with createMiddleware and wrapModelCall

3. Parameter Naming Consistency

Updated createAgent calls across multiple files to use model instead of deprecated llm:

  • mcp.mdx
  • multi-agent.mdx
  • short-term-memory.mdx
  • test.mdx
  • tools.mdx
  • stagehand.mdx

4. Import Consolidation

Simplified imports in test.mdx to use the unified langchain package


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/880 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 10/14/2025 **Status:** ✅ Merged **Merged:** 10/14/2025 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `cb/js-fixes` --- ### 📝 Commits (3) - [`2c3086b`](https://github.com/langchain-ai/docs/commit/2c3086b2ed1e2c759ebab54bb9a0a057a3e8cc08) docs: update agent examples to use middleware for dynamic behavior - [`cc1c45f`](https://github.com/langchain-ai/docs/commit/cc1c45fa3e4572e93a9005ce4c29f63d13eabf2e) Update src/oss/langchain/agents.mdx - [`344bb05`](https://github.com/langchain-ai/docs/commit/344bb0500eb3b8027070ac63ac78295deed16fee) Update src/oss/concepts/context.mdx ### 📊 Changes **8 files changed** (+57 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/concepts/context.mdx` (+25 -32) 📝 `src/oss/javascript/integrations/tools/stagehand.mdx` (+2 -2) 📝 `src/oss/langchain/agents.mdx` (+20 -10) 📝 `src/oss/langchain/mcp.mdx` (+1 -1) 📝 `src/oss/langchain/multi-agent.mdx` (+1 -1) 📝 `src/oss/langchain/short-term-memory.mdx` (+1 -1) 📝 `src/oss/langchain/test.mdx` (+6 -10) 📝 `src/oss/langchain/tools.mdx` (+1 -1) </details> ### 📄 Description Updates agent documentation examples to reflect the current API where `createAgent` accepts a string-based `model` parameter and uses middleware for dynamic behavior. ## Changes ### 1. Dynamic Model Selection Pattern (agents.mdx) **Before:** Used a function passed to the `llm` parameter that returned a chat model instance with tools bound **After:** Uses middleware with `wrapModelCall` to dynamically select models based on state ### 2. Dynamic System Prompts (context.mdx) **Python:** - Replaced `create_react_agent` with `prompt` parameter - Now uses `create_agent` with `@dynamic_prompt` decorator middleware **JavaScript:** - Replaced `createReactAgent` with `stateModifier` parameter - Now uses `createAgent` with `createMiddleware` and `wrapModelCall` ### 3. Parameter Naming Consistency Updated `createAgent` calls across multiple files to use `model` instead of deprecated `llm`: - `mcp.mdx` - `multi-agent.mdx` - `short-term-memory.mdx` - `test.mdx` - `tools.mdx` - `stagehand.mdx` ### 4. Import Consolidation Simplified imports in `test.mdx` to use the unified `langchain` package --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:21:44 -05:00
yindo closed this issue 2026-02-17 17:21:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#1109