traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: TypeError: unsupported operand type(s) for +=: 'async_generator_asend' and 'async_generator_asend'

Open
#1,544 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.4k
Forks
1.1k
Avg merge
8d 14h
Merged PRs (30d)
2

Description

Which component is this bug for?

Langchain Instrumentation

๐Ÿ“œ Description

When using LangChain instrumentation on an AgentExecutor, the error specified in the title occurs.

๐Ÿ‘Ÿ Reproduction steps
  1. Add LangChain Instrumentation to application, either manually or through automated instrumentation.
  2. Make a call to any LangChain AgentExecutor, e.g. in the following LangServe context for a simple chat app:
agent = create_tool_calling_agent(model, tools, agent_prompt)

agent_executor = AgentExecutor(
    agent=agent,
    tools=tools,
)

add_routes(
    app,
    agent_executor.with_types(input_type=Input, output_type=Output),
    path="/chat",
)
  1. By default, stream_runnable is set to True, which then throws the error in the title. Setting stream_runnable to False allows the agent executor to run without issue.
๐Ÿ‘ Expected behavior

No error - AgentExecutor chain should complete without issue, traces should be available at destination specified in instrumentation.

๐Ÿ‘Ž Actual Behavior with Screenshots
image
chat-app-langchain  |   File "/usr/local/lib/python3.11/site-packages/langchain/agents/agent.py", line 560, in aplan
chat-app-langchain  |     final_output += chunk
chat-app-langchain  | TypeError: unsupported operand type(s) for +=: 'async_generator_asend' and 'async_generator_asend'

Which links to the following LangChain agent code: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/agents/agent.py#L560C18-L561C14

๐Ÿค– Python Version

Tried with both 3.11 and 3.12

๐Ÿ“ƒ Provide any additional context for the Bug.

Tried with opentelemetry-instrumentation==0.46b0 and both langchain==0.2.1 and langchain==0.2.2.
Exception is thrown across multiple agent types.

๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?
  • I checked and didn't find similar issue
Are you willing to submit PR?

Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up โ€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with LangChain AgentExecutor and stream_runnable=True, then inspect the linked langchain/agents/agent.py entry point around the aplan failure and the LangChain instrumentation path. Done means the AgentExecutor completes with streaming enabled, no TypeError occurs on Python 3.11 or 3.12, and traces remain available at the configured destination.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.