Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pipeline/preprocessors/link_map.py
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing dupes

Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class LinkMap(TypedDict):
"BaseMessage": "classes/_langchain_core.messages.BaseMessage.html",
"HumanMessage": "classes/_langchain_core.messages.HumanMessage.html",
"SystemMessage": "classes/_langchain_core.messages.SystemMessage.html",
"SystemMessage.concat": "classes/_langchain_core.messages.SystemMessage.html#concat",
"ToolMessage": "classes/_langchain_core.messages.ToolMessage.html",
"ToolCallChunk": "classes/_langchain_core.messages.ToolCallChunk.html",
"BaseChatModel": "classes/_langchain_core.language_models_chat_models.BaseChatModel.html",
Expand All @@ -350,8 +351,8 @@ class LinkMap(TypedDict):
"Document": "classes/_langchain_core.documents.Document.html",
"Embeddings": "classes/_langchain_core.embeddings.Embeddings.html",
"initChatModel": "functions/langchain.chat_models_universal.initChatModel.html",
"RunnableConfig": "interfaces/_langchain_core.runnables.RunnableConfig.html",
"Runnable": "classes/_langchain_core.runnables.Runnable.html",
"RunnableConfig": "interfaces/_langchain_core.runnables.RunnableConfig.html",
"Retrievers": "interfaces/_langchain_core.retrievers.BaseRetriever.html",
"VectorStore": "classes/_langchain_core.vectorstores.VectorStore.html",
"VectorStore.maxMarginalRelevanceSearch": "classes/_langchain_core.vectorstores.VectorStore.html#maxMarginalRelevanceSearch",
Expand All @@ -376,7 +377,9 @@ class LinkMap(TypedDict):
"BaseCheckpointSaver": "classes/_langchain_langgraph-checkpoint.BaseCheckpointSaver.html",
"BaseStore": "classes/_langchain_langgraph-checkpoint.BaseStore.html",
"BaseStore.put": "classes/_langchain_langgraph-checkpoint.BaseStore.html#put",
"InMemorySaver": "classes/_langchain_langgraph-checkpoint.MemorySaver.html",
"MemorySaver": "classes/_langchain_langgraph-checkpoint.MemorySaver.html",
"AsyncPostgresSaver": "classes/_langchain_langgraph-checkpoint-postgres.AsyncPostgresSaver.html",
"PostgresSaver": "classes/_langchain_langgraph-checkpoint-postgres.index.PostgresSaver.html",
"protocol": "interfaces/_langchain_langgraph-checkpoint.SerializerProtocol.html",
"SerializerProtocol": "interfaces/_langchain_langgraph-checkpoint.SerializerProtocol.html",
Expand All @@ -390,24 +393,22 @@ class LinkMap(TypedDict):
"addEdge": "classes/_langchain_langgraph.index.StateGraph.html#addEdge",
"add_node": "classes/_langchain_langgraph.index.StateGraph.html#addNode",
"add_messages": "functions/_langchain_langgraph.index.messagesStateReducer.html",
"LastValue": "classes/_langchain_langgraph.channels.LastValue.html",
"Topic": "classes/_langchain_langgraph.channels.Topic.html",
"BinaryOperatorAggregate": "classes/_langchain_langgraph.index.BinaryOperatorAggregate.html",
"Command": "classes/_langchain_langgraph.index.Command.html",
"CompiledStateGraph": "classes/_langchain_langgraph.index.CompiledStateGraph.html",
"create_agent": "functions/langchain.index.createAgent.html",
"create_react_agent": "functions/_langchain_langgraph.prebuilt.createReactAgent.html",
"create_supervisor": "functions/_langchain_langgraph-supervisor.createSupervisor.html",
"createAgent": "functions/langchain.index.createAgent.html",
"createReactAgent": "functions/_langchain_langgraph.prebuilt.createReactAgent.html",
"createSupervisor": "functions/_langchain_langgraph-supervisor.createSupervisor.html",
"entrypoint": "functions/_langchain_langgraph.index.entrypoint.html",
"entrypoint.final": "functions/_langchain_langgraph.index.entrypoint.html#final",
"get_state_history": "classes/_langchain_langgraph.pregel.Pregel.html#getStateHistory",
"getStateHistory": "classes/_langchain_langgraph.pregel.Pregel.html#getStateHistory",
"HumanInterrupt": "interfaces/_langchain_langgraph.prebuilt.HumanInterrupt.html",
"interrupt": "functions/_langchain_langgraph.index.interrupt.html",
"InMemorySaver": "classes/_langchain_langgraph-checkpoint.MemorySaver.html",
"AsyncPostgresSaver": "classes/_langchain_langgraph-checkpoint-postgres.index.PostgresSaver.html",
"CompiledStateGraph.invoke": "classes/_langchain_langgraph.index.CompiledStateGraph.html#invoke",
"langgraph.json": "cloud/reference/cli/#configuration-file",
"LastValue": "classes/_langchain_langgraph.channels.LastValue.html",
"Topic": "classes/_langchain_langgraph.channels.Topic.html",
"messagesStateReducer": "functions/_langchain_langgraph.index.messagesStateReducer.html",
"Pregel": "classes/_langchain_langgraph.pregel.Pregel.html",
"Pregel.stream": "classes/_langchain_langgraph.pregel.Pregel.html#stream",
Expand Down Expand Up @@ -435,6 +436,7 @@ class LinkMap(TypedDict):
"ContextEdit": "interfaces/langchain.index.ContextEdit.html",
"toolRetryMiddleware": "functions/langchain.index.toolRetryMiddleware.html",
"modelRetryMiddleware": "functions/langchain.index.modelRetryMiddleware.html",
"systemPrompt": "types/langchain.index.CreateAgentParams.html#systemprompt",
},
},
]
Expand Down
8 changes: 6 additions & 2 deletions src/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@
"pages": [
"oss/python/langchain/overview",
{
"group": "LangChain v1.0",
"group": "Releases",
"pages": [
"oss/python/releases/langchain-v1",
"oss/python/releases/changelog",
"oss/python/migrate/langchain-v1"
]
},
Expand Down Expand Up @@ -417,6 +418,7 @@
{
"group": "Releases",
"pages": [
"oss/python/releases/changelog",
"oss/python/releases/langchain-v1"
]
},
Expand Down Expand Up @@ -487,9 +489,10 @@
"pages": [
"oss/javascript/langchain/overview",
{
"group": "LangChain v1.0",
"group": "Releases",
"pages": [
"oss/javascript/releases/langchain-v1",
"oss/javascript/releases/changelog",
"oss/javascript/migrate/langchain-v1"
]
},
Expand Down Expand Up @@ -792,6 +795,7 @@
{
"group": "Releases",
"pages": [
"oss/javascript/releases/changelog",
"oss/javascript/releases/langchain-v1"
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/langsmith/rate-limiting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def evaluator(inputs: dict, outputs: dict, reference_outputs: dict) -> dict:
...
```

See the [`langchain`](oss/langchain/models#rate-limiting) documentation for more on how to configure rate limiters.
See the [`langchain`](/oss/langchain/models#rate-limiting) documentation for more on how to configure rate limiters.

## Retrying with exponential backoff

Expand Down
29 changes: 29 additions & 0 deletions src/oss/javascript/releases/changelog.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Changelog
sidebarTitle: Changelog
rss: true
---

A chronological log of updates and improvements to LangChain JavaScript.

<Update label="v1.1" description="November 25, 2025">

* [Model profiles](/oss/langchain/models#model-profiles): Chat models now expose supported features and capabilities through a `.profile` getter. These data are derived from [models.dev](https://github.com/sst/models.dev), an open source project providing model capability data.
* [Model retry middleware](/oss/langchain/middleware/built-in#model-retry): New middleware for automatically retrying failed model calls with configurable exponential backoff, improving agent reliability.
* [Content moderation middleware](/oss/langchain/middleware/built-in#content-moderation): OpenAI content moderation middleware for detecting and handling unsafe content in agent interactions. Supports checking user input, model output, and tool results.
* [Summarization middleware](/oss/langchain/middleware/built-in#summarization): Updated to support flexible trigger points using model profiles for context-aware summarization.
* [Structured output](/oss/langchain/structured-output): `ProviderStrategy` support (native structured output) can now be inferred from model profiles.
* [`SystemMessage` for `createAgent`](/oss/langchain/middleware/custom#working-with-system-messages): Support for passing `SystemMessage` instances directly to `createAgent`'s `systemPrompt` parameter and a new `concat` method for extending system messages. Enables advanced features like cache control and structured content blocks.
* [Dynamic system prompt middleware](/oss/langchain/agents#dynamic-system-prompt): Return values from `dynamicSystemPromptMiddleware` are now purely additive. When returning a @[`SystemMessage`] or `string`, they are merged with existing system messages rather than replacing them, making it easier to compose multiple middleware that modify the prompt.
* **Compatibility improvements:** Fixed error handling for Zod v4 validation errors in structured output and tool schemas, ensuring detailed error messages are properly displayed.

</Update>

## Resources

- [V1 Migration guide](/oss/migrate/langchain-v1) - How to migrate to LangChain v1
- [V1 Release notes](/oss/releases/langchain-v1) - Detailed release notes
- [Release policy](/oss/release-policy) - Detailed release policies
- [Versioning](/oss/versioning) - Understanding version numbers
- [Report issues on GitHub](https://github.com/langchain-ai/langchainjs/issues)

4 changes: 2 additions & 2 deletions src/oss/javascript/releases/langchain-v1.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: What's new in v1
sidebarTitle: Release notes
sidebarTitle: V1 Release Notes
---

**LangChain v1 is a focused, production-ready foundation for building agents.** We've streamlined the framework around three core improvements:
Expand Down Expand Up @@ -310,7 +310,7 @@ Please report any issues discovered with 1.0 on [GitHub](https://github.com/lang
<Card title="LangChain 1.0" icon="rocket" href="https://blog.langchain.com/langchain-langchain-1-0-alpha-releases/">
Read the announcement
</Card>
<Card title="Middleware Guide" icon="puzzle-piece" href="https://blog.langchain.com/agent-middleware/">
<Card title="Middleware guide" icon="puzzle-piece" href="https://blog.langchain.com/agent-middleware/">
Deep dive into middleware
</Card>
<Card title="Agents Documentation" icon="book" href="/oss/langchain/agents" arrow>
Expand Down
195 changes: 195 additions & 0 deletions src/oss/langchain/middleware/custom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,201 @@ const agent = createAgent({

:::

### Working with system messages

:::python

Modify system messages in middleware using the `system_message` field on `ModelRequest`. The `system_message` field contains a @[`SystemMessage`] object (even if the agent was created with a string `system_prompt`).

**Example: Adding context to system message**

<Tabs>
<Tab title="Decorator">

```python
from langchain.agents.middleware import wrap_model_call, ModelRequest, ModelResponse
from langchain.messages import SystemMessage
from typing import Callable


@wrap_model_call
def add_context(
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
# Always work with content blocks
new_content = list(request.system_message.content_blocks) + [
{"type": "text", "text": "Additional context."}
]
new_system_message = SystemMessage(content=new_content)
return handler(request.override(system_message=new_system_message))
```

</Tab>

<Tab title="Class">

```python
from langchain.agents.middleware import AgentMiddleware, ModelRequest, ModelResponse
from langchain.messages import SystemMessage
from typing import Callable


class ContextMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
# Always work with content blocks
new_content = list(request.system_message.content_blocks) + [
{"type": "text", "text": "Additional context."}
]
new_system_message = SystemMessage(content=new_content)
return handler(request.override(system_message=new_system_message))
```

</Tab>
</Tabs>

**Example: Working with cache control (Anthropic)**

When working with Anthropic models, you can use structured content blocks with cache control directives to cache large system prompts:

<Tabs>
<Tab title="Decorator">

```python
from langchain.agents.middleware import wrap_model_call, ModelRequest, ModelResponse
from langchain.messages import SystemMessage
from typing import Callable


@wrap_model_call
def add_cached_context(
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
# Always work with content blocks
new_content = list(request.system_message.content_blocks) + [
{
"type": "text",
"text": "Here is a large document to analyze:\n\n<document>...</document>",
# content up until this point is cached
"cache_control": {"type": "ephemeral"}
}
]

new_system_message = SystemMessage(content=new_content)
return handler(request.override(system_message=new_system_message))
```

</Tab>

<Tab title="Class">

```python
from langchain.agents.middleware import AgentMiddleware, ModelRequest, ModelResponse
from langchain.messages import SystemMessage
from typing import Callable


class CachedContextMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
# Always work with content blocks
new_content = list(request.system_message.content_blocks) + [
{
"type": "text",
"text": "Here is a large document to analyze:\n\n<document>...</document>",
"cache_control": {"type": "ephemeral"} # This content will be cached
}
]

new_system_message = SystemMessage(content=new_content)
return handler(request.override(system_message=new_system_message))
```

</Tab>
</Tabs>

**Notes:**
- `ModelRequest.system_message` is always a @[`SystemMessage`] object, even if the agent was created with `system_prompt="string"`
- Use `SystemMessage.content_blocks` to access content as a list of blocks, regardless of whether the original content was a string or list
- When modifying system messages, use `content_blocks` and append new blocks to preserve existing structure
- You can pass @[`SystemMessage`] objects directly to `create_agent`'s `system_prompt` parameter for advanced use cases like cache control

:::

:::js
Modify system messages in middleware using the `systemMessage` field in `ModelRequest`. It contains a @[`SystemMessage`] object (even if the agent was created with a string @[`systemPrompt`]).

**Example: Chaining middleware** - Different middleware can use different approaches:

```typescript
import { createMiddleware, SystemMessage, createAgent } from "langchain";

// Middleware 1: Uses systemMessage with simple concatenation
const myMiddleware = createMiddleware({
name: "MyMiddleware",
wrapModelCall: async (request, handler) => {
return handler({
...request,
systemMessage: request.systemMessage.concat(`Additional context.`),
});
},
});

// Middleware 2: Uses systemMessage with structured content (preserves structure)
const myOtherMiddleware = createMiddleware({
name: "MyOtherMiddleware",
wrapModelCall: async (request, handler) => {
return handler({
...request,
systemMessage: request.systemMessage.concat(
new SystemMessage({
content: [
{
type: "text",
text: " More additional context. This will be cached.",
cache_control: { type: "ephemeral", ttl: "5m" },
},
],
})
),
});
},
});

const agent = createAgent({
model: "anthropic:claude-3-5-sonnet",
systemPrompt: "You are a helpful assistant.",
middleware: [myMiddleware, myOtherMiddleware],
});
```

The resulting system message will be:
```typescript
new SystemMessage({
content: [
{ type: "text", text: "You are a helpful assistant." },
{ type: "text", text: "Additional context." },
{
type: "text",
text: " More additional context. This will be cached.",
cache_control: { type: "ephemeral", ttl: "5m" },
},
],
});
```

Use @[`SystemMessage.concat`] to preserve cache control metadata or structured content blocks created by other middleware.

:::

## Additional resources

- [Middleware API reference](https://reference.langchain.com/python/langchain/middleware/)
Expand Down
Loading