-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Problem
simple test code,while meeting something worong, when use ChatOpenAI & CodeAgent
from langchain_openai import ChatOpenAI
from smolagents import (
CodeAgent,
LiteLLMModel,
OpenAIModel,
WebSearchTool
)
model = ChatOpenAI(
model_name="Qwen/Qwen3-30B-A3B-thinking-2507",
api_key=os.getenv("MODELSCOPE_API_KEY"),
base_url=os.getenv("MODELSCOPE_BASE_URL"),
temperature=0.2, # 随机性,0-1之间,值越高回复越多样
max_tokens=1024, # 最大生成token数
streaming=True,
)
print(model.invoke("你好"))
agent = CodeAgent(
model=model,
tools=[],
planning_interval=3
)
print(agent.run("你好"))Actual behavior and error logs
print(agent.run("你好"))
^^^^^^^^^^^^^^^
File "D:\miniconda3\envs\agent_mcp_skill\Lib\site-packages\smolagents\agents.py", line 498, in run
steps = list(self._run_stream(task=self.task, max_steps=max_steps, images=images))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\miniconda3\envs\agent_mcp_skill\Lib\site-packages\smolagents\agents.py", line 554, in _run_stream
for element in self._generate_planning_step(
File "D:\miniconda3\envs\agent_mcp_skill\Lib\site-packages\smolagents\agents.py", line 671, in _generate_planning_step
plan_message = self.model.generate(input_messages, stop_sequences=["<end_plan>"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\miniconda3\envs\agent_mcp_skill\Lib\site-packages\langchain_core\language_models\chat_models.py", line 913, in generate
_format_for_tracing(message_list) for message_list in messages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\miniconda3\envs\agent_mcp_skill\Lib\site-packages\langchain_core\language_models\chat_models.py", line 129, in _format_for_tracing
for message in messages:
TypeError: 'ChatMessage' object is not iterable
Expected behavior
A clear and concise description of what you expected to happen.
Environment:
Please complete the following information:
- OS: [e.g., Linux, macOS, Windows]
- Python version: [e.g., 3.10]
- Package version: (output of
pip show smolagents)
Additional context (optional)
Add any other context, screenshots, or links about the bug here.
Checklist
- I have searched the existing issues and have not found a similar bug report.
- I have provided a minimal, reproducible example.
- I have provided the full traceback of the error.
- I have provided my environment details.
- I am willing to work on this issue and submit a pull request. (optional)