diff --git a/src/task.ts b/src/task.ts index e6c0478..8e08637 100644 --- a/src/task.ts +++ b/src/task.ts @@ -54,7 +54,7 @@ export abstract class BaseTask { throw new Error(`clone not implemented for task "${this.name}"`) } - public retryConfig(retryConfig: types.RetryConfig) { + public retryConfig(retryConfig: types.RetryConfig): this { this._retryConfig = retryConfig return this } @@ -82,7 +82,8 @@ export abstract class BaseTask { attemptNumber: 0, metadata: { taskName: this.name, - taskId: this.id + taskId: this.id, + callId: this._agentic.idGeneratorFn() } } diff --git a/src/types.ts b/src/types.ts index b757b43..f866547 100644 --- a/src/types.ts +++ b/src/types.ts @@ -104,6 +104,7 @@ export interface TaskResponseMetadata extends Record { success?: boolean error?: Error numRetries?: number + callId?: string } export interface LLMTaskResponseMetadata< diff --git a/test/calculator.test.ts b/test/calculator.test.ts index f16f39f..a12e0f5 100644 --- a/test/calculator.test.ts +++ b/test/calculator.test.ts @@ -17,8 +17,9 @@ test('CalculatorTool', async (t) => { t.is(res2.result, 1) expectTypeOf(res2.result).toMatchTypeOf() - const { taskId, ...metadata } = res2.metadata + const { taskId, callId, ...metadata } = res2.metadata t.true(typeof taskId === 'string') + t.true(typeof callId === 'string') t.deepEqual(metadata, { success: true, taskName: 'calculator',