Workflow Type

The Workflow type orchestrates multi-step field collection by iterating through configured Form instances. It tracks missing fields, current form index, and completion status.

Creation Syntax

@agentName := "Assistant"
@cars form currentUser
    carName : "Car name of" $currentUser
    color : "the color of the car for" $currentUser
    year : "year of production of the car for" $currentUser
end

@workflowAgent new Workflow $agentName
workflowAgent.configure "Use " $cars " to find the favorite car for the user"

This setup is based on tests/pipelines/customTypes/workFlowAgent.mjs. The workflow stores form references and uses them to derive questions and missing fields.

Example

@workflowAgent new Workflow $agentName
workflowAgent.configure "Use " $cars " to find the favorite car for the user"

After configuration, host code repeatedly asks workflow for the next question and acknowledges responses until completion.

Step-by-Step Interaction

The workflow instance is typically used from host code by repeatedly calling:

The host asks the workflow for the next prompt by calling getQuestion(), and that call inspects current forms and current answer state to compute the next missing field. After the user or external component provides a structured response object, the host submits it through acknowledgeResponse(response), which merges valid fields and advances workflow state. The host continues this loop until the workflow reports completion through isCompleted, and at that point the consolidated payload is available through answers. Internally, the object also exposes utility methods such as getMissingFields and getCurrentRequiredFields, plus optional LLM forwarding methods such as getTextResponse and getChatCompletionResponse.

Runtime Role Notes

Workflow is an orchestration adapter for form-driven conversational data collection. It coordinates form state, missing fields, and optional agent calls within one object reference.