File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -956,11 +956,19 @@ def load(
956956
957957 # Fallback: load from agent.json (legacy JSON-based agents)
958958 agent_json_path = agent_path / "agent.json"
959- if not agent_json_path .exists ():
959+ if not agent_json_path .is_file ():
960960 raise FileNotFoundError (f"No agent.py or agent.json found in { agent_path } " )
961961
962962 with open (agent_json_path , encoding = "utf-8" ) as f :
963- graph , goal = load_agent_export (f .read ())
963+ export_data = f .read ()
964+
965+ if not export_data .strip ():
966+ raise ValueError (f"Empty agent export file: { agent_json_path } " )
967+
968+ try :
969+ graph , goal = load_agent_export (export_data )
970+ except json .JSONDecodeError as exc :
971+ raise ValueError (f"Invalid JSON in agent export file: { agent_json_path } " ) from exc
964972
965973 return cls (
966974 agent_path = agent_path ,
You can’t perform that action at this time.
0 commit comments