Adding Inputs¶
Make your workflows configurable by accepting runtime parameters.
The Problem¶
Hardcoded values make workflows inflexible:
Solution: Use inputs — variables you provide when running the workflow.
Defining Inputs¶
Add an inputs section to your workflow:
name: "code-review"
description: "Review any file you specify"
inputs:
files:
description: "The files to review"
default: "*.go"
agents:
reviewer:
inline:
description: "Code reviewer"
prompt: "You are an expert code reviewer."
steps:
- id: review
agent: reviewer
prompt: "Review these files: {{inputs.files}}"
output:
steps: [review]
format: markdown
Input Fields¶
| Field | Required | Description |
|---|---|---|
description |
No | Explains what the input is for |
default |
No | Default value if not provided at runtime |
Always Add Descriptions
Descriptions appear in error messages and help documentation, making workflows self-documenting.
Running With Inputs¶
Provide inputs using the --inputs flag:
Multiple Inputs¶
Using Defaults¶
If an input has a default value, you can omit it:
Input Template Syntax¶
Reference inputs using {{inputs.NAME}}:
Where You Can Use Input Templates¶
| Location | Example |
|---|---|
| Step prompts | prompt: "Analyze {{inputs.files}}" |
| Agent prompts | prompt: "You specialize in {{inputs.language}}" |
| Conditions | contains: "{{inputs.keyword}}" |
Complete Example¶
Let's build a configurable greeting workflow:
name: "greeting-workflow"
description: "Generates a personalized greeting"
inputs:
name:
description: "Name of the person to greet"
default: "World"
style:
description: "Greeting style: formal, casual, or pirate"
default: "casual"
agents:
greeter:
inline:
description: "Creates greetings in various styles"
prompt: "You create greetings. Use {{inputs.style}} style."
steps:
- id: greet
agent: greeter
prompt: "Create a greeting for {{inputs.name}}. Keep it to one sentence."
output:
steps: [greet]
format: markdown
Try It¶
# Default greeting
goflow run --workflow greeting-workflow.yaml --mock
# Custom name
goflow run --workflow greeting-workflow.yaml --inputs name='Alice' --mock
# Custom name and style
goflow run --workflow greeting-workflow.yaml \
--inputs name='Captain Jack' \
--inputs style='pirate' \
--verbose
Input Validation¶
goflow validates inputs when the workflow starts:
Missing Required Input¶
If an input has no default and you don't provide it:
Unknown Input¶
If you pass an input that isn't defined:
goflow run --workflow example.yaml --inputs typo='value'
# Warning: unknown input 'typo' (will be ignored)
Best Practices¶
1. Use Descriptive Names¶
# ✓ Good
inputs:
target_files:
description: "Files to analyze (glob pattern)"
# ✗ Bad
inputs:
f:
description: "files"
2. Provide Sensible Defaults¶
inputs:
depth:
description: "Analysis depth (brief, normal, detailed)"
default: "normal" # Most users want this
3. Document Valid Values¶
What You Learned¶
How to define inputs with
inputs:
How to provide inputs with
--inputs key='value'
How to use
{{inputs.name}} in prompts
How default values work
Next Steps¶
Now that you can make workflows configurable, let's learn to chain multiple steps together: