8 min readUpdated: November 24, 2026

AI-Generated Sales Logic in Production: Six Patterns from QuotyAI's Coding Agent

How QuotyAI turns business-rule edits into versioned, tested releases—and why deterministic execution still needs validation, review, and rollback.

Available in:

When a spa owner says “we added Thai massage, 200 baht,” one sentence can touch several resources: the catalog, the order model, the pricing script, availability rules, and sometimes an automation. Get the sequence wrong and the assistant can quote a service that does not exist, apply a stale price, or accept an order it should reject.

Most AI platforms hand that entire cascade to a language model and hope it remembers every dependency. I do not trust hope with business logic.

At QuotyAI, the model helps interpret the request and draft changes. Code defines the structure: dependencies, write scopes, artifact contracts, tests, release environments, and rollback. The model can still misunderstand the owner. The generated rule can still be wrong. The difference is that those mistakes meet a pipeline instead of reaching a customer silently.

Update note — November 24, 2026: This post was originally titled “Codex for Sales.” It is about QuotyAI’s own builder, not OpenAI Codex. The current repository uses LangChain createAgent and LangGraph; the DeepAgents design described in the first draft is historical. OpenAI’s Codex documentation describes a separate coding-agent product.


1. LLM for Meaning, Code for Structure

The first boundary is simple: use the model where language judgment helps, and use code where the shape of the operation is already known.

“Add Thai massage, 200 baht” must become structured data before anything is edited. A schema can constrain the output:

import { z } from 'zod';

const IntentSchema = z.object({
  mode: z.enum(['query', 'update']),
  task: z.string(),
  missingFacts: z.array(z.string()),
});

The current builder uses structured output for tool arguments and decision fields. But structured output is not a truth machine. It makes the response parseable; it does not guarantee that task captures what the owner meant. That is why ambiguous requests still need a question.

Everything after extraction should be inspectable: which agent owns the task, which files it may write, which artifacts depend on those files, and which checks must pass.


2. Model Dependencies as Data, Not Prompt Folklore

A dependency graph written only in a prompt drifts. Someone edits the prompt, the graph changes, and nobody notices until a release is inconsistent.

QuotyAI keeps dependencies in code. As of November 2026, there are five skills:

aiPersona       (independent)
catalog         (independent)
dataCollector   → catalog
checkout        → catalog + dataCollector
agentPlugins    → catalog + dataCollector + checkout

The catalog computes a topological order, detects cycles, and exposes upstream artifacts to editors. The commit gate also revalidates declared dependents when a file changes. If the catalog schema changes, the checkout scripts do not get a free pass just because this run did not edit them.

The diagram below preserves the earlier offerings-to-pricing cascade from the original article. It is useful intuition, but it is not the current five-skill graph.

Earlier dependency graph from the July 2026 architecture: offerings_schema feeds order_schema, which feeds pricing, scheduling, and validation

Historical diagram from the original DeepAgents design; the current dependency graph is the five-skill graph above.


3. A Release Lifecycle, Not a Chat Log

The current lifecycle is deliberately boring:

Thread workspace → validated release in In Development → published live
                         ↘ discarded or left unpublished
Live release → rollback to an earlier release

A workspace is a draft. Committing merges it into a versioned release in next; it does not make the change customer-visible. Publishing is a separate action that moves live forward. The release tool refuses inconsistent releases and returns the blockers.

Promotion, discard, and rollback use a compare-and-swap update on the environment pointer. If another operator moved the pointer first, the operation fails instead of overwriting their work. The environment service also records who performed the transition and why.

This is “git-like,” not git. It gives the business owner the part that matters: a reviewable draft, a named release, an explicit publish step, and a way back.


4. Specialist Agents With Write Scopes

The current skill-builder graph has 15 roles: intake, general edit, catalog update, price update, customer questions, order rules, catalog item edit, catalog import, promotion, availability, automation, diagnose, audit, persona, and delivery.

That sounds like a lot. The point is not agent count. The point is ownership.

A price update should change a price-bearing catalog value. An order-rules edit should change checkout rules. Each editing agent delegates to one of five skill editors—catalog, checkout, data collector, agent plugins, or persona—with a closed set of writable artifacts. Test editing and asset analysis have their own helpers.

The orchestrator does not get a universal write_anything tool. If a change crosses an ownership boundary, the owning editor must handle it. That rule is enforced by the commit gate, not just requested in a prompt.

