Index/ AESOP/ Build Decision Flow
Build decision flow

Build Decision Flow

aesop-os / backend / engine — from PRD to buildable agent

How the AESOP OS engine decides what to build and how to build it. Every PRD enters at Phase 0 and exits as either a paste-ready brief (Auto Mode) or importable JSON (Workflow Mode). The flow spans three layers: build-class selection, build-path routing, and architecture-pattern selection.

PRD → Layer 1 build class → Layer 2 path → Layer 3 pattern → buildable agent

01

Overview — the three layers

Three stacked decisions turn a PRD into a deployable agent. Not every build produces an agent: one output type hands a full-stack developer a decision-complete spec — a thin brief plus a full implementation reference — and lets them own the build. The developer, not AESOP, picks the stack, schema, and API.

Layer 1
Build-class selection — what kind of thing to build. Phase 0 fitness check, quick scoring, hard gates, then a class: A1 Assistant, A2 Assistant + routing, G1–G4 agents, or N1 not-ready.
Layer 2
Build-path routing — which phases run. Auto Mode (Phase 2A + 3A) for A1/A2/G1; Workflow Mode (Phase 2 + 3 + 4) for G2/G3/G4. Both end at Phase 5 summary.
Layer 3
Architecture-pattern selection — which structural template inside Workflow Mode. Six base patterns, optional hybrid modifiers, branching rules, and a sub-agent decision.
02

Layer 1 — build-class selection

decision gate
PRD submitted
Lowercased PRD text scored against 10 built-in patterns by keyword count.
Pattern matcher
Returns the top 3 patterns as hints — a suggestion, never a binding decision.
Phase 0 — fitness
failN1: not ready.go / conditionalProceed to quick scoring.
Quick score
Eight dimensions, 0–2 each, on a 0–16 scale.
Hard gates
Override the score when forced conditions hold. Map to a class: 0–4 broad Q&AA1 Assistant 14–16 multi-domainA2 Assistant + routing 5–9 domain chatG1 Conversational 10–13 form + stepsG2 Input form schedule triggerG3 Scheduled content triggerG4 Content-triggered
Phase 1 gap analysis
Re-validates the class against 12 gap categories (category 12 validates build class) and can override Phase 0.
HITL checkpoint
blockN1, requires explicit override. A1, A2, G1Auto Mode path (Phase 2A + 3A). G2, G3, G4Workflow Mode path (Phase 2 + 3 + 4).
Pattern matcherpatterns.py

Keyword-scores the PRD against 10 built-in patterns and returns the top 3 as hints. Each pattern carries a keyword list (8–10 terms); the matcher counts hits in the lowercased PRD. Score > 0 is a match. Limitation: keyword matching is shallow — the LLM in Phase 0 makes the real decision; the matcher only primes it.

  • 1 Q&A Bot — question, answer, knowledge base, search, FAQ
  • 2 Workflow Agent — form, workflow, collect, process, generate
  • 3 Scheduled Reporter — report, weekly, daily, digest, recurring
  • 4 Approval Workflow — approval, route, triage, classify, escalate
  • 5 Data Sync Agent — sync, migrate, transfer, ETL, pipeline
  • 6 Alert Monitor — monitor, alert, threshold, detect, anomaly
  • 7 Document Generator — document, template, memo, draft, compose
  • 8 Conversational Assistant — chat, conversation, multi-turn, coach
  • 9 Onboarding / Guided Flow — onboarding, walkthrough, checklist, training
  • 10 Decision Tree Agent — decision tree, evaluate, criteria, gate, eligibility
Phase 0 fitness check — fail conditionsmandatory stops

Any one of these triggers an automatic FAIL:

  • Required data source has no connector AND no viable workaround (no remote template, API action, or export path)
  • Core workflow requires storing or caching data outside the platform
  • Use case requires real-time bidirectional sync
  • Problem is better solved by process change, policy change, or a non-AI tool
  • Problem-solution fit is misaligned

Conditional pass is appropriate only when all connectors exist and the gaps are about PRD clarity, not platform capability.

Quick scoring model — 8 dimensions0–16

Score each 0–2, then sum.

