Defining workflows
Register distinct agent types and connect them with a Flow definition.
This example summarizes text and reviews the summary. Distinct agent types let the runtime resolve each step unambiguously.
Create the host
Install Runiq.AI.Core, Runiq.AI.Agents, and Runiq.AI.Workflows. Supply OpenAI:ApiKey through host configuration and choose a model available to your account.
Registration does not execute the flow. Add the handler from Running workflows before app.Run().
Keep types distinct
Step<TAgent> resolves the exact CLR type. Two plain Agent instances with different IDs still share a type. Use distinct subclasses and register one instance per type.
The resolver builds a type-keyed dictionary of the registered agent collection. Duplicate CLR types can prevent workflow resolution even when IDs differ.
Declare transitions
Execution starts at the first declared step. OnSuccess("review") selects the next step by ID; declaring a second step alone does not make it execute.
Without a success target, success ends the flow. Failure stops by default.
Validate the definition
Build() returns the definition. Before execution, the runner checks for an empty flow, duplicate step IDs, and unknown targets.
Validation does not reject cycles or check every runtime dependency. Keep this flow acyclic and verify agent registrations.
Continue with Host application.