@@ -97,21 +97,19 @@ def get_artifact_text(artifact: Artifact, delimiter: str = '\n') -> str:
9797# --- Task Helpers ---
9898
9999
100- def new_task_from_request ( request : Message ) -> Task :
100+ def new_task_from_user_message ( user_message : Message ) -> Task :
101101 """Creates a new Task object from an initial user message."""
102- if not request .role :
103- raise TypeError ('Message role cannot be None' )
104- if not request .parts :
102+ if not user_message .parts :
105103 raise ValueError ('Message parts cannot be empty' )
106- for part in request .parts :
104+ for part in user_message .parts :
107105 if part .HasField ('text' ) and not part .text :
108106 raise ValueError ('Message.text cannot be empty' )
109107
110108 return Task (
111109 status = TaskStatus (state = TaskState .TASK_STATE_SUBMITTED ),
112- id = request .task_id or str (uuid .uuid4 ()),
113- context_id = request .context_id or str (uuid .uuid4 ()),
114- history = [request ],
110+ id = user_message .task_id or str (uuid .uuid4 ()),
111+ context_id = user_message .context_id or str (uuid .uuid4 ()),
112+ history = [user_message ],
115113 )
116114
117115
@@ -123,13 +121,12 @@ def new_task(
123121 history : list [Message ] | None = None ,
124122) -> Task :
125123 """Creates a Task object with a specified status."""
126- if not artifacts or not all (isinstance (a , Artifact ) for a in artifacts ):
127- raise ValueError (
128- 'artifacts must be a non-empty list of Artifact objects'
129- )
130124
131125 if history is None :
132126 history = []
127+ if artifacts is None :
128+ artifacts = []
129+
133130 return Task (
134131 status = TaskStatus (state = state ),
135132 id = task_id ,
0 commit comments