Dimension012
Repeatabilityrarerecurringhigh-vol
Workflow clarityunclearpartialdefined
Standard outputnosomewhatyes
Branching / logicnonelimitedsignificant
Actions / integrationsnonefuturerequired
Risk / governancelowmediumhigh
Specialized KBbroadmixednarrow
Single entry pointnomaybeyes

Interpretation: 0–4 → A1. 5–9 → A1 or lean A2. 10–13 → agent (G1–G4 by trigger). 14–16 → A2.

Hard gates — override the scorebinding rules

These override the numeric score when triggered.

  • Force A1 when mostly true: broad Q&A / synthesis is the value; no strict process; no action in another system; freeform conversation helps; retrieval can stay dynamic.
  • Force agent (G1–G4) when any are true: repeatable steps; deterministic inputs + structured outputs; authoritative docs + system logic; must classify and respond differently; must route / escalate; requires system actions; must run in Slack, scheduled, or triggered.
  • Force A2 when all are true: users shouldn’t pick the specialist; 2+ domain use cases; real quality gain from specialization; a single front door is wanted.

PRD-prescribed override: if the PRD prescribes workflow steps but the problem maps to Auto Mode, recommend Auto Mode and note the override — PRDs often carry forward legacy design decisions.

Phase 1 gap analysis — build-class validationcan override Phase 0

Phase 1 re-evaluates the Phase 0 classification using 12 gap categories; category 12 validates the class.

  • A1 recommended? Do requirements need repeatable steps, deterministic outputs, or system actions? If yes, upgrade to G1/G2.
  • A2 recommended? Are there really 2+ distinct domains? If not, downgrade to A1/G1.
  • G1 recommended? Need branching, gates, multi-step data flow, or >20 actions? If yes, upgrade to G2.
  • G2/G3/G4 recommended? Is every step necessary, or could it be a single instruction block? If over-engineered, downgrade to G1/A1.

Rule: always choose the lowest-complexity class that reliably solves the problem.

HITL checkpoint — human overrideUI checkpoint
  • Block — red UI, requires an explicit checkbox to continue. Critical gaps that may produce a broken agent.
  • Caution — amber UI, standard approve / reject. Gaps exist but are manageable.
  • Proceed — green UI. No significant gaps.

The user can approve and continue, reject and halt, or override the classification before proceeding.

03

Layer 2 — build-path routing

parallel paths
HITL approved
A1, A2, G1Auto Mode path — Phase 2A instruction design → Phase 3A build brief. G2, G3, G4Workflow Mode path — Phase 2 workflow design → Phase 3 task instructions → Phase 4 generate outputs. both →Phase 5 summary.
Auto Mode path — Phase 2A + 3AA1, A2, G1

Phase 2A — instruction design: write the instruction block (scope, persona, knowledge sources, response format). Action budget — max 20 actions per agent; MCP tools consume action slots, so split or switch to Workflow Mode if exceeded. Design for adoption — don’t over-specify behavior that should adapt through traces. Context health check for distraction, clash, confusion.

Phase 3A — build brief: a paste-ready configuration for the UI — instructions, knowledge sources, conversation starters, action selections, LLM config. For A2, adds routing conditions and agent specs per domain. Auto Mode agents cannot be imported via JSON — manual paste only.

Workflow Mode path — Phase 2 + 3 + 4G2, G3, G4

Phase 2 — workflow design: select the base architecture pattern (Layer 3), apply hybrid modifiers if needed, design branching architecture, sub-agent decisions, MCP integration. Context health check and skill/action detection. Output: step-by-step architecture with types, dependencies, tool assignments.

Phase 3 — task instructions: write each step’s instruction template using the Goal–Return–Format–Warnings–Context framework. Target 4,000 chars per step (warn at 6K, hard limit 8K). Wire variable references [[step_id]] and [[field_name]].

Phase 4 — generate outputs: produce importable JSON matching the exact schema — UUIDs per step, correct type (BRANCH / TOOL / AGENT), memoryConfig: ALL_DEPENDENCIES. Post-build validation: schema checks, dependency integrity, variable syntax, budget audit.

Knowledge docs per phasePHASE_KNOWLEDGE

