Skip to content

fix(langchain): neutralize write_todos tool message#37698

Open
Nick Hollon (nick-hollon-lc) wants to merge 2 commits into
masterfrom
nh/neutralize-write-todos-tool-message
Open

fix(langchain): neutralize write_todos tool message#37698
Nick Hollon (nick-hollon-lc) wants to merge 2 commits into
masterfrom
nh/neutralize-write-todos-tool-message

Conversation

@nick-hollon-lc
Copy link
Copy Markdown
Contributor

@nick-hollon-lc Nick Hollon (nick-hollon-lc) commented May 26, 2026

Replaces the write_todos tool message payload from the verbose "Updated todo list to [...]" dump to a neutral "Todo list updated." acknowledgment.

The actual todo state still flows through the todos field of the Command update — only the text content returned to the model changes. No behavior change for downstream consumers reading state.

Why

Inlining the full todo list into the tool message — especially with status: completed entries on the final call — was priming some models (notably Anthropic Sonnet 4.6) to read the tool result as "everything done, wrap up briefly" and emit a content-free recap in the next turn instead of continuing with the substantive answer the user asked for. Reducing the tool message to a plain ack removes that prime.

This is one half of a paired change. The companion prompt updates to WRITE_TODOS_SYSTEM_PROMPT and WRITE_TODOS_TOOL_DESCRIPTION are in #37643 and can land in either order.

Notes for review

  • write_todos and _write_todos both produce the new ack; behavior parity preserved.
  • test_todo_middleware_write_todos_tool_execution no longer asserts on the inline-dump format; it now asserts on the neutral ack string.

Replaces the verbose tool-message dump ("Updated todo list to [...]")
with a neutral "Todo list updated." acknowledgment. The actual state
still lives in the `todos` field of the `Command` update — only the
text payload returned to the model changes.

Why: inlining the full todo list — especially with `status: completed`
entries on the final call — was priming some models to read the tool
result as "everything done, wrap up briefly" and emit a content-free
recap instead of continuing with the substantive answer. Reducing the
tool message to a plain ack removes that prime.
@github-actions github-actions Bot added fix For PRs that implement a fix internal langchain `langchain` package issues & PRs size: S 50-199 LOC labels May 26, 2026
Nick Hollon (nick-hollon-lc) added a commit that referenced this pull request May 26, 2026
Restores the inline-dump tool message ("Updated todo list to [...]")
and its matching test parametrize. The neutralization to
"Todo list updated." is being landed as its own PR (#37698) so that
the prompt-only and tool-message-only halves of the loop-contract fix
can be reviewed independently.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 26, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks
⏩ 13 skipped benchmarks1


Comparing nh/neutralize-write-todos-tool-message (dc13974) with master (d08245f)2

Open in CodSpeed

Footnotes

  1. 13 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (c7858c4) during the generation of this report, so d08245f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

`ruff format` wants the now-shorter message text on a single line.
The previous multi-line layout fit the longer "Updated todo list to
{todos}" payload; "Todo list updated." is short enough to inline.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!!!

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

Labels

fix For PRs that implement a fix internal langchain `langchain` package issues & PRs size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants