Skip to content

Conversation

@christian-bromann
Copy link
Member

@christian-bromann christian-bromann commented Nov 22, 2025

Some further improvements on:

  • custom state schema: more details on how this is useful
  • custom context schema: new section (was not documented before)
  • adding references to published middleware videos:
    Screenshot 2025-11-22 at 3 22 10 PM
  • (js only): add docs on public/private state
  • (js only): fix example for jump to section
  • (js only): improvements to openAIModerationMiddleware

@github-actions github-actions bot added langchain For docs changes to LangChain oss labels Nov 22, 2025
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-cbimpr-1763851614-4162242

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-cbimpr-1763852422-6d89282

@github-actions github-actions bot added python For content related to the Python version of LangChain projects docs-infra labels Nov 22, 2025
@christian-bromann christian-bromann changed the title fix: agent jump example, enhanced state docs for JS fix: agent jump example, enhanced state docs for JS and more Nov 22, 2025
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-cbimpr-1763853024-4a27815

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-cbimpr-1763853761-497e4b2

Comment on lines +851 to +856
beforeModel: {
canJumpTo: ["end"],
hook: (state) => {
if (state.messages.at(-1)?.content.includes("BLOCKED")) {
return {
messages: [new AIMessage("I cannot respond to that request.")],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
beforeModel: {
canJumpTo: ["end"],
hook: (state) => {
if (state.messages.at(-1)?.content.includes("BLOCKED")) {
return {
messages: [new AIMessage("I cannot respond to that request.")],
afterModel: {
canJumpTo: ["end"],
hook: (state) => {
if (state.messages.at(-1)?.content.includes("BLOCKED")) {
return {
messages: [
...state.messages.slice(0, -1),
{
...state.messages.at(-1),
content: "I cannot respond to that request."
}
],

Copy link
Contributor

@mcavdar mcavdar Nov 23, 2025

Choose a reason for hiding this comment

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

It might be better if we had an afterModel example that updates the agent message, either here or in the guardrails docs. What do you think?

Edit: Actually, we already have this in guardrails, but using afterAgent. Having another example with afterModel still makes sense.

```

const result = await agent.invoke({
messages: "Hello, world! BLOCKED"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
messages: "Hello, world! BLOCKED"
messages: "Hello, world! Return a message that contains BLOCKED"

Base automatically changed from sr/changelog-approach-instead to main November 23, 2025 22:29
@christian-bromann
Copy link
Member Author

Closing in favor of #1608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-infra langchain For docs changes to LangChain oss python For content related to the Python version of LangChain projects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants