AutoFlow
Architecture

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 generate

Stage Details

StageAgentPurpose
NavigateNavigatorAgentRoutes to the right Ask Sage tool (only Agent Builder continues)
NormalizeNormalizerAgentExtracts objective, deliverable type, constraints from messy input
ParseBaseAgent (parser)Splits input into structured sections (synthesize only)
ExtractBaseAgent (extractor)Extracts events from parsed sections (synthesize only)
SynthesizeBaseAgent (synthesizer)Produces SITREP output (synthesize only)
GenerateGeneratorAgent (WorkflowCompiler)Produces v2 workflow JSON with pattern + model hints, then post-processes to ensure valid identity model (generate only)
EvaluateEvaluatorAgentScores on 5 quality dimensions
CritiqueCritiqueAgentIdentifies issues and suggests fixes
EnvelopeWraps result in Universal Output Envelope

Critique Loop

The evaluate-critique cycle runs up to MAX_CRITIQUE_ITERATIONS (default: 2):

  1. Evaluate — Scores the current output on correctness, completeness, format validity, efficiency, and reusability
  2. Check pass criteria — If correctness >= 4, format_validity == 5, and estimated_human_edit_minutes <= 15, the loop exits with PASS
  3. Critique — If thresholds aren't met, the critique agent identifies specific issues
  4. 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:

  1. Generates UUID IDs for any non-UUID node IDs
  2. Derives slugs from labels (or preserves old snake_case IDs)
  3. Resolves slug collisions with numeric suffixes
  4. Adds missing key fields
  5. 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

On this page