generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request: Agentic workflow optimization support
Problem
Current optimization targets single prompts, but modern LLM apps use multi-step agent workflows. These have different challenges:
- Agents make 10-100x more API calls than single prompts
- Need to optimize entire workflows, not just individual steps
- Different models work better for different workflow steps
- Hard to evaluate multi-step success vs. individual responses
Proposed Solution
Add workflow optimization that can optimize multi-step agent pipelines with cost-aware model routing.
Basic Usage
# Define multi-step workflow
workflow = AgentWorkflow([
PlanningStep(models=["nova-pro", "claude-sonnet"]),
ReasoningStep(models=["claude-sonnet", "gpt-4o"]),
ToolCallingStep(models=["gpt-4o", "nova-lite"]),
SynthesisStep(models=["nova-pro"])
])
# Optimize entire workflow
optimizer = WorkflowOptimizer(
workflow=workflow,
cost_budget=50.0,
metric=workflow_success_metric
)
optimized_workflow = optimizer.optimize(dataset, metric)Cost-Aware Model Routing
# Automatically route based on task complexity and cost
router = CostAwareRouter({
"simple_tasks": "nova-lite", # $0.0006/1k tokens
"reasoning": "claude-sonnet", # $0.003/1k tokens
"complex_coding": "gpt-4o" # $0.005/1k tokens
})
workflow.add_router(router)Key Features Needed
- Workflow adapter: Execute and track multi-step workflows
- Step-level optimization: Optimize prompts for each workflow step
- Model routing: Assign optimal models to different steps
- Workflow metrics: Evaluate entire pipeline success
- Cost tracking: Monitor costs across all workflow steps
- Context management: Optimize data passing between steps
Example Use Cases
Research Agent: Search (nova-lite) → Analysis (claude-sonnet) → Synthesis (nova-pro)
Coding Agent: Planning (claude-sonnet) → Implementation (gpt-4o) → Testing (nova-pro)
Support Agent: Classification (nova-lite) → Retrieval (nova-pro) → Response (claude-sonnet)
Why This Matters
- Agent workflows are becoming standard - single prompts are less common/for prototypes
- Cost explosion problem - agents can easily burn through budgets
- No existing tools optimize multi-step workflows end-to-end
- Model specialization - different models excel at different workflow steps
Consider
- Extend existing
PromptAdapterto support workflow definitions - Add
WorkflowOptimizerthat uses MIPROv2 across multiple steps - Create workflow-specific metrics and evaluation methods
- Add cost tracking and budget allocation across steps
References
- LangGraph - Agent workflow patterns
- DSPy ReAct - Single-step agent optimization
- CrewAI - Multi-agent frameworks
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request