Tool Composition Patterns

Orchestrate multiple tools into sophisticated, powerful agent workflows

Sequential Composition: Step-by-Step Execution

Sequential composition is the simplest pattern: tools execute one after another, with each tool receiving the output of the previous step. Like an assembly line, data flows through a series of transformations.

This pattern works best when each tool depends on the previous result to do its job.

Interactive: Sequential Execution Demo

Watch tools execute one after another in a research workflow

1
search_web
Search for information
2
extract_content
Extract content from articles
3
analyze_sentiment
Analyze sentiment
4
generate_summary
Generate final summary

Common Sequential Patterns

Pipeline
Linear sequence where each tool processes the previous result
Example:
fetch β†’ transform β†’ validate β†’ save
βœ“ Simple, predictable data flow
⚠ Slow for independent operations
Chain
Each tool depends on previous output to determine action
Example:
query_db β†’ if empty: search_api β†’ merge_results
βœ“ Flexible, adaptive to intermediate results
⚠ More complex error handling
Waterfall
Sequential stages with validation checkpoints
Example:
draft β†’ review β†’ approve β†’ publish
βœ“ Quality gates, rollback capability
⚠ Cannot skip stages easily

Best Practices for Sequential Composition

βœ…
Minimize sequential steps
Each step adds latencyβ€”only sequence when necessary
πŸ”—
Pass minimal data
Large data transfers between tools slow execution
⚠️
Handle errors at each step
One failure shouldnt crash the entire sequence
πŸ“Š
Log intermediate results
Essential for debugging complex sequences