Skip to content

fix(langchain): set name on todoListMiddleware ToolMessages#10706

Merged
Christian Bromann (christian-bromann) merged 3 commits into
langchain-ai:mainfrom
JadenKim-dev:fix/todo-middleware-tool-message-name
May 19, 2026
Merged

fix(langchain): set name on todoListMiddleware ToolMessages#10706
Christian Bromann (christian-bromann) merged 3 commits into
langchain-ai:mainfrom
JadenKim-dev:fix/todo-middleware-tool-message-name

Conversation

@JadenKim-dev

@JadenKim-dev Youngho Kim (JadenKim-dev) commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • todoListMiddleware built ToolMessages without a name field, which Gemini rejects with a 400. Once such a message enters history, every later turn in the session keeps failing.
  • Set name: "write_todos" at both ToolMessage construction sites in todoListMiddleware.ts, aligning with every other ToolMessage producer in the package
  • Added regression coverage on both the success and parallel-rejection paths.

Fixes #10705

Test plan

  • pnpm vitest run src/agents/middleware/tests/todoList.test.ts (7 passed)

The todoListMiddleware built ToolMessages without a `name` field, which
broke agents running against providers (e.g. Google Gemini) that require
`name` on function responses. Once such a ToolMessage entered history,
every subsequent request failed with a 400.

All other ToolMessage producers in this package set `name`; align
todoListMiddleware with that pattern and add regression coverage.
@changeset-bot

changeset-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7f4bb0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
langchain Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

Thank you!

@christian-bromann Christian Bromann (christian-bromann) merged commit 4ecb660 into langchain-ai:main May 19, 2026
38 of 39 checks passed
Christian Bromann (christian-bromann) pushed a commit that referenced this pull request May 21, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @langchain/mistralai@1.1.0

### Minor Changes

- [#10873](#10873)
[`a74d574`](a74d574)
Thanks [@baptistejamin](https://github.com/baptistejamin)! -
chore(mistralai): upgrade to @mistralai/mistralai v2

Also populates `response_metadata.model` on chat completions (was
missing before).

## @langchain/openrouter@0.3.0

### Minor Changes

- [#10666](#10666)
[`2bb55b0`](2bb55b0)
Thanks [@hnustwjj](https://github.com/hnustwjj)! - feat(openrouter):
surface reasoning content as v1 standard content blocks

    `convertOpenRouterResponseToBaseMessage` and
    `convertOpenRouterDeltaToBaseMessageChunk` now copy OpenRouter's
`reasoning` (flat string) and `reasoning_details` (structured array)
fields
onto `additional_kwargs.reasoning_content` /
`additional_kwargs.reasoning_details`.
A new `ChatOpenRouterTranslator` is registered in `@langchain/core`
under
the `"openrouter"` provider key so `AIMessage.contentBlocks` emits
standard
    `{type: "reasoning"}` blocks alongside text and tool calls.

Previously, reasoning text returned by reasoning-capable models routed
through OpenRouter (DeepSeek R1, Minimax M2, Claude extended thinking,
o-series, etc.) was silently dropped: only the `reasoning_tokens` count
was preserved via `usage_metadata`. Consumers using standard content
blocks
(including the frontend agent UI patterns shown in the docs) could not
    display the model's chain of thought.

### Patch Changes

- [#10832](#10832)
[`1b24369`](1b24369)
Thanks [@info-arnav](https://github.com/info-arnav)! - fix(core,
openrouter): make CJS default re-exports callable

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

## langchain@1.4.2

### Patch Changes

- [#10900](#10900)
[`6bbddca`](6bbddca)
Thanks [@christian-bromann](https://github.com/christian-bromann)! -
fix(langchain): unwrap tool message outputs in agent streams

- [#10706](#10706)
[`4ecb660`](4ecb660)
Thanks [@JadenKim-dev](https://github.com/JadenKim-dev)! -
fix(langchain): set name on todoListMiddleware ToolMessages

## @langchain/classic@1.0.34

### Patch Changes

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

## @langchain/core@1.1.48

### Patch Changes

- [#10832](#10832)
[`1b24369`](1b24369)
Thanks [@info-arnav](https://github.com/info-arnav)! - fix(core,
openrouter): make CJS default re-exports callable

- [#10666](#10666)
[`2bb55b0`](2bb55b0)
Thanks [@hnustwjj](https://github.com/hnustwjj)! - feat(openrouter):
surface reasoning content as v1 standard content blocks

    `convertOpenRouterResponseToBaseMessage` and
    `convertOpenRouterDeltaToBaseMessageChunk` now copy OpenRouter's
`reasoning` (flat string) and `reasoning_details` (structured array)
fields
onto `additional_kwargs.reasoning_content` /
`additional_kwargs.reasoning_details`.
A new `ChatOpenRouterTranslator` is registered in `@langchain/core`
under
the `"openrouter"` provider key so `AIMessage.contentBlocks` emits
standard
    `{type: "reasoning"}` blocks alongside text and tool calls.

Previously, reasoning text returned by reasoning-capable models routed
through OpenRouter (DeepSeek R1, Minimax M2, Claude extended thinking,
o-series, etc.) was silently dropped: only the `reasoning_tokens` count
was preserved via `usage_metadata`. Consumers using standard content
blocks
(including the frontend agent UI patterns shown in the docs) could not
    display the model's chain of thought.

- [#10918](#10918)
[`3999fab`](3999fab)
Thanks [@christian-bromann](https://github.com/christian-bromann)! -
fix(openai): stream custom tool calls through Responses API chunks

## @langchain/aws@1.3.9

### Patch Changes

- [#10743](#10743)
[`6e4337f`](6e4337f)
Thanks [@Zelys-DFKH](https://github.com/Zelys-DFKH)! - fix(aws): add
claude-haiku-4 to supportedToolChoiceValuesForModel

## @langchain/deepseek@1.0.27

### Patch Changes

- [#10747](#10747)
[`78e642f`](78e642f)
Thanks [@neo1027144-creator](https://github.com/neo1027144-creator)! -
feat(deepseek): add DeepSeek V4 Flash and V4 Pro model profiles

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

## @langchain/fireworks@0.1.5

### Patch Changes

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

## @langchain/ibm@0.1.1

### Patch Changes

- [#10721](#10721)
[`20f27df`](20f27df)
Thanks [@peterzaccha](https://github.com/peterzaccha)! -
fix(langchain-ibm): handle API errors in streaming responses

## @langchain/neo4j@0.1.6

### Patch Changes

-   Updated dependencies \[]:
    -   @langchain/classic@1.0.34

## @langchain/openai@1.4.7

### Patch Changes

- [#10918](#10918)
[`3999fab`](3999fab)
Thanks [@christian-bromann](https://github.com/christian-bromann)! -
fix(openai): stream custom tool calls through Responses API chunks

- [#10791](#10791)
[`fce9ab4`](fce9ab4)
Thanks [@Genmin](https://github.com/Genmin)! - fix(openai): preserve
top-level Responses API ids on AI messages

## @langchain/together-ai@0.1.5

### Patch Changes

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

## @langchain/xai@1.3.19

### Patch Changes

- Updated dependencies
\[[`3999fab`](3999fab),
[`fce9ab4`](fce9ab4)]:
    -   @langchain/openai@1.4.7

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

todoListMiddleware produces ToolMessages without name, breaking Gemini (400 InvalidArgument)

2 participants