Skip to content

Conversation

christian-bromann
Copy link
Member

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

- Replace function-based dynamic model selection with middleware approach
  in agents.mdx (JS section)
- Update context.mdx to use @dynamic_prompt decorator (Python) and
  createMiddleware (JS) for dynamic system prompts
- Replace deprecated `llm` parameter with `model` in createAgent calls
  across multiple documentation files (mcp.mdx, multi-agent.mdx,
  short-term-memory.mdx, test.mdx, tools.mdx, stagehand.mdx)
- Consolidate imports in test.mdx to use langchain package

These changes align documentation with the current API where createAgent
accepts a string-based model parameter and uses middleware for dynamic
model selection and prompt customization.
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 10:47
@github-actions github-actions bot added langchain For docs changes to LangChain oss javascript labels Oct 14, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates agent documentation examples to reflect the current LangChain API where createAgent accepts a string-based model parameter. The changes introduce middleware patterns for dynamic behavior that was previously handled through function parameters.

Key changes:

  • Replaces deprecated llm parameter with model parameter across agent examples
  • Updates dynamic model selection to use createMiddleware with wrapModelCall instead of passing functions
  • Migrates dynamic prompt patterns to use middleware decorators and createMiddleware

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
agents.mdx Refactors dynamic model selection from function-based approach to middleware pattern
context.mdx Updates dynamic prompt examples for both Python and JavaScript to use middleware
mcp.mdx Updates model parameter name and changes to string-based model identifier
multi-agent.mdx Simplifies model parameter usage
short-term-memory.mdx Simplifies model parameter usage
test.mdx Updates model parameter and consolidates imports to unified package
tools.mdx Updates model parameter while maintaining ChatOpenAI instance
stagehand.mdx Updates import path and model parameter

Copy link
Contributor

Preview ID generated: preview-cbjsfi-1760438879-96087af

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 10:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copy link
Contributor

Preview ID generated: preview-cbjsfi-1760439024-2f68a66

@christian-bromann christian-bromann merged commit 0d94654 into main Oct 14, 2025
11 checks passed
@christian-bromann christian-bromann deleted the cb/js-fixes branch October 14, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript langchain For docs changes to LangChain oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants