-
Notifications
You must be signed in to change notification settings - Fork 123
docs: update agent examples to use middleware for dynamic behavior #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
There was a problem hiding this 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 withmodel
parameter across agent examples - Updates dynamic model selection to use
createMiddleware
withwrapModelCall
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 |
Preview ID generated: preview-cbjsfi-1760438879-96087af |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this 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.
Preview ID generated: preview-cbjsfi-1760439024-2f68a66 |
Updates agent documentation examples to reflect the current API where
createAgent
accepts a string-basedmodel
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 boundAfter: Uses middleware with
wrapModelCall
to dynamically select models based on state2. Dynamic System Prompts (context.mdx)
Python:
create_react_agent
withprompt
parametercreate_agent
with@dynamic_prompt
decorator middlewareJavaScript:
createReactAgent
withstateModifier
parametercreateAgent
withcreateMiddleware
andwrapModelCall
3. Parameter Naming Consistency
Updated
createAgent
calls across multiple files to usemodel
instead of deprecatedllm
: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 unifiedlangchain
package