From 8d5b97c67e20b3330d26446879746cd08eb8299f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Wed, 6 May 2026 10:23:25 +0000 Subject: [PATCH] feat: add threadId to ThreadContext and WorkflowFnOptions Agentic roles can now access ctx.threadId to query thread details via uncaged-workflow CLI for richer context. --- packages/workflow/src/create-role-moderator.ts | 1 + packages/workflow/src/types.ts | 2 ++ packages/workflow/src/worker.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/workflow/src/create-role-moderator.ts b/packages/workflow/src/create-role-moderator.ts index 490c873..a5ed1af 100644 --- a/packages/workflow/src/create-role-moderator.ts +++ b/packages/workflow/src/create-role-moderator.ts @@ -54,6 +54,7 @@ export function createRoleModerator( } const ctx: ThreadContext = { + threadId: options.threadId, start, steps, }; diff --git a/packages/workflow/src/types.ts b/packages/workflow/src/types.ts index b8c1736..0dc627f 100644 --- a/packages/workflow/src/types.ts +++ b/packages/workflow/src/types.ts @@ -26,6 +26,7 @@ export type ThreadInput = { /** Options passed to a workflow bundle's `run` export (engine-provided). */ export type WorkflowFnOptions = { + threadId: string; isDryRun: boolean; maxRounds: number; }; @@ -57,6 +58,7 @@ export type RoleStep = { /** Thread-scoped context passed to roles and moderator. */ export type ThreadContext = { + threadId: string; start: StartStep; steps: RoleStep[]; }; diff --git a/packages/workflow/src/worker.ts b/packages/workflow/src/worker.ts index 0261184..c0e6f9c 100644 --- a/packages/workflow/src/worker.ts +++ b/packages/workflow/src/worker.ts @@ -136,7 +136,7 @@ function parseRunControlPayload(rec: Record): RunCommand | null threadId, workflowName, prompt, - options: { isDryRun, maxRounds }, + options: { threadId, isDryRun, maxRounds }, steps: parsedSteps.steps, stepTimestamps: parsedSteps.stepTimestamps, forkSourceThreadId,