DefaultWorkflowRuntime with the canonical executor graph, behaviour handlers,
loop strategies, and command handlers.
Required collaborators are the WorkflowRepository, WorkflowStateRepository,
WorkflowEventLog, and a pre-built AgentInvoker. FileSink, ShellCommandRunner,
Clock, LoopEvaluator, and RunContextManager default when omitted.
Public construction path for WorkflowRuntime;
DefaultWorkflowRuntime constructors stay package-private because they accept non-exported execution types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionagentInvoker(AgentInvoker value) Configures theAgentInvokerused for agent and SPAR steps (for example from framework integration or constructed explicitly by the embedding application).artifactValidators(List<ArtifactValidator> value) build()Validates required dependencies, wires executors and handlers, and returns a runnableWorkflowRuntime.Configures the clock used for timestamps on state updates and events.contextAggregators(List<ContextAggregator> value) eventRecorder(EventRecorder value) Configures the sharedEventRecorderused by command handlers, loop strategies, and step executors.Configures whereCreateFileCommandcontent is written.Configures the run-scoped store that captures emittedCREATE_FILEbytes for in-process artifact validation.loopEvaluator(LoopEvaluator value) Configures the evaluator loop strategy dependency.maxNestingDepth(int value) Configures the maximum nested workflow depth passed toExecutionContext.Configures the store used to resume approval-pending tool invocations.Configures the resolver used to satisfy declaredrequirementsat the run-start checkpoint and at deferred first use.Configures correlation scope hooks for each drive.Configures the control interceptor fired before main execution and before each LLM call.Configures execution ofRunCommandCommandshell strings.Configures the optional tool-execution chokepoint.workflowEventLog(WorkflowEventLog value) Configures the append-only event log receivingWorkflowEventinstances.Configures the workflow definition source.Configures persistence forWorkflowStatebetween drives.
-
Constructor Details
-
WorkflowRuntimeBuilder
public WorkflowRuntimeBuilder()
-
-
Method Details
-
workflowRepository
Configures the workflow definition source.- Parameters:
value- repository instance- Returns:
- this builder
-
workflowStateRepository
Configures persistence forWorkflowStatebetween drives.- Parameters:
value- repository instance- Returns:
- this builder
-
workflowEventLog
Configures the append-only event log receivingWorkflowEventinstances.- Parameters:
value- event log instance- Returns:
- this builder
-
clock
Configures the clock used for timestamps on state updates and events. Defaults toClock.systemUTC()when omitted.- Parameters:
value- clock instance- Returns:
- this builder
-
fileSink
Configures whereCreateFileCommandcontent is written.- Parameters:
value- file sink instance- Returns:
- this builder
-
shellCommandRunner
Configures execution ofRunCommandCommandshell strings.- Parameters:
value- shell runner instance- Returns:
- this builder
-
loopEvaluator
Configures the evaluator loop strategy dependency. Defaults toDefaultLoopEvaluatorwhen omitted.- Parameters:
value- loop evaluator instance- Returns:
- this builder
-
maxNestingDepth
Configures the maximum nested workflow depth passed toExecutionContext.- Parameters:
value- maximum nesting depth (at least 1)- Returns:
- this builder
-
runContextManager
Configures correlation scope hooks for each drive. Defaults toRunContextManager.NO_OPwhen omitted.- Parameters:
value- run context manager instance- Returns:
- this builder
-
agentInvoker
Configures theAgentInvokerused for agent and SPAR steps (for example from framework integration or constructed explicitly by the embedding application).- Parameters:
value- invoker instance- Returns:
- this builder
-
eventRecorder
Configures the sharedEventRecorderused by command handlers, loop strategies, and step executors. When omitted,build()constructs one fromworkflowEventLog(WorkflowEventLog)andclock(Clock).- Parameters:
value- event recorder instance- Returns:
- this builder
-
toolExecutionService
Configures the optional tool-execution chokepoint. When set, aToolInvocationCommandHandleris registered soTOOL_INVOCATIONcommands are dispatched, and tool-approval resume becomes available; when omitted, tool invocation is unavailable and behaviour is unchanged.- Parameters:
value- tool execution service instance- Returns:
- this builder
-
pendingToolInvocationStore
Configures the store used to resume approval-pending tool invocations. Required alongsidetoolExecutionService(ToolExecutionService)forcontinueAfterToolApprovalto function.- Parameters:
value- pending tool invocation store instance- Returns:
- this builder
-
requirementResolver
Configures the resolver used to satisfy declaredrequirementsat the run-start checkpoint and at deferred first use. Defaults toDefaultRequirementResolver(default- or-empty) when omitted, so a pure-coreruntime still enforces the fail-fast guarantee.- Parameters:
value- requirement resolver instance- Returns:
- this builder
-
runExecutionInterceptor
Configures the control interceptor fired before main execution and before each LLM call. Defaults toRunExecutionInterceptor.NO_OP.- Parameters:
value- run-execution interceptor instance- Returns:
- this builder
-
generatedArtifactStore
Configures the run-scoped store that captures emittedCREATE_FILEbytes for in-process artifact validation. Defaults to a retainingInMemoryGeneratedArtifactStorewhen omitted.- Parameters:
value- generated-artifact store instance- Returns:
- this builder
-
artifactValidators
Configures theArtifactValidators aVALIDATEstep may select byvalidatorId. Defaults to none; an embedding assembly (for example bootstrap) supplies the defaults.- Parameters:
value- validators registered by id (no duplicate ids)- Returns:
- this builder
-
contextAggregators
Configures theContextAggregators anAGGREGATEstep may select byaggregatorId. Defaults to none; an embedding assembly (for example bootstrap) supplies the defaults.- Parameters:
value- aggregators registered by id (no duplicate ids)- Returns:
- this builder
-
build
Validates required dependencies, wires executors and handlers, and returns a runnableWorkflowRuntime.Also rejects, before returning, every registered
WorkflowDefinitioninworkflowRepository's current snapshot that contains aCOLLECTIONstep: that step type has no registeredBehaviourHandlerin this release (seeWorkflowValidator.validateNoCollectionSteps(java.util.Map<java.lang.String, com.agentforge4j.core.workflow.WorkflowDefinition>)), so a run that reached one would otherwise fail deep inside execution instead of at build time. The JSON-loader path also runs this same check (defense-in-depth); this call covers definitions assembled programmatically, which never pass through the loader's validation suite.- Returns:
- configured runtime instance
- Throws:
IllegalArgumentException- if a required dependency is missing or invalid, or if a registered workflow contains aCOLLECTIONstep
-