@@ -205,18 +205,22 @@ async def cancel_task(
205205 self ,
206206 task_id : str | None = None ,
207207 task_name : str | None = None ,
208+ agent_id : str | None = None ,
209+ agent_name : str | None = None ,
208210 trace_id : str | None = None ,
209211 parent_span_id : str | None = None ,
210212 start_to_close_timeout : timedelta = timedelta (seconds = 5 ),
211213 heartbeat_timeout : timedelta = timedelta (seconds = 5 ),
212214 retry_policy : RetryPolicy = DEFAULT_RETRY_POLICY ,
213215 ) -> Task :
214216 """
215- Cancel a task.
217+ Cancel a task by sending cancel request to the agent that owns the task .
216218
217219 Args:
218- task_id: The ID of the task to cancel.
219- task_name: The name of the task to cancel.
220+ task_id: ID of the task to cancel.
221+ task_name: Name of the task to cancel.
222+ agent_id: ID of the agent that owns the task.
223+ agent_name: Name of the agent that owns the task.
220224 trace_id: The trace ID for the task.
221225 parent_span_id: The parent span ID for the task.
222226 start_to_close_timeout: The start to close timeout for the task.
@@ -225,13 +229,19 @@ async def cancel_task(
225229
226230 Returns:
227231 The task entry.
232+
233+ Raises:
234+ ValueError: If neither agent_name nor agent_id is provided,
235+ or if neither task_name nor task_id is provided
228236 """
229237 if in_temporal_workflow ():
230238 return await ActivityHelpers .execute_activity (
231239 activity_name = ACPActivityName .TASK_CANCEL ,
232240 request = TaskCancelParams (
233241 task_id = task_id ,
234242 task_name = task_name ,
243+ agent_id = agent_id ,
244+ agent_name = agent_name ,
235245 trace_id = trace_id ,
236246 parent_span_id = parent_span_id ,
237247 ),
@@ -244,6 +254,8 @@ async def cancel_task(
244254 return await self ._acp_service .task_cancel (
245255 task_id = task_id ,
246256 task_name = task_name ,
257+ agent_id = agent_id ,
258+ agent_name = agent_name ,
247259 trace_id = trace_id ,
248260 parent_span_id = parent_span_id ,
249261 )
0 commit comments