Historical orchestrator diagram showing intent routing, editing subagents, code generation, validation, approval, and deployment

Historical diagram from the original nine-generator design. The current implementation uses specialist LangGraph agents and scoped skill editors; the lifecycle principle is unchanged.


5. Ask Before You Cascade

A short clarification is cheaper than a confident wrong release.

The current builder uses a real ask_user interrupt: the run pauses, the owner answers, and execution resumes with the answer. “Hide it” and “delete it” are different operations. “Member price” and “member eligibility” are different facts.

I learned this class of lesson the hard way in earlier sales assistants. The fix was not a longer prompt telling the model to be careful. The fix was to make ambiguity visible before the write.


6. Validate the Artifacts, Then Test the Behavior

There are two different questions:

  1. Does the artifact satisfy its contract? Schemas parse, references resolve, plugins match declared assets, migrations exist, and dependent files remain consistent.
  2. Does the business behavior make sense? A checkout test suite exercises pricing, validation, and availability scripts with concrete cases.

The commit-readiness gate handles the first question and runs the suite for the second. A failed case blocks the commit.

Generated JavaScript also executes in a restricted vm context with an allowlisted set of globals and a five-second synchronous timeout. That bounds accidental loops and removes obvious access to require, fetch, and process. It is not a complete security boundary: the Node.js documentation explicitly warns that vm is not a security mechanism. Hostile or high-risk generated code still needs process or container isolation.

The same limitation applies to determinism. The pricing runner repeats execution for the same input, code, and dependencies. It cannot tell you that the owner’s discount policy was captured correctly.


What Did Not Work

One agent editing everything. It was easy to demo and hard to reason about. A failure could cross several ownership boundaries before anyone saw it.

A dependency graph that lived only in prose. Prompt edits changed behavior without changing code review. Moving the graph into the artifact catalog made dependencies testable.

Letting the model publish directly. Generation and publication have different risk profiles. Keeping them separate gives the owner a deliberate go-live decision.

I am not publishing success-rate or latency tables here. Those earlier figures were private operational observations, not independently reproducible benchmarks. The architecture claims above can be checked in the repository; the performance claims should be measured in your own workload.


When to Use This Architecture

Use it when:

  • Generated resources depend on one another.
  • A wrong release has a real operational cost.
  • You need a draft, tests, an explicit publish step, and rollback.
  • You can define artifact contracts and representative business cases.

Skip it when the content is independent, mistakes are cheap, and a simpler review flow is enough. Deterministic infrastructure is not free; it earns its keep when consistency matters.


TL;DR

Layer Pattern
Language Model extracts intent; ambiguity triggers a question
Structure Dependencies and write scopes live in code
Lifecycle Workspace → validated release → publish → rollback
Ownership Specialist agents delegate to scoped skill editors
Verification Artifact contracts + dependent checks + behavior tests
Execution Repeatable code path, bounded by version and dependencies


Frequently Asked Questions

How do you safely update AI-generated business logic in production? Keep edits in a thread workspace, validate the changed artifacts and their dependents, commit a versioned release to In Development, and publish it to the live environment only when the owner asks. Use compare-and-swap pointer updates so concurrent promotions cannot silently overwrite each other, and keep rollback available.

What does deterministic mean here? The same input, code version, and dependencies produce the same execution path and result. That does not make generated code correct: intent extraction can misunderstand the owner, generated rules can encode the wrong policy, and external systems can fail. Validation, representative tests, review, and rollback are still required.

What is the difference between specialist agents and skill editors? Specialist agents own a task such as updating a catalog item, changing a price, or editing order rules. They delegate file changes to skill editors with declared write scopes. The current graph has 15 agent roles and five skill editors, plus test and asset-analysis helpers.

How does QuotyAI validate generated code before release? The commit gate checks registered artifact contracts, validates changed files and declared dependents, checks schema versions and migrations, and runs the checkout test suite. Generated JavaScript also runs in a restricted vm context with a five-second synchronous timeout. These checks reduce risk but cannot prove that the business rules themselves are correct.

Is this article about OpenAI Codex? No. The original headline used Codex loosely, but the system described here is QuotyAI’s own coding-agent architecture. OpenAI Codex is a separate agent harness. The current QuotyAI repository uses LangChain createAgent and LangGraph; its earlier DeepAgents implementation is historical.


Sources


Tags: ai-agents business-logic code-generation typescript langchain deterministic-ai

Found this useful? Share it.

Related articles