Each phase gets only the docs it needs (token-budget management), controlled by the PHASE_KNOWLEDGE map. Phase 3 and 4 use the full platform reference (~45K chars) because they emit JSON; all others use the slim version (~9K chars).

  • Phase 0: feasibility-rules, connector-registry, platform-ref-slim, prd-decision-framework, external-integrations
  • Phase 1: feasibility-rules, connector-registry, platform-ref-slim, community-patterns-slim
  • Phase 2: actions-catalog, connector-registry, platform-ref-slim, prompt-engineering, hybrid-patterns-slim, orchestration-decisions-slim, community-patterns-slim, platform-best-practices
  • Phase 3: platform-ref (full), prompt-engineering, orchestration-decisions-slim
  • Phase 4: actions-catalog, json-schema, platform-ref (full), orchestration-decisions-slim
  • Phase 2A: actions-catalog, platform-ref-slim, prompt-engineering, orchestration-decisions-slim
  • Phase 3A: actions-catalog, platform-ref-slim, orchestration-decisions-slim
04

Layer 3 — architecture-pattern selection

workflow mode

During Phase 2 the engine picks one of six base patterns, then optionally layers hybrid modifiers. The pattern matcher gives a keyword hint, but the LLM makes the final call with full PRD context.

Select base
prescriptive1 Cohesive Synthesis 3+ stages2 Decision Tree Pipeline type routing3 Conditional Enterprise template + data4 Document Generator exploratory5 Dynamic Research trivial6 Single-Step Agent
Hybrid modifier?
computeCompute Bridge qaValidation Gate webhook / mcpExternal Orchestration isolationMemory Isolation Sandwich noneProceed to branching design.
Branching design
Apply the three binding branching rules (branch-first routing, deterministic computation, depth and convergence).
Sub-agent?
yes / noEither resolves to the workflow architecture.
Pattern 1 — Cohesive Synthesismost common

Flow: Search + Think + Respond. Use when: known inputs, defined outputs, standardized process. Think is the synthesis step — deterministic and controllable, it reads dependency outputs via memory and compiles a structured result. Do not use Plan and Execute here; that is only for genuinely exploratory work.

Example — Job Description GeneratorTrigger: form (role, level, department, location). Flow: search JD templates and comp data → Think synthesizes a standardized JD → Respond. Why: every input known, output standardized, always search-then-synthesize.
Example — Policy Compliance CheckerTrigger: form (policy area, document). Flow: read document → search policy docs → Think compares and outputs a pass/fail compliance report → Respond. Why: clear inputs, authoritative source, deterministic output.
Pattern 2 — Decision Tree Pipelinemulti-stage gates

Flow: [Classify + Branch + Validate]* + Recommend. Use when: 3+ decision stages with STOP/REVIEW gates and terminal outcomes. Each classification is a Think step, each gate a Branch step, terminal outcomes get dedicated Respond steps, and the final recommendation is a Think step consuming validated outputs. Critical rule: gate enforcement must be structural (Branch steps), not behavioral. A decision-tree PRD with 3+ stages must produce multiple steps — a single TOOL step holding all the logic is always wrong.

Example — Technology Platform SelectorClassify need → branch (STOP if out of scope) → assess scale → branch (REVIEW if enterprise) → check compliance → branch (STOP if non-compliant) → final Think recommendation → Respond.
Example — Vendor Qualification PipelineSearch → classify risk → branch (HIGH → manual review; MEDIUM continues) → check insurance → branch (INCOMPLETE → request docs) → score and recommend.
Pattern 3 — Conditional Enterprise Actiontype-based routing

Flow: Classify + Branch + per-type processing. Use when: the request type determines entirely different paths, actions, output formats, or compliance rules. First step classifies type; a branch routes to type-specific sub-workflows; a convergence step merges outputs.

Example — HR Request RouterClassify (benefits / leave / verification / payroll) → branch → each path searches its own sources and generates its own output → convergence formats the response with per-type disclaimers.
Example — Separation Agreement GeneratorClassify by jurisdiction (US / EMEA / Australia) → branch → each path calculates per its own law and template → convergence QA & delivery to a legal reviewer.
Pattern 4 — Document Generatortemplate-based

