The Engaging Way
Adam S KhanDesigner/developer

4 min read

15 hours ago

From chatbot to heartbeat: An architectural pattern for the AI workforce

Treat AI agents as actual user accounts in your system.

Adam S KhanDesigner/developer

4 min read

15 hours ago

The Engaging Way

For the past few years, the software industry’s mental model of AI has been dominated by the chat window; a human types a prompt, an external client hits an LLM API, and text streams back. It is client-driven, stateless, and disconnected from the deep plumbing of enterprise software.

But what happens when you strip away the chat interface and wire intelligence directly into the backend of a software platform?

When building an autonomous, heartbeat-driven system where AI actors operate alongside humans, traditional chatbot architectures fall apart. Here is a breakdown of the novel, architectural pattern driving Engaging OS that treats AI not as an external tool, but as a virtual employee.

1. From Client-Driven Chat to Server-Driven Heartbeats

In traditional setups, the intelligence lives in the client (a browser tab, a desktop app, or a mobile chat UI) poking your server from the outside.

In a heartbeat-driven architecture, the backend server becomes another brain:

  • The Pulse: A background worker or cron job ticks on a regular interval.

  • The Routine: Instead of waiting for a human to click a button, the server itself executes a background evaluation loop. It pulls system state, queries an LLM API internally, and immediately routes decisions through native system boundaries.

  • The Result: The system runs headless at 3:00am, making operational decisions without a human or a chat client anywhere in sight.

2. AI as a First-Class Citizen: The “Virtual Employee” Model

The tech world is currently enamored by the thought of spinning up thousands of ephemeral AI agent swarms in cloud containers that execute and disappear. But this is a governance nightmare in production, where data is audited and permissions matter.

A cleaner enterprise solution is to treat AI agents as actual user accounts in your system:

  • Shared Permissions: The AI accountant and the human accountant share much the same role-based access control (RBAC). They both walk through the same system doors, albeit the AI is labeled as such and may lack some access reserved for humans.

  • Organizational Structure: Just like humans, AI workers hold positions within the body of the organization. Their capabilities are bounded by their position's permissions, not hardcoded script hacks.

  • The is_ai Flag: A simple boolean flag on the user record dictates how the platform treats them. For humans, the system waits for a mouse click. For AI users, the heartbeat triggers the LLM evaluation loop.

  • Built-In Accountability: Because every action is stamped with a user ID, your audit logs don't say System_Action_Complete—they tell you precisely which digital employee made the call.

3. The Dashboard Is the Queue

Traditional agentic systems rely on complex secondary messaging queues (like RabbitMQ or Redis pub/sub) to pass tasks around. But if your platform already features a GTD-style dashboard with an "Awaiting" work areas, you already have your queue: the consoles within it.

  • The Consoles: Every user role has a dashboard view. The rows sitting in an account's "Awaiting" console are the work items.

  • Frictionless Handoffs: Because the AI and the humans share the same dashboard architecture, task hand-offs are trivial. If an AI worker encounters a task too ambiguous to process, it doesn't crash—it simply leaves it in the console, flags it, or reassigns the row to a human supervisor's desk.

4. The Hybrid Engine: Deterministic Rules Meet Cognitive AI

Not every operation requires an expensive, high-latency LLM call. A robust platform uses a hybrid routing engine controlled by the operation's metadata (e.g., a requires_llm flag):

  • Deterministic Path (requires_llm = false): Hardcoded business rules and mathematical checks evaluate instantly via native code. Zero API tokens spent, zero latency.

  • Cognitive Path (requires_llm = true): When fuzzy logic, text generation, or semantic judgment is required, the system packages the row's context, attaches the operation's specific prompt, and queries the LLM.

5. Ports as Absolute Safety Boundaries

All system activity flows through strictly defined entry/exit surfaces called ports. Whether a human clicks a button or an AI worker evaluates a queue item via the heartbeat, the execution must pass through these ports.

This design creates an uncompromised security boundary. The AI doesn't write raw SQL or execute arbitrary code; it can only invoke the pre-approved operations exposed by the port.

"There is no center; the data is the center. The ports are the lenses through which actors observe and mutate state."

Summary: Building an Organization, Not an App

When you combine a heartbeat loop, user-account-backed AI actors, dashboard console queues, and port-level security, you stop building a standard CRUD application. You are building a hybrid workforce architecture—a living platform where humans and digital employees share the same workspace, play by the same rules, and safely run the business around the clock.