Chapter 5

From OpenClaw to Flowwink

The OpenClaw reference model — how it actually works — and how Flowwink adapted it for multi-tenant business operations.

From OpenClaw to Flowwink — Reference Model and Adaptation

This chapter separates fact from design. Every claim about OpenClaw is verified against its source code. Every Flowwink extension is clearly marked.


What Is Flowwink?

Before diving into architecture, the reader needs context: what does Flowwink actually do?

Flowwink is a B2B SaaS platform — a digital operating system for businesses. It bundles capabilities that normally require 5-10 separate SaaS tools:

ModuleWhat it does
CMSPages, layouts, themes — the company’s web presence
BlogArticles, categories, SEO, scheduled publishing
CRMContacts, companies, leads, deals pipeline, engagement scoring
FormsContact forms, surveys, lead capture with conditional logic
NewsletterSubscriber management, campaign creation, send + tracking
BookingAppointment scheduling with availability rules
E-CommerceProducts, orders, inventory, checkout
WebinarsEvent registration, reminders, follow-up
TicketsSupport ticket system with priority and assignment
Knowledge BaseFAQ and docs powering the public chat agent
AnalyticsSite stats, page views, conversion tracking

Without FlowPilot, Flowwink works as a classic platform. An admin logs in, creates content, manages contacts, sends newsletters — all manually. The platform is a tool.

With FlowPilot, the same platform becomes autonomous. The agent operates the CMS, writes blog posts, qualifies leads, sends newsletters, analyzes performance — all without being asked. The platform becomes a digital employee.

This dual nature — tool when you’re driving, employee when you’re not — is what makes Flowwink unique. The rest of this chapter dissects how both modes work architecturally.


The Core Insight

OpenClaw’s fundamental insight — shared by all agentic systems that followed — is: the agent is not the model. The agent is the system around the model.

The LLM is a reasoning engine. The agent is the orchestration layer that decides what the LLM sees, what tools it can use, what it remembers, and when it acts.

┌─────────────────────────────────────────────────────┐
│                   THE AGENT SYSTEM                   │
│                                                     │
│  ┌─────────┐  ┌─────────┐  ┌─────────────────┐    │
│  │ Memory  │  │ Skills  │  │   Prompt        │    │
│  │ System  │  │ Registry│  │   Compiler      │    │
│  └────┬────┘  └────┬────┘  └────────┬────────┘    │
│       │            │                │              │
│       └────────────┼────────────────┘              │
│                    │                               │
│                    ▼                               │
│           ┌───────────────┐                        │
│           │  LLM (reason) │                        │
│           └───────┬───────┘                        │
│                   │                               │
│                   ▼                               │
│           ┌───────────────┐                        │
│           │ Tool Router   │                        │
│           └───────┬───────┘                        │
│                   │                               │
│       ┌───────────┼───────────┐                    │
│       ▼           ▼           ▼                    │
│   Built-in    Skills      External                 │
│   Tools       (on-demand) (webhooks)               │
└─────────────────────────────────────────────────────┘

This architectural pattern — separating the reasoning core from skills, memory, surfaces, and infrastructure — is what both OpenClaw and Flowwink converge on. The implementation details differ significantly.


Part 1: The OpenClaw Reference Model

All claims in this section are verified against the OpenClaw source code at /Users/mafr/Code/github/openclaw.

How OpenClaw’s System Prompt Works

OpenClaw builds a system prompt from fixed sections. There is no “nine-layer” abstraction — the prompt is assembled directly:

SectionPurposeVerified Source
ToolingCurrent tool list + short descriptionsdocs/concepts/system-prompt.md:19
SafetyGuardrail reminder against power-seeking behaviordocs/concepts/system-prompt.md:20
SkillsCompact list with file paths; model reads SKILL.md on demanddocs/concepts/system-prompt.md:107-121
Self-UpdateHow to run config.apply and update.rundocs/concepts/system-prompt.md:22
WorkspaceWorking directory pathdocs/concepts/system-prompt.md:23
DocumentationLocal path to docs + ClawHub referencedocs/concepts/system-prompt.md:24
Workspace FilesInjected: AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, BOOTSTRAP.md, MEMORY.mddocs/concepts/system-prompt.md:51-67
SandboxSandboxed runtime info (when enabled)docs/concepts/system-prompt.md:26
Current DateUser-local time + timezonedocs/concepts/system-prompt.md:27
Reply TagsOptional reply tag syntaxdocs/concepts/system-prompt.md:28
HeartbeatsHeartbeat prompt + ack behaviordocs/concepts/system-prompt.md:29
RuntimeHost, OS, node, model, repo rootdocs/concepts/system-prompt.md:30
ReasoningVisibility level + reasoning toggledocs/concepts/system-prompt.md:31