Flow: Gather data + Generate + Deliver. Use when: output is a formatted deliverable built from a template. The intelligence is in gathering the right data and filling sections accurately, not in deciding what to do.

Example — Quarterly Business ReviewSearch quarterly metrics → read dashboards → Think fills the review template (summary, KPIs, highlights, risks, priorities) → create a document.
Example — New-Hire Onboarding PacketSearch role checklist, department resources, IT provisioning → Think compiles the personalized packet → Respond.
Pattern 5 — Dynamic Researchrare — exploratory only

Flow: Plan and Execute. Use only when the problem is genuinely open-ended with no known path — source material may be thin and the agent must autonomously re-query, the workflow is conversational and exploratory, and no defined output format exists. Never for defined inputs plus expected output, prescriptive steps, or standardized documents — those are Think (Pattern 1) workflows.

Example — Competitive Intelligence ResearcherThe agent autonomously decides what to search, evaluates sufficiency, re-queries if thin, and produces an analysis. No predefined template.
Example — Root-Cause InvestigatorEach investigation is unique; the agent follows the evidence, not a script.
Pattern 6 — Single-Step Agentminimal

Flow: one instruction block. Use when: trivial 1–2 step workflows where orchestration adds no value. Note: if a workflow seems single-step but has decision logic or classification, it belongs in Pattern 1 or 2. Don’t collapse complexity into one step just because it fits in 8K characters.

Example — Meeting Summary FormatterPasted transcript → one instruction extracts attendees, decisions, action items, and next steps into a structured summary.
Example — Email Draft HelperDraft in company voice — no search, no branching, no external systems.
Hybrid modifiers — applied on top of base patternsoptional layer

Hybrid modifiers close the gap between deterministic and non-deterministic steps. Apply one or more when the base pattern doesn’t fully cover the workflow.

  • Compute Bridge — a Custom Action step before a Branch step, when the branch needs exact computed values. Never use Think to compute routing values (non-deterministic). Example: days-until-renewal computed by a Custom Action; Think might say “about a month” and misroute.
  • Validation Gate — a Think step (FACTUAL) between synthesis and delivery when output is externally visible or multi-step. Checks completeness, consistency, compliance. Example: a QA step after the JD generator confirms sections, comp range, and EEO statement.
  • External Orchestration Bridge — a webhook or MCP call between deterministic steps. Constraint: MCP tools only exist in Plan and Execute and Auto Mode, not explicit workflow steps — use Custom Actions or webhooks in Workflow Mode. Example: a PO that calls an approval API, then branches on approved / denied / pending.
  • Memory Isolation Sandwich — a sub-agent within the parent workflow for batch processing or modular encapsulation. Only the Respond step returns to the parent; no native parent-to-child variable mapping. Example: a CSV Splitter spawns per-row sub-agents that enrich data; or parallel US/EU/APAC compliance sub-agents aggregate into one report.
Branching design rulescritical constraints

Branch-first routing — branch on raw search output, never on Think interpretation. Think may reclassify, soften, or alter the routing signal.

Correct: Search → Branch → per-branch Think.  Wrong: Search → Think → Branch.

Deterministic computation — route calculated values through a Custom Action before the Branch. LLM arithmetic is unreliable.

Correct: Custom Action (compute) → Branch.  Wrong: Think (compute and decide) → Branch.

Depth and convergence — max 3 levels of nesting; deeper means flatten or delegate inner branches to a sub-agent. Convergence steps must handle missing inputs from branches that didn’t fire — check each dependency’s status with a sentinel before including its output.

Sub-agent decision frameworkwhen to delegate

Use a sub-agent when: memory isolation matters (no context pollution); batch processing (CSV Splitter); modular domain encapsulation (updating it doesn’t rebuild the parent); reusable across parents.

Don’t use one when: the parent needs intermediate outputs (only Respond returns); the task is 1–2 steps tightly coupled to parent context; the overhead exceeds the encapsulation benefit.

Scoping: single purpose, max 2 nesting levels, branch logic inside sub-agents to avoid duplication. Start with “triage agent plus one or two specialists.” Don’t over-architect.

05

Review — key anti-patterns

platform lead + community

The five most common failures in AESOP OS output — the highest-value items to review with the platform lead.

1 — Plan and Execute for prescriptive workflowsmost common mistake

