Skip to main content

The Two-Phase Engine

Daemo achieves its deterministic reliability by enforcing a strict architectural separation between Data Retrieval and Response Generation.

Every user query undergoes a rigorous two-step process: [1] Reasoning (The Engineer) and [2] Presentation (The Analyst).

Why Two Phases?

Standard chatbots combine logic and writing in a single pass. This leads to hallucination: the AI attempts to write a confident sentence before it has actually verified the underlying numbers.

Daemo forces a separation of concerns:

  1. Phase 1 (The Engineer): Get the facts right. (No talking, strictly execution).
  2. Phase 2 (The Analyst): Explain the facts. (No new data fetching, strictly formatting).

Phase 1: The Engineer (Reasoning Logic)

Goal: Fetch, validate, and structure the data. Privileges: Full access to registered SDK functions. Output: A strictly typed VerifiedData object.

The Engineer is a rigorous logic engine designed to solve the "Blank Page" problem. It does not care about grammar, tone, or user persona; it only cares about data correctness and logical consistency.

The Reasoning Loop

  1. Intent Analysis: The Engine analyzes the request: "The user wants sales trends. I need to fetch data for the last 12 months and calculate the growth rate."
  2. Plan Synthesis: It constructs a deterministic Execution Plan—a sequence of logic steps required to retrieve and process the data.
// The Engine synthesizes logic to solve the problem
const sales = await SalesService.getMonthlySales({ months: 12 });
const growth = calculateGrowth(sales); // Computes derived data
return { trend: "up", data: sales, growth: growth };

  1. Hermetic Execution: The Daemo Kernel executes this plan in an isolated, ephemeral runtime. This ensures that the logic runs with strict resource limits and no unauthorized side effects.
  2. Validation: The runtime returns the actual data object.
Note

Self-Correction: If the data returned is incomplete or the API throws an error, the Engineer will catch the exception, refine its plan, and retry the execution (e.g., "The API returned a 400 error; I will try fetching with a different date format").


Phase 2: The Analyst (Presentation)

Goal: Explain the findings to the user. Privileges: None (Read-only access to VerifiedData). Output: Natural language, Markdown tables, or Charts.

Once the Engineer has produced the verified payload, the Analyst takes over. The Analyst is an articulate communicator that takes the raw data and presents it according to the user's specific context.

The "Zero-Hallucination" Guarantee

Because the Analyst cannot call tools and cannot execute code, it is architecturally impossible for it to invent new actions or data points. It is constrained strictly to the facts provided by the Engineer.

  • If the Engineer found $500: The Analyst must report $500.
  • If the Engineer failed: The Analyst must report "Data unavailable."

Example Trace

User Query: "What were our top 5 products last quarter?"

Step 1: Execution Plan (The Engineer)

The Engine determines that it needs to define a date range, query the sales service, and perform a client-side sort to filter the top results.

// Logic executed inside the Safety Airlock
const quarterStart = new Date('2024-10-01');
const quarterEnd = new Date('2024-12-31');

const salesData = await SalesService.getProductSales({
startDate: quarterStart,
endDate: quarterEnd
});

// The Engine performs math/logic that LLMs typically fail at
const top5 = salesData
.sort((a, b) => b.totalRevenue - a.totalRevenue)
.slice(0, 5);

return {
finalPayload: {
period: "Q4 2024",
products: top5.map(p => ({
name: p.productName,
revenue: p.totalRevenue
}))
}
};

Step 2: Final Response (The Analyst)

The Analyst receives the finalPayload and formats it for the user.

Top 5 Products for Q4 2024

RankProductRevenue
1Widget Pro$125,400
2Gadget Plus$98,200
.........

Widget Pro was the clear winner this quarter.


Summary

FeaturePhase 1 (Engineer)Phase 2 (Analyst)
Primary JobExecution & LogicCommunication
OutputStructured DataNatural Language / Markdown
Tool AccessRead/Write (Can call your API)None (Read-only)
SafetyValidated by Runtime KernelConstrained by Input Data