Key constraints:

  • Bootstrap files (workspace files) are capped at 20,000 chars per file, 150,000 chars total (agents.defaults.bootstrapMaxChars, bootstrapTotalMaxChars)
  • Skills are NOT injected as full instructions — only name, description, and file path. The model reads SKILL.md on demand via the read tool
  • Sub-agent sessions only inject AGENTS.md + TOOLS.md (no soul, identity, heartbeat, etc.)

How OpenClaw’s Skill System Works

Skills are file-based. Each skill is a directory containing a SKILL.md file:

~/.openclaw/workspace/skills/
  ├── weather/
  │   └── SKILL.md
  ├── github/
  │   └── SKILL.md
  └── canvas/
      └── SKILL.md

Discovery: OpenClaw watches skills/*/SKILL.md for changes and auto-discovers new skills (src/agents/skills/refresh.ts:85-93).

Loading: The system prompt includes a compact list:

<available_skills>
  <skill>
    <name>weather</name>
    <description>Check weather for any city</description>
    <location>~/.openclaw/workspace/skills/weather/SKILL.md</location>
  </skill>
</available_skills>

The model then uses the read tool to load SKILL.md when it decides the skill is relevant. This is lazy loading by design — the full skill instructions are never injected into the system prompt unless the model explicitly reads them.

ClawHub: OpenClaw integrates with ClawHub, a skill/plugin marketplace. Skills can be installed via openclaw plugins install clawhub:<package>.

How OpenClaw’s Memory Works

OpenClaw uses files on disk as its memory system:

FilePurposeVerified Source
AGENTS.mdOperational rules, conventions, safety rulesdocs/concepts/system-prompt.md:55
SOUL.mdPersona, values, tonedocs/concepts/system-prompt.md:56
TOOLS.mdTool preferences, blocked toolsdocs/concepts/system-prompt.md:57
IDENTITY.mdName, role, emoji, avatardocs/concepts/system-prompt.md:58
USER.mdUser preferences, contextdocs/concepts/system-prompt.md:59
HEARTBEAT.mdHeartbeat checklist (what to check on each cycle)docs/concepts/system-prompt.md:60
MEMORY.mdPersistent memory (injected every turn)docs/concepts/system-prompt.md:62
memory/*.mdDaily memory files (on-demand via tools, NOT auto-injected)docs/concepts/system-prompt.md:69-71

These files are injected into the context window on every agent turn. This means they consume tokens. OpenClaw’s approach trades token efficiency for simplicity — no database, no vector search, just files.

How OpenClaw’s Heartbeat Works

  • Default interval: 30 minutes (docs/gateway/heartbeat.md:23)
  • Mechanism: The agent receives the prompt: “Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.”
  • Autonomy: The agent reads its HEARTBEAT.md checklist and decides what to do. There is no fixed protocol — the model reasons about what needs attention.
  • Skip logic: If HEARTBEAT.md is effectively empty (only headers/whitespace), the heartbeat is skipped to save API calls.

How OpenClaw’s A2A Works

OpenClaw provides intra-process session coordination via three tools:

ToolPurposeVerified Source
sessions_listList active sessions with metadatasrc/agents/tools/sessions-list-tool.ts:43
sessions_historyFetch transcript for another sessionsrc/agents/tools/sessions-history-tool.ts:178
sessions_sendSend a message to another sessionsrc/agents/tools/sessions-send-tool.ts:99

This enables multi-agent coordination within a single OpenClaw instance. It is NOT Google’s A2A protocol — it is OpenClaw’s own session-level messaging system.

How OpenClaw’s Concurrency Works

  • Queue-based: default lane (main) processes inbound + main heartbeats
  • Configurable via agents.defaults.maxConcurrent for parallel sessions
  • Sub-agents get isolated sessions with separate context

Part 2: How Flowwink Adapts the Pattern

Everything in this section is Flowwink’s own design. It is inspired by OpenClaw but architecturally different.

The Multi-Tenant Shift

OpenClaw is single-user: one human, one agent, files on disk. Flowwink is multi-tenant: many businesses, each with their own agent, data isolated via Supabase Row-Level Security (RLS).

This changes everything:

ConcernOpenClawFlowwink
StorageMarkdown files on diskPostgreSQL tables with RLS
AuthChannel allowlistsSupabase Auth + JWT
RuntimeNode.js Gateway daemonDeno Edge Functions (Supabase)
ProtocolWebSocket control planeHTTP/SSE
Multi-agentSession tools within one processSeparate edge functions per surface

Flowwink’s Edge Functions

Flowwink runs on Supabase Edge Functions (Deno). Each function serves a specific role in the agent system:

Edge FunctionTriggerPurpose
agent-operateAdmin sends messageInteractive session — admin talks to FlowPilot
chat-completionVisitor sends messagePublic chat — visitor talks to the public-facing agent
flowpilot-heartbeat12h cronAutonomous cycle — 7-step protocol (self-heal, propose, plan, advance, automate, reflect, remember)
agent-executeCalled by reason coreSkill execution gateway — routes to correct handler, enforces approval gating
agent-reasonCalled by any surfaceShared reasoning core — ReAct loop, prompt compilation, tool routing
signal-ingestWebhookExternal event ingestion — form submissions, payment events, etc.
agent-cardGET requestA2A discovery — publishes agent capabilities to peers
a2a-ingestPOST from peerA2A gateway — authenticates peer, routes to skill or chat
a2a-outboundAgent calls peerA2A outbound — calls external agents
a2a-discoverAgent needs peer infoA2A discovery — fetches remote Agent Cards
setup-flowpilotAdmin triggers onboardingSeeds soul, identity, skills, memory for a new agent

Key principle: agent-reason is the shared module. agent-operate, chat-completion, and flowpilot-heartbeat all call it with different configurations — scope, streaming mode, and context. No logic duplication.

The Dual-Agent Architecture

Flowwink runs two separate agent surfaces that share the same reasoning core but have different capabilities:

┌──────────────────────────────────────────────┐
│              agent-reason.ts                  │
│         (shared reasoning module)             │
└──────────────────┬───────────────────────────┘

        ┌──────────┴──────────┐
        ▼                     ▼
┌───────────────┐    ┌──────────────────┐
│  FlowAgent    │    │  Public Chat     │
│  (admin)      │    │  (visitors)      │
│               │    │                  │
│  scope:       │    │  scope:          │
│  internal     │    │  external        │
│               │    │                  │
│  Can:         │    │  Can:            │
│  - Write blog │    │  - Answer FAQs   │
│  - Send email │    │  - Book meetings │
│  - Manage CRM │    │  - Capture leads │
│  - Run reports│    │  - Recommend     │
│  - Approve    │    │                  │
│    actions    │    │  Cannot:         │
│               │    │  - Modify data   │
│               │    │  - Access admin  │
│               │    │  - Send emails   │
└───────────────┘    └──────────────────┘

FlowAgent (admin-side, agent-operate):

  • Triggered by the business owner via the admin UI
  • Has access to ALL skills marked internal or both
  • Can draft content, manage CRM, analyze data, send newsletters
  • Destructive actions require approval (requires_approval: true)

Public Chat (visitor-side, chat-completion):

  • Triggered by website visitors
  • Only has access to skills marked external or both
  • Can answer questions from knowledge base, book appointments, capture lead info
  • Cannot modify any data — read-only + booking

Why this matters: The scope system (internal/external/both) enforces this separation at the architecture level. A visitor can never accidentally access admin tools. An admin can never accidentally expose internal operations to visitors.

Flowwink’s Prompt Architecture

Flowwink assembles its system prompt from 9 ordered layers. This is Flowwink’s design, not OpenClaw’s:

#LayerPurposeSource
1Core InstructionsGrounding rules, safety, mode identityHardcoded
2Tool DefinitionsWhat the agent can doBuilt-in + DB skills
3Skills RegistryAvailable capabilitiesagent_skills table
4Model AliasesProvider routingAI config resolver
5Protocol SpecsReply directives, output formatParser rules
6Runtime InfoDomain context (CMS schema, data counts)Domain pack
7Workspace FilesSoul, identity, operational rulesagent_memory keys
8Bootstrap HooksSkill instructions (lazy loaded)On-demand fetch
9Inbound ContextCurrent conversation + objectives + memorySession data

Loading strategy:

  • Layers 1-3: loaded at startup (static)
  • Layers 4-6: loaded per-session (configurable)
  • Layers 7-9: loaded per-turn (dynamic)

Flowwink’s ReAct Loop

The reasoning core uses a ReAct (Reason → Act → Observe) loop. The general pattern is shared with OpenClaw and other agentic systems, but the constants are Flowwink-specific:

Input (message / heartbeat / event)


┌─── reason() ────────────────────────────────────┐
│                                                  │
│  1. Build system prompt (9 layers)               │
│  2. Assemble tools (built-in + DB skills)        │
│  3. Call LLM                                     │
│                                                  │
│  4. LLM returns response:                        │
│     ├── Text only → return to surface            │
│     └── Tool calls → execute each:               │
│         ├── Built-in tool → handlers.ts          │
│         └── DB skill → handler router            │
│                                                  │
│  5. Append tool results to conversation          │
│  6. Budget check (tokens, iterations)            │
│  7. If budget OK and more tool calls → go to 3  │
│  8. Return final response                        │
│                                                  │
└──────────────────────────────────────────────────┘


   Response (text / SSE stream / tool results)

Flowwink-specific constants:

  • MAX_ITERATIONS = 6 (interactive) / 8 (heartbeat)
  • MAX_CONTEXT_TOKENS = 80,000
  • SUMMARY_THRESHOLD = 60,000 (triggers compaction)

Flowwink’s Handler Abstraction

Flowwink decouples skill definitions from implementations using handler strings. This is Flowwink’s design — OpenClaw does not use this pattern:

PrefixImplementationExample
edge:Supabase Edge Functionedge:qualify-lead
module:In-process handlermodule:blog
db:Direct database querydb:page_views
webhook:External HTTP callwebhook:n8n
a2a:Agent-to-agent peera2a:SoundSpace

This means you can change how a skill is implemented without changing the agent’s understanding of what it does.

Flowwink’s Memory Architecture

Flowwink replaces OpenClaw’s file-based memory with a 4-tier PostgreSQL system. This is Flowwink’s design — OpenClaw uses files on disk:

TierWhatStorageAccess
L1: SessionCurrent conversationIn-memory / chat_messagesLinear scan
L2: WorkingRecent memories (top 20-30)agent_memoryKey/category filter
L3: Long-termAll persisted factsagent_memoryFull-text search
L4: SemanticVector embeddingsagent_memory.embeddingpgvector cosine similarity

The concept categories (soul, identity, agents, facts, preferences) mirror OpenClaw’s workspace files but live in database rows instead of markdown files.

Flowwink’s Three Surfaces

SurfaceTriggerModePurpose
InteractiveUser messageStreamingReal-time conversation
AutonomousCron/scheduleNon-streamingSelf-directed operation
ExternalEvent/webhookNon-streamingReactive processing

In Flowwink:

  • Interactive = agent-operate (admin) / chat-completion (visitor)
  • Autonomous = flowpilot-heartbeat (12h cron)
  • External = signal-ingest (webhook endpoint)

All three surfaces share the same reasoning core. This is LAW 10: Unified Reasoning Core. No logic duplication.

Flowwink’s Concurrency Model

Lane-based locking — Flowwink’s design:

heartbeat    → lane: "heartbeat"           (TTL: 15 min)
operate      → lane: "operate:{convId}"    (TTL: 5 min)

Lane-based locking prevents:

  • Two heartbeats running simultaneously
  • Multiple operate sessions colliding
  • Resource contention on shared state

The lock is time-boxed (TTL) — if the agent crashes, the lock auto-expires. No zombie locks.

Flowwink’s Safety Architecture

LayerMechanismPurpose
Skill scopeinternal / external / bothPrevent visitor-facing agents from accessing admin tools
Approval gatingrequires_approval: trueHuman must approve destructive actions
Self-healingAuto-quarantine after 3 failuresPrevent cascading failures
Token budgetHard limit on context sizePrevent runaway costs
Iteration capMax 6-8 tool roundsPrevent infinite loops
Wall-clock timeout120s hard abortPrevent hung processes
Grounding rulesHardcoded in prompt layer 1Safety rules that can never be overridden

Why This Architecture Works

This architecture works because it separates concerns:

  1. Surfaces handle I/O (how the agent communicates)
  2. Reasoning core handles cognition (how the agent thinks)
  3. Skills handle capability (what the agent can do)
  4. Memory handles continuity (what the agent knows)
  5. Infrastructure handles reliability (how the agent runs)

Each layer can evolve independently. You can add new channels without touching the reasoning core. You can add new skills without changing the memory system. You can upgrade the LLM without rewriting the surfaces.

This is the principle that makes agentic systems maintainable: separation of concerns at the architectural level.

OpenClaw proved the pattern with 346k+ GitHub stars and production deployments worldwide. Flowwink adapted it for multi-tenant business operations — same brain, different body.


OpenClaw is the reference. Flowwink is the adaptation. Understanding both — and where they differ — is the foundation for building your own agentic system.

Next: the control plane layer — Claude Code, Cursor, thin wrappers, and what creates a real moat. The Agentic Control Plane →

This is your handbook

Agentic AI is evolving fast. The patterns, the laws, the architecture — they need to stay current with the community's collective knowledge. I want this to become the go-to resource for anyone learning how autonomous agents work.

Whether you fix a typo, add a chapter, share a production story, or challenge an assumption — every contribution makes this better for everyone.