You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The result field of above MemoryRecord is a coroutine object, which cause python abort abnormally. Here is the complete tracebac:
Traceback (most recent call last):
File "test.py", line 58, in <module>
loop.run_until_complete(main())
File "/opt/homebrew/Cellar/[email protected]/3.12.10/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "test.py", line 52, in main
assistant_response = agent.step(user_msg)
^^^^^^^^^^^^^^^^^^^^
File "venv/lib/python3.12/site-packages/camel/agents/chat_agent.py", line 628, in step
self._execute_tool(tool_call_request)
File "venv/lib/python3.12/site-packages/camel/agents/chat_agent.py", line 1295, in _execute_tool
return self._record_tool_calling(func_name, args, result, tool_call_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv/lib/python3.12/site-packages/camel/agents/chat_agent.py", line 1351, in _record_tool_calling
self.update_memory(
File "venv/lib/python3.12/site-packages/camel/agents/chat_agent.py", line 347, in update_memory
self.memory.write_record(
File "venv/lib/python3.12/site-packages/camel/memories/base.py", line 46, in write_record
self.write_records([record])
File "venv/lib/python3.12/site-packages/camel/memories/agent_memories.py", line 83, in write_records
self._chat_history_block.write_records(records)
File "venv/lib/python3.12/site-packages/camel/memories/blocks/chat_history_block.py", line 162, in write_records
stored_records.append(record.to_dict())
^^^^^^^^^^^^^^^^
File "venv/lib/python3.12/site-packages/camel/memories/records.py", line 90, in to_dict
**asdict(self.message),
^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.10/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dataclasses.py", line 1329, in asdict
return _asdict_inner(obj, dict_factory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.10/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dataclasses.py", line 1339, in _asdict_inner
f.name: _asdict_inner(getattr(obj, f.name), dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.10/Frameworks/Python.framework/Versions/3.12/lib/python3.12/dataclasses.py", line 1386, in _asdict_inner
return copy.deepcopy(obj)
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.10/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 151, in deepcopy
rv = reductor(4)
^^^^^^^^^^^
TypeError: cannot pickle 'coroutine' object
minimal viable code
fromtypingimportListfromcamel.modelsimportModelFactoryfromcamel.typesimportModelPlatformType, ModelTypefromcamel.types.enumsimportModelTypefromcamel.agentsimportChatAgentimportasynciofrommcp.typesimportCallToolResultfromcamel.toolkits.mcp_toolkitimportMCPToolkit, MCPClientasyncdefmain():
# Initialize the MCPToolkit with your configuration filemcp_toolkit=MCPToolkit(config_path="./mcp_servers_config.json")
awaitmcp_toolkit.connect()
# Get MCP toolstools= [*mcp_toolkit.get_tools()]
# Optional: Print available tool namesiftools:
print(f"Available tools: {[tool.get_function_name() fortoolintools]}")
else:
print("No tools available from connected servers.")
ollama_model=ModelFactory.create(
model_platform=ModelPlatformType.OLLAMA,
model_type="qwq:32b",
url="http://localhost:11434/v1", # Optionalmodel_config_dict={"temperature": 0.4},
)
agent_sys_msg= (
"You are a helpful assistant. Always use the provided external tools for filesystem operations ""Also remember to use the tools to answer questions about the filesystem. Always use the tools ""Make sure to keep the messages short and to the point so that tokens are not wasted. ""when asked, rather than relying on your internal knowledge. Ensure that your final answer does not ""end with any trailing whitespace."
)
agent=ChatAgent(agent_sys_msg, model=ollama_model, token_limit=32768, tools=tools)
user_msg="answer the following question using the tools: read all papers and summarize them"assistant_response=agent.step(user_msg)
print(assistant_response.msg.content)
if__name__=="__main__":
loop=asyncio.new_event_loop()
loop.run_until_complete(main())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am testing camel-ai with MCP supports, and I found it completely unusable because some async issue.
When I run
agent.step()
, it call MCP tools which are async tools, and it tried dumping the following MemoryRecord with pickle.The
result
field of above MemoryRecord is a coroutine object, which cause python abort abnormally. Here is the complete tracebac:minimal viable code
mcp_servers_config.json
FYI my uv pyproject.toml is like this. I am using camel-ai 0.2.45, which is new enough.
Beta Was this translation helpful? Give feedback.
All reactions