Skip to content

LangGraph: TypeError "FunctionWrapperBase missing required argument 'wrapper'" from weakref.WeakMethod after create_agent instrumentation in 13.0.1 #1739

@bhalani97

Description

@bhalani97

Summary

After upgrading from newrelic==13.0.0 to newrelic==13.0.1, every LangGraph streaming turn that uses langchain.create_agent (in our case via deepagents.create_deep_agent) crashes after the first or second model call with:

TypeError: FunctionWrapperBase() missing required argument 'wrapper' (pos 3)

The agent is retried three times by our stream handler, each retry fails identically, and the client receives an empty answer. Downgrading to newrelic==13.0.0 makes the bug disappear immediately with no other code or configuration change.

The regression appears to have been introduced by PR #1733 (LangChain & LangGraph Transaction Context Propagation, merged 2026-05-21, shipped in 13.0.1).

Traceback

TypeError: FunctionWrapperBase() missing required argument 'wrapper' (pos 3)

  File ".../langchain_core/runnables/base.py", line 1516, in astream_events
    async for event in event_stream:
  File ".../langchain_core/tracers/event_stream.py", line 1100, in _astream_events_implementation_v2
    await task
  File ".../langchain_core/tracers/event_stream.py", line 1055, in consume_astream
    async for _ in event_streamer.tap_output_aiter(run_id, stream):
  File ".../langchain_core/tracers/event_stream.py", line 222, in tap_output_aiter
    async for chunk in output:
  File ".../langgraph/pregel/main.py", line 2997, in astream
    async for _ in runner.atick(
  File ".../langgraph/pregel/_runner.py", line 349, in atick
    self.submit()(
    ^^^^^^^^^^^^^
  File ".../python3.11/weakref.py", line 73, in __call__
    return self._meth_type(func, obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: FunctionWrapperBase() missing required argument 'wrapper' (pos 3)

The crash consistently fires immediately after a TodoListMiddleware.after_model graph event, on the second model step.

Suspected root cause

LangGraph's runner stores a weakref.WeakMethod over bound methods of the compiled agent. WeakMethod.__call__ does self._meth_type(func, obj) (two positional args), where _meth_type is normally types.MethodType. After PR #1733 the create_agent return value is wrapped in AgentObjectProxy (a wrapt.ObjectProxy), so the bound method's class is now wrapt._FunctionWrapperBase, whose __init__ requires wrapper as the third positional argument — hence missing required argument 'wrapper' (pos 3).

In 13.0.0 the corresponding wrapping is shaped differently and this collision does not occur.

Environment

Package Version
newrelic (broken) 13.0.1
newrelic (working) 13.0.0
Python 3.11.13 (also reproduced on 3.13)
OS macOS 14 / Amazon Linux 2023
langchain 1.2.15
langchain-core 1.3.2
langgraph 1.1.9
langgraph-prebuilt 1.0.11
deepagents 0.5.3
wrapt 1.17.3

Started via NEW_RELIC_CONFIG_FILE=... newrelic-admin run-program python app.py. AI monitoring enabled (default).

Minimal repro

# repro.py
import asyncio
from deepagents import create_deep_agent

agent = create_deep_agent(
    model="anthropic:claude-sonnet-4-5",  # any tool-calling model
    tools=[],
)

async def main():
    # The second turn reliably triggers the crash.
    for _ in range(2):
        async for _ in agent.astream_events(
            {"messages": [{"role": "user", "content": "say hi"}]},
            version="v2",
        ):
            pass

asyncio.run(main())
# newrelic.ini
[newrelic]
app_name = repro
license_key = 0000000000000000000000000000000000000000
monitor_mode = false
log_level = info
pip install "newrelic==13.0.1" "langchain==1.2.15" "langchain-core==1.3.2" \
            "langgraph==1.1.9" "langgraph-prebuilt==1.0.11" \
            "deepagents==0.5.3" "langchain-anthropic"

# Reproduces:
NEW_RELIC_CONFIG_FILE=./newrelic.ini newrelic-admin run-program python repro.py

# Does NOT reproduce:
pip install "newrelic==13.0.0"
NEW_RELIC_CONFIG_FILE=./newrelic.ini newrelic-admin run-program python repro.py

Workaround

Pinning newrelic==13.0.0 restores correct behavior with no other changes.

Asks

  1. Confirm whether AgentObjectProxy should be returning a non-wrapt-wrapped object on the public method path that LangGraph stores in weakref.WeakMethod.
  2. Consider releasing a 13.0.2 that either uses a non-wrapt proxy, exposes the underlying bound method to WeakMethod, or otherwise guards against the collision.
  3. In the interim, document this incompatibility in the v13.0.1 release notes so other LangGraph / deepagents users can pin.

Happy to test a patched build — the failure is 100% reproducible on every run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect or flawed agent behavior.needs-triageRequires initial review by maintainers.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions