Skip to content

Flows

Processing pipelines for AI operations.

Flows define step-by-step processing pipelines. Think Unix pipes, but for AI operations.

FLOW handle_request
validate input
fetch context
generate response
apply constraints
format output

Each step transforms data. The output of one step becomes the input of the next.

FLOW name
step one
step two
step three

Rules:

  • Steps execute in order
  • Each step is an indented line
  • Steps are named operations
  • Indentation matters (2 spaces)
FLOW document_analyzer
extract text # First: get the text
detect language # Then: identify language
analyze sentiment # Then: assess tone
summarize content # Finally: create summary

Each step completes before the next begins. No parallel execution.

FLOW enhance_response
original response # "The capital is Paris"
add context # "The capital of France is Paris"
add sources # "The capital of France is Paris (Source: Wikipedia)"
format markdown # "The capital of France is **Paris** *(Source: Wikipedia)*"

Each step enriches or transforms the data.

FLOW validate_and_process
check rate limit
validate schema
sanitize input
check permissions
process request

Fail fast. If any validation step fails, the flow stops.

FLOW enhance_output
generate base response
add examples
include references
apply formatting
add metadata

Progressive enhancement. Each step adds value.

FLOW safety_pipeline
scan for pii
check content policy
validate against rules
apply filters
final review

Multiple safety checks. Defense in depth.

FLOW contextual_response
fetch user history
fetch relevant docs
merge context
generate with context
personalize

Build context before generation.

Flows and constraints work together:

AGENT support
CONSTRAINTS rules
NEVER expose PII
MUST be helpful
FLOW support_flow
identify issue # Understand the problem
check knowledge # Search for solutions
generate response # Create response
apply constraints # Apply NEVER/MUST rules
send reply # Deliver to user

The apply constraints step enforces your rules.

FLOW handle_complaint
acknowledge customer
extract issue
check previous tickets
determine severity
generate solution
create ticket
send response
schedule followup
FLOW review_code
parse syntax
check style guide
scan security issues
analyze complexity
generate feedback
format comments
FLOW moderate_content
detect language
scan inappropriate
check copyright
verify facts
apply policy
generate decision
FLOW research_topic
understand query
search sources
evaluate credibility
extract facts
synthesize findings
cite references

While Human doesn’t have explicit error handling syntax, flows naturally handle errors:

FLOW safe_process
validate or fail # Stops flow if validation fails
process if valid # Only runs if validation passed
return result # Only runs if processing succeeded

Steps can be smart about when they apply:

FLOW adaptive_flow
detect content type
process text # Runs for text
process code # Runs for code
process data # Runs for data
format output # Always runs

Test that your flow produces expected results:

FLOW parsing_flow
extract entities
validate entities
format entities
TEST
INPUT "John Smith visited New York"
EXPECT CONTAINS "John Smith"
TEST
INPUT "Invalid data: @#$%"
EXPECT CONTAINS "error"

Each step should do one thing:

# Good
FLOW clear_flow
validate input
fetch data
process data
format output
# Bad
FLOW unclear_flow
validate and fetch and process
do everything else

Step names should be verbs that describe actions:

# Good
FLOW descriptive
authenticate user
fetch permissions
apply access control
# Bad
FLOW vague
step1
process
finish

Put validation and checks first:

# Good
FLOW fail_fast
validate input # First
check permissions # Second
expensive operation # Last
# Bad
FLOW fail_late
expensive operation # Wastes resources
validate input # Should be first

One flow, one purpose:

# Good: Separate flows
FLOW validate_input
check format
verify completeness
FLOW process_input
transform data
apply business logic
# Bad: Mixed concerns
FLOW do_everything
validate
process
send email
update database
# Bad: Jumps straight to generation
FLOW incomplete
generate response
send response
# Good: Includes necessary steps
FLOW complete
validate request
check rate limit
generate response
apply safety checks
send response
# Bad: Generates before validating
FLOW wrong_order
generate content
check if allowed
# Good: Validates first
FLOW right_order
check if allowed
generate content

Flows make AI behavior predictable. Instead of a black box that takes input and produces output, you have a glass pipeline where each transformation is visible.