After the Open-Source "Full Stack": How to Systematically Rebuild a Conversational AI Product

    This article explains how engineering teams can systematically rebuild a conversational AI product after an open-source model family becomes available in multiple parameter sizes, inference formats, and adapted versions. It covers a five-layer architecture, scenario-based model selection and deployment, context and session management, streaming output and frontend interaction, content safety, observability, and common pitfalls. The focus is on reproducing the interaction paradigm and capability structure rather than copying a specific vendor's interface or brand.

    1. Background: Engineering Opportunities from a Systematically Opened Model Family

    When a model family is released as a “full stack” with different parameter sizes, inference formats, and adapted versions, the question for engineering teams is no longer whether a model can be used, but how the models should be combined. As model supply shifts from a single option to a matrix, capabilities can be deployed in tiers by scenario: lightweight models handle high-frequency short requests, larger models handle complex reasoning, and distilled versions support on-device use or low-cost canary releases.

    The goal of rebuilding a conversational product should not be to copy a specific vendor’s interface or brand. It should be to reproduce the interaction paradigm and capability structure: multi-turn context, streaming output, interruptible generation, session management, content safety, and observability. Defining the goal clearly gives every later technical decision a basis.

    2. Overall Architecture: Split the System into Five Layers

    A layered design reduces coupling and allows each layer to evolve independently:

    1. Access layer: authentication, rate limiting, canary routing, and protocol conversion;
    2. Session layer: session state, history trimming, and multi-turn context;
    3. Orchestration layer: prompt templates, tool calls, retrieval augmentation, and result assembly;
    4. Inference layer: model serving with unified batching and streaming output;
    5. Support layer: logging, metrics, auditing, content safety, and cost control.

    An illustrative directory structure could look like this:

    1. chat-service/
    2. gateway/ # authentication, rate limiting, canary routing
    3. session/ # sessions and context
    4. orchestrator/ # prompts, tools, retrieval
    5. inference/ # model serving client
    6. safety/ # input and output moderation
    7. observability/ # logs and metrics

    3. Model Selection and Deployment: Tier by Scenario, Not by a Single Strongest Model

    The core selection metric is not the highest overall score, but usable quality per unit of cost. Build an evaluation matrix with dimensions such as instruction following, long-context stability, structured output success rate, time to first token, output tokens per second, concurrency capacity, and GPU memory usage.

    For deployment, three forms can be used: a regular online service handles the main traffic; small-parameter models handle lightweight tasks such as classification, rewriting, and summarization; quantized versions support canary releases and disaster recovery. Inference serving must pay particular attention to dynamic batching, KV cache reuse, and request queuing policies, which directly determine time to first token and throughput.

    4. Context and Session Management: The Key to a Human-Like Experience

    The bottleneck in multi-turn experiences is usually context. Recommended engineering practices include:

    • Layered memory: keep recent dialogue verbatim and compress older dialogue into summaries;
    • Budget control: set token budgets for the system prompt, retrieved snippets, history, and user input;
    • Structured assembly: use stable templates to avoid prompt drift.
    1. def build_messages(system, history, retrieved, user_input, budget=6000):
    2. messages = [{"role": "system", "content": system}]
    3. messages += summarize_if_needed(history, budget // 2)
    4. if retrieved:
    5. messages.append({"role": "system", "content": format_refs(retrieved)})
    6. messages.append({"role": "user", "content": user_input})
    7. return trim_to_budget(messages, budget)

    5. Streaming Output and Frontend Interaction

    A high-fidelity feel comes mainly from interaction details: time to first token, typing rhythm, interruptibility, regeneration, and recoverable errors. The backend should stream content segment by segment, while the frontend renders incrementally and maintains a state machine for “stop generation” and “regenerate.”

    On mobile, pay special attention to consistent input-area behavior: the input box should move up with the keyboard, adapt to safe areas, and allow long text to scroll without covering the send button. These details shape whether users judge the product as a close match, and they matter more than the visual skin.

    6. Content Safety and Compliance

    Safety must be built into the access and orchestration layers from the start: on the input side, detect intent and sensitive information; on the output side, apply compliance checks and refusal policies. Keep auditable logs across the full pipeline and store sensitive fields in masked form. When external retrieval is involved, apply source allowlists and summary constraints to prevent uncontrolled content from entering prompts.

    7. Observability and Acceptance

    Acceptance can be split into three metric groups: functional fidelity (whether core capabilities are complete), interaction consistency (latency, streaming, and mobile layout), and stability (error rate, timeout rate, and retry success rate). Build a regression test set for each release and run the same prompts across different model tiers to establish a baseline, avoiding the “switch model and quality degrades” problem.

    8. Common Pitfalls and Recommendations

    • Chasing leaderboard scores while ignoring structured output failure rates;
    • No context budget, which inevitably causes instability in long sessions;
    • Disconnected streaming and error handling, leaving half-finished answers unrecoverable;
    • No safe-area adaptation for the mobile input area, discovered only during acceptance as misalignment.

    The barrier is no longer obtaining a model, but engineering delivery. Solid work on the layered architecture, context budgets, streaming interaction, safety, and observability is what makes it possible to reliably rebuild a high-fidelity conversational product that can keep evolving.