Files
united-workforce/packages/workflow-execute
xingyue 5b7c9b844b fix(engine): abort signal races gen.next() to fix flaky kill test (#209)
Root cause: executeThread awaited gen.next() without racing against
the abort signal. When a workflow bundle awaited a long setTimeout
between yields, the engine could not respond to kill until the
Promise resolved — causing the kill test to flake when the thread
completed before kill arrived.

Fix: Promise.race gen.next() with an abort listener so kill takes
effect immediately, even mid-yield. Also move the bundle's delay
to after the first yield (between planner and coder) to ensure the
thread is killable while running.

Closes #209
2026-05-13 11:31:40 +08:00
..
2026-05-13 03:28:33 +00:00

@uncaged/workflow-execute

Thread engine: execution, fork/GC, extract pipeline, supervisor/worker wiring, and workflow-as-agent.

What This Package Does

It runs WorkflowFn generators against disk-backed threads, integrates CAS and registry-backed extract (createExtract), coordinates LLM tool usage via @uncaged/workflow-reactor, handles fork plans and garbage collection, and exposes workflowAsAgent for nesting workflows.

Key Exports

From src/index.ts:

  • Engine: createWorkflow (engine-local re-export), executeThread, getWorkerHostScriptPath
  • Fork / parse: buildForkPlan, parseThreadDataJsonl, selectForkHistoricalSteps, tryParseRoleStepRecord, tryParseWorkflowResultRecord
  • GC / pause: garbageCollectCas, createThreadPauseGate
  • Engine types: ExecuteThreadIo, ExecuteThreadOptions, ForkHistoricalStep, ForkPlan, GcResult, ParsedThreadStartRecord, PrefilledDiskStep, SupervisorDecision, ThreadPauseGate
  • Extract: buildExtractUserContent, createExtract, extractFunctionToolFromZodSchema, llmErrorToCause, llmExtract, types ExtractFn, ExtractThreadContext, LlmError, LlmExtractArgs
  • Agent composition: workflowAsAgent, WorkflowAsAgentOptions

Dependencies

  • Workspace: @uncaged/workflow-protocol, @uncaged/workflow-runtime, @uncaged/workflow-util, @uncaged/workflow-cas, @uncaged/workflow-reactor, @uncaged/workflow-register
  • npm: yaml
  • Peer: zod ^4

@uncaged/workflow-reactor is used for LLM-backed extract and supervisor flows (extract-fn.ts, supervisor.ts).

Usage

import { executeThread } from "@uncaged/workflow-execute";
// Typical callers are CLI/tests that supply ExecuteThreadIo (paths, CAS, abort, logger, …).