Pipeline
The WorkflowPipeline orchestrator and its two execution modes.
The WorkflowPipeline class in src/autoflow/pipeline.py is the central orchestrator. It manages two execution modes, each running a different sequence of stages.
Pipeline Modes
Synthesize Mode (SITREP Generation)
Produces structured briefing documents from free-form input:
python -m autoflow "Summarize this week's cyber threat landscape"Generate Mode (Workflow JSON)
Produces Ask Sage Agent Builder workflow JSON:
python -m autoflow "Route support tickets by category" --mode generateStage Details
| Stage | Agent | Purpose |
|---|---|---|
| Navigate | NavigatorAgent | Routes to the right Ask Sage tool (only Agent Builder continues) |
| Normalize | NormalizerAgent | Extracts objective, deliverable type, constraints from messy input |
| Parse | BaseAgent (parser) | Splits input into structured sections (synthesize only) |
| Extract | BaseAgent (extractor) | Extracts events from parsed sections (synthesize only) |
| Synthesize | BaseAgent (synthesizer) | Produces SITREP output (synthesize only) |
| Generate | GeneratorAgent (WorkflowCompiler) | Produces v2 workflow JSON with pattern + model hints, then post-processes to ensure valid identity model (generate only) |
| Evaluate | EvaluatorAgent | Scores on 5 quality dimensions |
| Critique | CritiqueAgent | Identifies issues and suggests fixes |
| Envelope | — | Wraps result in Universal Output Envelope |
Critique Loop
The evaluate-critique cycle runs up to MAX_CRITIQUE_ITERATIONS (default: 2):
- Evaluate — Scores the current output on correctness, completeness, format validity, efficiency, and reusability
- Check pass criteria — If
correctness >= 4,format_validity == 5, andestimated_human_edit_minutes <= 15, the loop exits with PASS - Critique — If thresholds aren't met, the critique agent identifies specific issues
- Regenerate — The generator incorporates critique feedback and produces a new version
If all iterations are exhausted without passing, the best version is returned with a FAIL verdict.
Generator Post-Processing
The GeneratorAgent (persona: WorkflowCompiler) includes a post-processing safety net (_ensure_identity_model()) that runs before validation. If the LLM produces v1-style output (snake_case IDs, missing slugs), the post-processor upgrades it to v2 format:
- Generates UUID IDs for any non-UUID node IDs
- Derives slugs from labels (or preserves old snake_case IDs)
- Resolves slug collisions with numeric suffixes
- Adds missing
keyfields - Updates edge source/target references to UUIDs
This ensures generated workflows are always valid v2 format, even if the underlying LLM doesn't follow the compiler-spec prompt perfectly.
Universal Output Envelope
Every pipeline run produces a standardized envelope validated against schemas/universal_output_envelop/schema.json:
{
"objective": "What the user asked for",
"deliverable_artifact": { ... },
"quality_scores": {
"correctness": 4,
"completeness": 4,
"format_validity": 5,
"efficiency": 4,
"reusability": 3
},
"confidence": 0.85,
"assumptions": ["..."],
"constraints": ["..."],
"known_gaps": ["..."],
"estimated_human_edit_minutes": 10,
"recommended_next_actions": ["..."],
"metadata": {
"provider": "openai",
"mode": "generate",
"iterations": 1,
"pattern": "classification"
}
}Skipping Navigation
If you know Agent Builder is the right tool, skip the Navigator stage:
python -m autoflow "Classify emails" --mode generate --skip-navigator