Skip to content

[Agent] JSON Serialization Error in DataScienceAssistant: "Object of type CodeCell is not JSON serializable" #640

@huhao0926

Description

@huhao0926

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have read and followed the docs & demos and still think this is a bug
  • I am confident that the issue is with ms-agent (not my code, or another library in the ecosystem)

What happened + What you expected to happen

Branch/Version: v0.7.2 (from modelscope/ms-agent repository)

Component: DataScienceAssistant (executing decompose_task)

Error Log:
2025-07-11 16:52:08.346 - modelscope-agent - ERROR - | message: decompose task error: Object of type CodeCell is not JSON serializable

Trigger: Running the data_science_assistant.ipynb example notebook
refer: https://github.com/modelscope/ms-agent/blob/release/0.8/examples/agents/data_science_assistant.ipynb

Versions / Dependencies

Branch/Version: v0.7.2

Reproduction script

from modelscope_agent.agents.data_science_assistant import DataScienceAssistant
from modelscope_agent.tools.metagpt_tools.tool_recommend import TypeMatchToolRecommender

llm_config = {
'model': 'Qwen/Qwen3-8B',
'model_server': 'openai',
'api_base': 'https://api.siliconflow.cn/v1',
'api_key': '硅基流动api_key'
}
tool_recommender = TypeMatchToolRecommender(tools=[""])
ds_assistant = DataScienceAssistant(llm=llm_config, tool_recommender=tool_recommender)
question = "This is a medical dataset with over fifty anonymized health characteristics linked to three age-related conditions. Your goal is to predict whether a subject has or has not been diagnosed with one of these conditions. The target column is Class. Perform data analysis, data preprocessing, feature engineering, and modeling to predict the target. Report F1 Score on the eval data. Train data path: ‘/Users/hao0926.hu/pyproject/data_interpreter/di_dataset/ml_benchmark/04_titanic/split_train.csv', eval data path: ‘/Users/hao0926.hu/pyproject/data_interpreter/di_dataset/ml_benchmark/04_titanic/split_eval.csv' . It is only necessary to provide the relevant code, without actually running it to verify whether it can run successfully"
responses = ds_assistant.run(question)
for res in responses:
print(res)

Issue Severity

None

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions