Task Builder — Visual Workflow Editor with MongoDB Persistence
Status: 🟡 In-development Category: Architecture & Design Date: March 3, 2026
Overview
Introduced a visual Task Builder UI for creating and managing self-service workflows, backed by a new task_configs MongoDB collection. The supervisor agent now reads task configs from MongoDB (with YAML fallback), closing the gap between the UI and the backend.
Problem Statement
The supervisor agent reads workflows exclusively from task_config.yaml on disk. The UI has no way to create or edit these workflows — any change requires modifying YAML, rebuilding the Helm chart, and redeploying. Non-developer users cannot create custom self-service workflows, and workflows created in the existing Agent Builder are not consumed by the supervisor.
Decision
| Alternative | Pros | Cons | Decision |
|---|---|---|---|
| New Task Builder UI + MongoDB collection (chosen) | Clean separation from Agent Builder; visual flow editor; MongoDB as single source of truth; supervisor reads directly via pymongo | New collection and API routes to maintain | Selected |
| Extend Agent Builder to write task_config.yaml | Reuses existing UI | Conflates two different config models; file-based flow is fragile | Rejected |
| YAML editor in UI | Simple to build | Poor UX for non-developers; still requires understanding YAML syntax | Rejected |
Solution Architecture
Data Flow
First boot:
task_config.yaml → /api/task-configs/seed → MongoDB (task_configs)
UI editing:
Task Builder UI → /api/task-configs (CRUD) → MongoDB (task_configs)
Supervisor reads:
load_task_config() → pymongo (primary, cached 60s) → YAML file (fallback)
Components
- MongoDB
task_configscollection — Stores workflow definitions with indexes onid(unique),name(unique),category,owner_id,is_system, andcreated_at. - Next.js API routes —
/api/task-configs(CRUD) and/api/task-configs/seed(YAML seeding). Auth-protected with ownership/admin checks. - Zustand store —
task-config-store.tsmanages client-side state with auto-seeding on first load. - Task Builder UI —
@xyflow/react-based visual flow editor at/task-builderwith custom TaskStepNode components, property sidebar, and toolbar. - Shared pymongo client —
ai_platform_engineering/utils/mongodb_client.pysingleton withget_task_configs_from_mongodb()returning task_config.yaml-compatible dict format. - Modified
load_task_config()— Reads from MongoDB whenMONGODB_URIis set (with 60s TTL cache), falls back to YAML file.
UX Enhancements (post-initial implementation)
The following UX improvements were added after the initial Task Builder implementation:
- S-curve node layout — Nodes alternate left-right in an S-curve pattern with bezier curved edges instead of a straight vertical line.
- Step Templates palette — Left sidebar (
StepPalette.tsx) with 154 draggable tool templates from all integrated agents (CAIPE, GitHub, Jira, Webex, ArgoCD, AWS, AI Gateway, Backstage, Slack, PagerDuty, Splunk, Komodor, Confluence), searchable, categorized, with drag-and-drop onto canvas. Data instep-templates.ts. - CAIPE Form Builder — Structured form editor (
CaipeFormBuilder.tsx) forcaipesubagent steps. - File I/O visualization — Nodes show file read/write badges extracted from
llm_prompt; edges between nodes sharing files are highlighted green. - Environment variable panel —
EnvVarsPanel.tsxshows env vars referenced in workflow with step locations. - Unsaved changes guard — In-app styled dialog (
UnsavedChangesDialog.tsx) when navigating away with unsaved changes; works on Back button AND header tab navigation via Zustand global store (unsaved-changes-store.ts) +GuardedLinkwrapper in AppHeader. - Import dialog —
ImportDialog.tsxsupports loading saved configs from MongoDB, uploading YAML file, or importing from raw HTTP URL. - YAML preview dialog —
YamlPreviewDialog.tsxprovides syntax-highlighted YAML preview with copy/download, line numbers. - YAML export — Download uses YAML format (js-yaml) instead of JSON.
- Workflow templates —
WorkflowTemplateDialog.tsxtemplate picker when creating new workflow. - Clone workflow — Clone button on existing workflow cards.
- Theme-aware nodes — Nodes use dark vibrant colors in dark mode, pastel colors in light mode via
useTheme()runtime detection. - Custom canvas controls — Replaced React Flow default Controls with custom Panel-based controls using primary theme color.
- Toolbar redesign — Two-row layout with grouped Import/Preview/Download button bar to prevent overflow.
- Scrollbar fix — Transparent track with thin rounded thumb globally.
Configuration
# MongoDB (required for Task Builder, existing env vars)
MONGODB_URI=mongodb://...
MONGODB_DATABASE=caipe
# YAML seed file path (optional, defaults to /app/task_config.yaml)
TASK_CONFIG_SEED_PATH=/app/task_config.yaml
# Cache TTL for supervisor MongoDB reads (seconds, default 60)
TASK_CONFIG_CACHE_TTL=60
Components Changed
ui/src/types/task-config.ts— TaskConfig, TaskStep types and YAML parsing utilitiesui/src/lib/mongodb.ts— Addedtask_configscollection indexesui/src/app/api/task-configs/— CRUD and seed API routesui/src/store/task-config-store.ts— Zustand storeui/src/store/unsaved-changes-store.ts— Zustand store for unsaved changes guardui/src/components/task-builder/— Visual flow editor componentsui/src/components/task-builder/StepPalette.tsx— Step Templates palette (154 draggable tool templates)ui/src/components/task-builder/CaipeFormBuilder.tsx— CAIPE Form Builder for structured editingui/src/components/task-builder/EnvVarsPanel.tsx— Environment variable panelui/src/components/task-builder/ImportDialog.tsx— Import dialog (MongoDB, YAML upload, HTTP URL)ui/src/components/task-builder/YamlPreviewDialog.tsx— YAML preview dialogui/src/components/task-builder/UnsavedChangesDialog.tsx— Unsaved changes dialogui/src/components/task-builder/WorkflowTemplateDialog.tsx— Workflow template pickerui/src/components/task-builder/step-templates.ts— Step template data for all integrated agentsui/src/app/(app)/task-builder/page.tsx— Task Builder pageui/src/components/layout/AppHeader.tsx— Added Task Builder navigation tab, GuardedLink wrapperai_platform_engineering/utils/mongodb_client.py— Shared pymongo client singletonai_platform_engineering/multi_agents/platform_engineer/deep_agent_single.py— Modifiedload_task_config()for MongoDB-first reads
Related
- Spec:
.specify/specs/task-builder.md - Task Config YAML:
charts/ai-platform-engineering/data/task_config.yaml - Existing Agent Builder:
ui/src/components/agent-builder/