-
Notifications
You must be signed in to change notification settings - Fork 112
fix(langchain): removing more v0 content #861
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
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 modernizes LangChain's documentation by removing outdated v0 content and updating it to reflect the current middleware-based architecture. The changes reorganize content to improve user experience and maintain consistency across documentation sections.
Key changes:
- Refactored middleware patterns from legacy hooks to modern decorator and class-based approaches
- Moved "Create tools" section from beginning to end in tools documentation for better information flow
- Updated API patterns throughout multiple files to use current middleware architecture
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/oss/langchain/tools.mdx |
Moved "Create tools" section to end and expanded agent data access content |
src/oss/langchain/short-term-memory.mdx |
Updated state management and hooks to use middleware patterns |
src/oss/langchain/runtime.mdx |
Modernized runtime access examples to use middleware instead of hooks |
src/oss/langchain/rag.mdx |
Added missing state_schema property to middleware class |
src/oss/langchain/middleware.mdx |
Reorganized decorator and class-based middleware sections |
src/oss/langchain/context-engineering.mdx |
Complete rewrite to focus on practical middleware-based patterns |
src/oss/langchain/agents.mdx |
Added middleware references and updated hook descriptions |
Preview ID generated: preview-srchip-1760369918-75ab621 |
Preview ID generated: preview-srchip-1760371054-ce01201 |
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 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/oss/langchain/short-term-memory.mdx:67
- Missing closing bracket for the
messages
array in the JavaScript code.
});
src/oss/langchain/context-engineering.mdx:1
- The function
perform_search
is referenced but not defined. This will cause a runtime error when the example is executed. Consider providing a placeholder implementation or noting that it's a stub function.
---
Preview ID generated: preview-srchip-1760371860-09bf38d |
For more details on streaming, see [Streaming](/oss/langchain/streaming). | ||
</Tip> | ||
|
||
### Middleware |
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.
can add specific code examples here if we want, but I think middleware section makes more sense
Preview ID generated: preview-srchip-1760374199-c008c3d |
from langchain.agents import create_agent, AgentState | ||
from langchain.agents.middleware import AgentMiddleware | ||
from langgraph.checkpoint.memory import InMemorySaver | ||
|
||
class CustomAgentState(AgentState): # [!code highlight] | ||
user_id: str # [!code highlight] | ||
preferences: dict # [!code highlight] | ||
|
||
class StateExtensionMiddleware(AgentMiddleware[CustomAgentState]): | ||
state_schema = CustomAgentState # [!code highlight] | ||
|
||
agent = create_agent( | ||
"openai:gpt-5", | ||
[get_user_info], | ||
state_schema=CustomAgentState, # [!code highlight] | ||
middleware=[StateExtensionMiddleware()], # [!code highlight] | ||
checkpointer=InMemorySaver(), | ||
) |
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.
This seems unfortunate to me :/
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.
Also not a great example of state extension? Both of these seem context-y?
from langchain_core.messages.utils import count_tokens_approximately | ||
from langchain.agents import create_agent, AgentState | ||
from langchain.agents import create_agent | ||
from langchain.agents.middleware import SummarizationMiddleware |
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.
Nice!
Preview ID generated: preview-srchip-1760375129-9bc72ff |
Preview ID generated: preview-srchip-1760375332-0ab38d5 |
Preview ID generated: preview-srchip-1760375536-7581bf7 |
Preview ID generated: preview-srchip-1760375669-afa4ae5 |
Preview ID generated: preview-srchip-1760406357-8eda49f |
Preview ID generated: preview-srchip-1760406558-ab7c31b |
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.
Comments suppressed due to low confidence (2)
src/oss/langchain/middleware.mdx:1
- The unreachable return statement has been removed, but the exception handling logic is still incomplete. The retry should continue to the next iteration within the loop rather than falling through.
---
src/oss/langchain/context-engineering.mdx:1
- The function
perform_search
is referenced but not defined. This appears to be a placeholder that should either be implemented or marked as a conceptual example.
---
} | ||
return None | ||
|
||
# Wrap-style: retry logic |
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.
I don't know if "wrap-style" would make sense to folks
|
||
## Decorator-based middleware | ||
|
||
For simple middleware that only needs a single hook, decorators provide the quickest way to add functionality: |
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.
This might work better as tabs or separate snippets, not sure, but code block is long
removing v0 content