* Request a running background task to stop. Sends SIGTERM with a * grace period (handled by the core BPM); subscribers receive a * `background.task.terminated` event when the kill settles. Calls * for unknown or already-terminal task ids are no-ops at the core * level — this method does
(
taskId: string,
options: { reason?: string } = {},
)
| 344 | * level — this method does not throw in those cases. |
| 345 | */ |
| 346 | async stopBackgroundTask( |
| 347 | taskId: string, |
| 348 | options: { reason?: string } = {}, |
| 349 | ): Promise<void> { |
| 350 | this.ensureOpen(); |
| 351 | const trimmedTaskId = normalizeRequiredString( |
| 352 | taskId, |
| 353 | 'Task id cannot be empty', |
| 354 | ErrorCodes.BACKGROUND_TASK_ID_EMPTY, |
| 355 | ); |
| 356 | await this.rpc.stopBackgroundTask({ |
| 357 | sessionId: this.id, |
| 358 | taskId: trimmedTaskId, |
| 359 | reason: options.reason, |
| 360 | }); |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Detach a running foreground task so the current tool call can return while |
no test coverage detected