PHII Labs

AI Systems28 October 2025 · 9 min read

How to build an AI agent that survives production

The architecture pattern behind every PHII Labs project: capture, reason, route, act, and why most agent prototypes fail at routing

Sergei · PHII Labs · Updated 2026-10-01

The capture-reason-route-act architecture behind AI agents

Every PHII Labs project follows one pattern: capture signals, reason on them, route actions, and surface outcomes. Most agent prototypes fail because they skip routing. This guide is for founders and ops leads who want to know how to build an AI agent that survives real traffic, not just a demo

How does an AI agent system work?

It runs five steps: ingest, reason, route, act and observe. The table shows what each does and where it typically breaks; the sections below explain each one.

StepWhat it doesTypical failure
IngestConverts, validates and queues signals from every channelTied to reasoning, so each new channel forces a rewrite
ReasonClassifies intent, scores urgency, proposes a decisionModel triggers side effects directly
RouteMaps the decision to a concrete action with explicit rulesRouting buried in prompt instructions
ActCalls APIs and databases with retries and idempotencyAI in the action layer, so execution is unreliable
ObserveLogs the full chain from signal to actionNo audit trail, so operators don't trust it

1. Ingest

Signals come from many sources: voice messages, chat, webhooks, search queries, form submissions. The first job is to turn them into a single stream. The system doesn't "process a WhatsApp message" or "handle a form post". It records "we received a signal of type X with payload Y"

The ingest layer has no business logic. It converts, validates and queues. Keep it separate, because signal sources change often. If ingest is tied tightly to reasoning, every new channel forces a rewrite

2. Reason

The LLM works in this layer. Given a normalized signal, it classifies intent, scores urgency, extracts entities and decides what should happen next

The key design choice is that the LLM proposes and the system decides. The model returns a structured decision (route to human, send automated reply, create task, escalate), and the system enforces it. Never let the model trigger side effects directly. This matches how tool use works in practice. The model returns a structured call and your application executes it. The model can say "send this reply", but the system checks that the reply is allowed, the recipient is valid and the rate limit is respected

3. Route

Prototypes die at this step. Routing takes a decision from the reasoning layer and maps it to a concrete action in a real system: create a CRM lead, send a WhatsApp message, file a ticket, update a dashboard

Routing fails when it's implicit, buried in prompt instructions like "if the user seems angry, escalate to a human." That works in a demo and breaks in production. Real routing is explicit. A rules engine or state machine takes the structured output of the reasoning layer and runs deterministic, auditable actions. Anthropic draws the same line between workflows, where LLMs and tools are orchestrated through predefined code paths, and agents that direct their own processes, and recommends finding the simplest solution possible and adding complexity only when needed. When you're choosing between a visual workflow tool and custom code for this layer, n8n vs a custom AI agent shows where n8n stops scaling

4. Act

The action layer is the interface to the outside world: APIs, databases, message queues, notification systems. We keep it boring on purpose. There is no AI here, only reliable execution with retries, idempotency and logging

5. Observe

Every step is logged, partly for debugging and mostly for trust. When a user asks "why did the system do X?", you need to show the full chain: signal received, classified as Y, routed to Z, action taken at timestamp T. Operators only hand real work to an AI system once they can see that chain. The same source suggests agents pause for human feedback at checkpoints and recommends extensive testing in sandboxed environments with appropriate guardrails. Keeping that chain visible after launch is ongoing work, and our breakdown of AI maintenance costs in Dubai shows what to budget for it

Why do most AI agent prototypes fail in production?

Prototypes fail at routing because builders treat the LLM as the whole system. They ask the model to decide and act in one step. That works for a demo, which is also why a proof of concept leaves some risks for the MVP to settle, as our AI POC vs MVP guide explains. In production:

  • The model invents an action the system doesn't support
  • The model sends a reply that violates a business rule
  • The model escalates when it shouldn't, or doesn't when it should
  • There's no audit trail, because the decision happened inside a prompt
Prototypes die at routing. A model told to escalate if the user seems angry works in a demo and breaks in production. The fix is to separate reasoning from routing, make the routing explicit and deterministic, and log every step.
Sergei · PHII Labs

The fix is to separate reasoning from routing, make routing explicit and deterministic, and log every step. That's the PHII pattern, and it's why our systems keep working once real users arrive

We build this for UAE businessesAI automation in Dubai: custom agents and workflows

Questions people ask

What makes an AI agent different from a chatbot?

An agent system ingests signals, reasons over them, routes decisions and acts on external systems. A chatbot only answers messages; the difference is the routing and action layers, not the model

Why do most AI agent prototypes fail in production?

They fail at routing: implicit escalation rules buried in prompts break under real traffic. Production systems need explicit state machines and deterministic, auditable actions

How does an agent system act on real business data?

Through explicit integrations with your CRM, inbox and ticketing tools. The agent writes back structured results, so every action is logged and reversible instead of trapped in a chat window

How is an AI agent different from workflow automation?

Workflow tools move data between fixed steps; an agent reasons over unstructured input first, then routes and acts. When the workflow stops scaling, the agent layer replaces the brittle decision points

Find out what AI tells your buyers about you

We ask six AI engines 10 questions your buyers ask, then send you their answers and how to fix each problem. On WhatsApp, within 48 hours

10 questions like these

  • Best dental clinic near JLT?
  • Who does teeth whitening in Dubai Marina?
  • Dentist open late in JLT?
  • + 7 more

in each of 6 AI engines

  • ChatGPT
  • Gemini
  • Claude
  • Perplexity
  • Google AI
  • Grok

Example: a dental clinic