AgentOps-AI / AgentOps-AI/agentops

[Bug]:The error "unexpected keyword argument 'config'" occurred when integrating langgraph

Abierto
#1,295 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
5.8k
Forks
619
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Contact Details

_No response_

### 📦 Package Version

0.4.21

### 🎞️ Framework Version

langchain 0.3.25 langchain-anthropic 0.3.15 langchain-classic 1.0.0 langchain-community 0.3.19 langchain-core 0.3.81 langchain-experimental 0.3.4 langchain-huggingface 1.1.0 langchain-mcp-adapters 0.1.0 langchain-openai 0.3.23 langchain-text-splitters 0.3.8 langfuse 3.10.1 langgraph 0.4.10 langgraph-checkpoint 2.0.26 langgraph-prebuilt 0.2.3 langgraph-sdk 0.1.69

### 🔎 Describe the Bug

My example:
import agentops
import asyncio
from typing import Annotated, Literal, TypedDict

from langchain_core.runnables import RunnableConfig
from langgraph.graph import StateGraph, END
from langgraph.graph.message import add_messages
from langchain_openai import ChatOpenAI
from pydantic import SecretStr

# Initialize AgentOps
agentops.init(api_key="66c3a0e1-cee9-4fe9-8dfd-6ba819bf5923")

# Define your graph state
class AgentState(TypedDict):
messages: Annotated[list, add_messages]

# Create your LLM
model = ChatOpenAI(
model="Qwen3-32B-23-new", # 根据你的实际模型调整
base_url="http://10.19.154.22:38009/v1", # 本地模型服务地址
api_key=SecretStr("sk-aaaa"), # 如果服务不需要认证,可以随意填写
temperature=0.7,
max_tokens=1000
)

def agent_node(state: AgentState, config: RunnableConfig):
messages = state["messages"]
response = model.invoke(messages, config=config)
return {"messages": [response]}

# Build the graph
workflow = StateGraph(AgentState)
workflow.add_node("agent", agent_node)
workflow.set_entry_point("agent")
workflow.add_edge("agent", END)

# Compile the graph
app = workflow.compile()

# 使用 astream 方式处理
async def process_stream():
async for chunk in app.astream({"messages": [{"role": "user", "content": "Hello!"}]}):
print(chunk)

# 运行异步函数
if __name__ == "__main__":
asyncio.run(process_stream())

error info:
D:\software\python\envs\py312\Scripts\python.exe E:\workspace\pycharmws\test\agentops\example2.py
🖇 AgentOps: Session Replay for default trace: https://app.agentops.ai/sessions?trace_id=98034f9f6512bdf1083f24ed4316fdba
🖇 AgentOps: You're on the agentops free plan 🤔
--- Logging error ---
Traceback (most recent call last):
File "D:\software\python\Python312\Lib\logging\__init__.py", line 1163, in emit
stream.write(msg + self.terminator)
UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f914' in position 66: illegal multibyte sequence
Call stack:
File "D:\software\python\Python312\Lib\threading.py", line 1032, in _bootstrap
self._bootstrap_inner()
File "D:\software\python\Python312\Lib\threading.py", line 1075, in _bootstrap_inner
self.run()
File "D:\software\python\Python312\Lib\threading.py", line 1012, in run
self._target(*self._args, **self._kwargs)
File "D:\software\python\envs\py312\Lib\site-packages\agentops\client\client.py", line 131, in run_async_auth
asyncio.run(self._fetch_auth_async(api_key))
File "D:\software\python\Python312\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
File "D:\software\python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
File "D:\software\python\Python312\Lib\asyncio\base_events.py", line 678, in run_until_complete
self.run_forever()
File "D:\software\python\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
super().run_forever()
File "D:\software\python\Python312\Lib\asyncio\base_events.py", line 645, in run_forever
self._run_once()
File "D:\software\python\Python312\Lib\asyncio\base_events.py", line 1999, in _run_once
handle._run()
File "D:\software\python\Python312\Lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "D:\software\python\envs\py312\Lib\site-packages\agentops\client\client.py", line 99, in _fetch_auth_async
response = await self.api.v3.fetch_auth_token(api_key)
File "D:\software\python\envs\py312\Lib\site-packages\agentops\client\api\versions\v3.py", line 57, in fetch_auth_token
logger.info(
Message: "You're on the agentops free plan 🤔"
Arguments: ()
Traceback (most recent call last):
File "E:\workspace\pycharmws\test\agentops\example2.py", line 49, in
asyncio.run(process_stream())
File "D:\software\python\Python312\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "D:\software\python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\Python312\Lib\asyncio\base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "E:\workspace\pycharmws\test\agentops\example2.py", line 44, in process_stream
async for chunk in app.astream({"messages": [{"role": "user", "content": "Hello!"}]}):
File "D:\software\python\envs\py312\Lib\site-packages\langgraph\pregel\__init__.py", line 2655, in astream
async for _ in runner.atick(
File "D:\software\python\envs\py312\Lib\site-packages\langgraph\pregel\runner.py", line 295, in atick
await arun_with_retry(
File "D:\software\python\envs\py312\Lib\site-packages\langgraph\pregel\retry.py", line 136, in arun_with_retry
return await task.proc.ainvoke(task.input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\envs\py312\Lib\site-packages\langgraph\utils\runnable.py", line 672, in ainvoke
input = await asyncio.create_task(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\envs\py312\Lib\site-packages\langgraph\utils\runnable.py", line 440, in ainvoke
ret = await self.afunc(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\envs\py312\Lib\site-packages\langchain_core\runnables\config.py", line 611, in run_in_executor
return await asyncio.get_running_loop().run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\Python312\Lib\concurrent\futures\thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\software\python\envs\py312\Lib\site-packages\langchain_core\runnables\config.py", line 602, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: agent_node() got an unexpected keyword argument 'config'
During task with name 'agent' and id '55afc527-f2be-f645-f8de-8a7f40b42632'
🖇 AgentOps: Session Replay for default.session trace: https://app.agentops.ai/sessions?trace_id=98034f9f6512bdf1083f24ed4316fdba

Process finished with exit code 1

### 🤝 Contribution

- [ ] Yes, I'd be happy to submit a pull request with these changes.
- [ ] I need some guidance on how to contribute.
- [x] I'd prefer the AgentOps team to handle this update.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.