pub struct Workflow {
pub name: String,
pub description: String,
pub tools: IndexMap<String, ToolDef>,
pub required_steps: Vec<String>,
pub terminal_tools: HashSet<String>,
pub system_prompt_template: String,
}Expand description
A validated workflow definition.
Fields§
§name: StringName of the workflow.
description: StringDescription of the workflow.
tools: IndexMap<String, ToolDef>Map of tool names to their definition.
required_steps: Vec<String>List of step names that must be completed.
terminal_tools: HashSet<String>Set of tools designated as terminal (success terminates loop).
system_prompt_template: StringSystem prompt template containing variable interpolation placeholders.
Implementations§
Source§impl Workflow
impl Workflow
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
tools: IndexMap<String, ToolDef>,
required_steps: Vec<String>,
terminal_tool: TerminalToolInput,
system_prompt_template: impl Into<String>,
) -> Result<Self, String>
pub fn new( name: impl Into<String>, description: impl Into<String>, tools: IndexMap<String, ToolDef>, required_steps: Vec<String>, terminal_tool: TerminalToolInput, system_prompt_template: impl Into<String>, ) -> Result<Self, String>
Construct and validate a Workflow.
Validates:
- Each tool dict key matches the tool definition’s name.
- Every required step exists in the tools map.
- Every terminal tool exists in the tools map.
- No terminal tool is also a required step.
- Every prerequisite references a tool that exists in the tools map.
Sourcepub fn build_system_prompt(&self, vars: &IndexMap<String, String>) -> String
pub fn build_system_prompt(&self, vars: &IndexMap<String, String>) -> String
Render the system prompt template with the provided variables.
Sourcepub fn get_tool_specs(&self) -> Vec<&ToolSpec>
pub fn get_tool_specs(&self) -> Vec<&ToolSpec>
Get all tool specs in insertion order.
Sourcepub fn get_callable(&self, tool_name: &str) -> Result<ToolCallable, String>
pub fn get_callable(&self, tool_name: &str) -> Result<ToolCallable, String>
Get the callable for a tool by name.
Returns an error if the tool name is not found.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Workflow
impl !UnwindSafe for Workflow
impl Freeze for Workflow
impl Send for Workflow
impl Sync for Workflow
impl Unpin for Workflow
impl UnsafeUnpin for Workflow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.