langchain - ✅(Solved) Fix bug(core): filter_messages docstring example uses wrong parameter names [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#36461Fetched 2026-04-08 02:33:25
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

The docstring example inside filter_messages passes keyword arguments that don't match the actual function signature. Running the example as-is raises a TypeError.

Error Message

TypeError: filter_messages() got an unexpected keyword argument 'incl_names'

Root Cause

The docstring example inside filter_messages passes keyword arguments that don't match the actual function signature. Running the example as-is raises a TypeError.

Fix Action

Fix

Replace the three wrong kwarg names in the example:

WrongCorrect
incl_namesinclude_names
incl_typesinclude_types
excl_idsexclude_ids

I have a fix ready and will open a PR for this.

PR fix notes

PR #36462: fix(core): correct parameter names in filter_messages docstring example

Description (problem / solution / changelog)

Why

The docstring example in filter_messages uses abbreviated kwarg names (incl_names, incl_types, excl_ids) that don't exist on the function signature. The real parameter names are include_names, include_types, and exclude_ids. Anyone copying the example from the docs gets a TypeError with no obvious explanation.

Fixes #36463

What changed

Renamed the three wrong kwarg names in the docstring example to match the actual function signature. No logic touched.

Review notes

Docstring-only change, safe to merge without additional test changes.

Changed files

  • libs/core/langchain_core/messages/utils.py (modified, +3/-3)

Code Example

from langchain_core.messages import (
    filter_messages,
    AIMessage,
    HumanMessage,
    SystemMessage,
)

messages = [
    SystemMessage("you're a good assistant."),
    HumanMessage("what's your name", id="foo", name="example_user"),
    AIMessage("steve-o", id="bar", name="example_assistant"),
]

# Copied directly from the docstring
filter_messages(
    messages,
    incl_names=("example_user", "example_assistant"),
    incl_types=("system",),
    excl_ids=("bar",),
)

---

TypeError: filter_messages() got an unexpected keyword argument 'incl_names'
RAW_BUFFERClick to expand / collapse

Description

The docstring example inside filter_messages passes keyword arguments that don't match the actual function signature. Running the example as-is raises a TypeError.

Location

libs/core/langchain_core/messages/utils.py — the example block inside the filter_messages docstring (~line 875)

Steps to reproduce

from langchain_core.messages import (
    filter_messages,
    AIMessage,
    HumanMessage,
    SystemMessage,
)

messages = [
    SystemMessage("you're a good assistant."),
    HumanMessage("what's your name", id="foo", name="example_user"),
    AIMessage("steve-o", id="bar", name="example_assistant"),
]

# Copied directly from the docstring
filter_messages(
    messages,
    incl_names=("example_user", "example_assistant"),
    incl_types=("system",),
    excl_ids=("bar",),
)

Output:

TypeError: filter_messages() got an unexpected keyword argument 'incl_names'

Expected behavior

The example should work without errors. The actual parameter names on the function are include_names, include_types, and exclude_ids — not the abbreviated versions used in the docstring.

Fix

Replace the three wrong kwarg names in the example:

WrongCorrect
incl_namesinclude_names
incl_typesinclude_types
excl_idsexclude_ids

I have a fix ready and will open a PR for this.

extent analysis

TL;DR

Update the keyword arguments in the filter_messages docstring example to match the actual function signature.

Guidance

  • Verify the function signature of filter_messages to ensure the correct parameter names are used.
  • Replace the incorrect keyword arguments incl_names, incl_types, and excl_ids with the correct ones include_names, include_types, and exclude_ids in the docstring example.
  • Test the updated example to ensure it runs without errors.
  • Consider reviewing other examples or documentation for similar inconsistencies.

Example

filter_messages(
    messages,
    include_names=("example_user", "example_assistant"),
    include_types=("system",),
    exclude_ids=("bar",),
)

Notes

This fix assumes that the actual function signature of filter_messages is correct and the issue is solely with the docstring example.

Recommendation

Apply workaround: Update the docstring example with the correct keyword arguments to prevent TypeError and ensure the example works as expected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The example should work without errors. The actual parameter names on the function are include_names, include_types, and exclude_ids — not the abbreviated versions used in the docstring.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix bug(core): filter_messages docstring example uses wrong parameter names [1 pull requests, 1 comments, 2 participants]