# LocoAgent Workflow Development Guide A guide for LocoAgent developers on creating, testing, and deploying custom Workflows. --- ## Table of Contents - [1. What is a Workflow](#1-what-is-a-workflow) - [2. Architecture](#2-architecture) - [Browser Targets (Multi-Platform)](#browser-targets-multi-platform) - [3. Creating a Workflow Step by Step](#3-creating-a-workflow-step-by-step) - [3.1 Step 1: Write the Workflow Definition](#31-step-1-write-the-workflow-definition) - [3.2 Step 2: Write the Executor Script](#32-step-2-write-the-executor-script) - [3.3 Step 3: Test and Run](#33-step-3-test-and-run) - [4. Workflow Definition Specification](#4-workflow-definition-specification) - [5. Executor Development Guide](#5-executor-development-guide) - [5.1 Executor Contract](#51-executor-contract) - [5.2 Browser Automation with agent-browser](#52-browser-automation-with-agent-browser) - [5.3 Checkpoint Protocol (Stoppable Workflows)](#53-checkpoint-protocol-stoppable-workflows) - [5.4 Deduplication Pattern](#54-deduplication-pattern) - [5.5 Integrating External LLM APIs](#55-integrating-external-llm-apis) - [6. Workflow Engine CLI Reference](#6-workflow-engine-cli-reference) - [7. Execution Modes](#7-execution-modes) - [8. State Model](#8-state-model) - [9. Agent Integration](#9-agent-integration) - [10. Existing Workflow Reference](#10-existing-workflow-reference) - [11. FAQ](#11-faq) --- ## 1. What is a Workflow A Workflow is a **scripted automation pipeline** in LocoAgent. Unlike agent-driven conversations where the LLM decides what to do next in an agentic loop, Workflows follow a **predefined sequence of steps** — the control flow is deterministic even if individual steps may involve LLM calls or agent operations. A Workflow can include: - Browser automation steps (via `agent-browser`) - LLM API calls (e.g., calling DeepSeek to generate a reply) - Agent sub-tasks (delegating part of the pipeline to an agent) - Pure data processing (file I/O, API calls, scraping, etc.) The key distinction is **who controls the flow**: in a Workflow, the executor script drives the pipeline; in an agent session, the LLM decides the next action. Workflows are code-driven pipelines that may use LLMs as tools within their steps. **Key advantages:** - Predictable execution — follows a fixed pipeline, no LLM decision variance - Cost-efficient — LLM calls are targeted and minimal (only where needed) - Idempotent — built-in dedup mechanisms make repeated runs safe - Interruptible — checkpoint protocol allows graceful stopping at any time --- ## 2. Architecture ``` workflows/.json ← Workflow definition (config, schedule, executor path) ↓ (read by) scripts/workflow-engine.ts ← Lifecycle CLI (start/stop/reset/run/status/history/summary) ↓ (spawns) workflows/executors/