Update "Example B" in Reducers doc #67

Closed
opened 2026-02-15 17:15:22 -05:00 by yindo · 1 comment
Owner

Originally created by @johisa on GitHub (Aug 23, 2024).

https://langchain-ai.github.io/langgraphjs/concepts/low_level/#reducers

Example reducer is applied to foo in the code snippet, but it's mixing number with string[]

const State = Annotation.Root({
  foo: Annotation<number>({
    reducer: (state: string[], update: string[]) => state.concat(update),
    default: () => [],
  }),
  bar: Annotation<string[]>,
})

Also in the following text it's the bar prop that implicitly had the custom reducer:

If the second node returns{ bar: ["bye"] } then the State would then be { foo: 2, bar: ["hi", "bye"] }. Notice here that the bar key > is updated by concatenating the two arrays together.

It seems to me that the intention was to apply the reducer to bar, so the code snippet should reflect this.

I can give it a try and update this if it's okay with the maintainers.

Originally created by @johisa on GitHub (Aug 23, 2024). https://langchain-ai.github.io/langgraphjs/concepts/low_level/#reducers Example reducer is applied to `foo` in the code snippet, but it's mixing `number` with `string[]` ``` const State = Annotation.Root({ foo: Annotation<number>({ reducer: (state: string[], update: string[]) => state.concat(update), default: () => [], }), bar: Annotation<string[]>, }) ``` Also in the following text it's the `bar` prop that implicitly had the custom reducer: > If the second node returns{ bar: ["bye"] } then the State would then be { foo: 2, bar: ["hi", "bye"] }. Notice here that the bar key > is updated by concatenating the two arrays together. It seems to me that the intention was to apply the reducer to `bar`, so the code snippet should reflect this. I can give it a try and update this if it's okay with the maintainers.
yindo closed this issue 2026-02-15 17:15:22 -05:00
Author
Owner

@bracesproul commented on GitHub (Aug 23, 2024):

thank you for flagging this, I quickly put up a PR to fix.

@bracesproul commented on GitHub (Aug 23, 2024): thank you for flagging this, I quickly put up a PR to fix.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#67