Wrong: Plan and Execute with defined inputs, expected output, prescriptive steps. Right: Search + Think + Respond. Plan and Execute is non-deterministic; Think is controllable and reads dependencies via memory.

2 — Think between Search and Branchthe platform lead’s rule

Wrong: Search → Think (interpret) → Branch. Right: Search → Branch → per-branch Think. Think may reclassify or soften the routing signal; branch on raw output.

3 — Think for branch-routing computationunreliable

Wrong: Think computes a score / date / threshold that Branch reads. Right: a Custom Action computes it; Branch reads the deterministic result.

4 — TEXT inputs for constrained fieldsUI problem

Wrong: free text for locations, departments, job levels. Right: a SELECT with the valid options. Typos and variations break downstream classification and branching.

5 — Deep branch nesting without sub-agentscomplexity trap

Wrong: 4+ nested branch levels in one workflow. Right: max 3; delegate inner branches to sub-agents. Deep nesting makes convergence fragile.

More from community practicecommunity-patterns-slim.md
  • Silent context truncation — the platform auto-truncates tokens with no indicator. Design with progressive memory scoping.
  • Read-document token bloat — full-doc reads exhaust context; use snippet-based search.
  • Large-PDF failure — ~1,000-page PDFs fail in agents; split or extract sections first.
  • 8K character limit — hard limit per instruction template. Move stable conventions to reference docs.
  • OAuth switches break agents — changing auth methods globally broke existing connected agents.
  • Slack bot limitation — agents don’t respond to bot / workflow messages. A human initiates, or use the Agent API.
06

Reference — quick tables

reference
Build classes
ClassNameModeTriggerOutputWhen to use
A1AssistantAutoChatPaste-ready briefBroad Q&A, summarization, drafting.Synthesis not execution — variable sources, follow-ups matter.
A2Assistant + RoutingAutoChatRouting + agent specsSingle front door, 2+ domains.Company help desk routes HR / IT / facilities questions to specialists.
G1Conversational AgentAutoChatPaste-ready briefDomain chat, narrow KB, decision logic.Sales-policy Q&A with classification and per-type responses.
G2Input Form AgentWorkflowFormImportable JSONStructured inputs, sequential steps.JD generator: form in, policy search, standardized output.
G3Scheduled AgentWorkflowScheduleJSON + scheduleTime-triggered, no user initiation.Weekly compliance digest posts to Slack each Monday.
G4Content-TriggeredWorkflowEventJSON + triggerFile / folder event triggers.Contract review fires when a PDF lands in a Drive folder.
S1SkillBetaAI-routedSKILL.mdNarrow reusable single task.Severance calculator reused across HR agents.
N1Not ReadyNoneGap summaryMissing sources, unresolved governance.No budget data, no approval API, no defined process.
Architecture patterns
#PatternFlowSelection signal
1Cohesive SynthesisSearch + Think + RespondPrescriptive: known inputs, defined outputs
2Decision Tree Pipeline[Classify+Branch+Validate]*3+ stages with STOP/REVIEW gates
3Conditional EnterpriseClassify+Branch+Per-typeRequest type determines different paths
4Document GeneratorGather+Generate+DeliverTemplate output from gathered data
5Dynamic ResearchPlan and ExecuteGenuinely exploratory (rare)
6Single-StepOne blockTrivial, no orchestration needed
Orchestration decision matrix
CriterionSkillCustom ActionAction PackSub-Agent
Reusable across agents?Yes (company-wide)Yes (global)Yes (system-wide)Yes (published)
External side effects?NoYes (API call)Yes (system write)Depends
Structured I/O?No (AI-routed)Yes (OpenAPI)Yes (fixed params)Yes (form/memory)
Memory isolation?N/ANoNoYes
Token cost?Low (~100)MinimalMinimalHigh (full exec)
Deterministic?NoYesYesDepends

One decision, three layers deep. The OS never guesses what to build. It scores the problem, forces the right class through hard gates and a human checkpoint, routes it down the matching path, and picks a structural pattern before a single instruction is written. The discipline that keeps the output reliable is the same throughout: branch on deterministic signal, gate structurally, and let a human override at the one moment it matters.