Engineering Practices and Acceptance Methods for Rebuilding a Conversational Web Page with AI Agents

    Rebuilding a chat-style web page with AI agents goes far beyond UI cloning—it requires clear requirements, state management, streaming output handling, credential security, and layered testing. This article presents a complete engineering workflow for agent-driven development: organizing deliverables into functional documentation, a baseline implementation, and iterative improvements; modeling conversation state with explicit state machines; handling streaming responses safely; and validating results through structured, traceable testing rather than visual appearance alone.

    1. From “Page Replication” to Conversational Product Engineering

    Having an AI agent develop a conversational web page based on an existing one may look like interface rebuilding, but it actually involves product analysis, interaction design, service integration, state management, data security, and test verification. A page screenshot alone cannot tell whether an implementation is truly usable: an input box that accepts text does not mean requests submit correctly; a page that displays answers does not mean streaming responses, cancel-generation, and history restoration work reliably.

    A more reasonable task definition, therefore, is not “build a page that looks similar,” but “rebuild the core workflows of a comparable conversational product based on properly authorized reference materials, and deliver verifiable engineering outcomes.” The reference should be used to understand interaction patterns—not to copy unauthorized logos, assets, or proprietary designs.

    In practice, multiple models and execution environments were given the same development task, yet their verification depth differed noticeably once credentials were introduced. This is worth abstracting as an engineering question: when requirements are largely identical, why does final quality still vary?

    The answer usually lies beyond the model itself. Outcomes are also shaped by context organization, browsing capabilities, file operation permissions, runtime environments, testing tools, and agent orchestration strategies. Evaluating agent development should focus on the full execution chain rather than attributing every difference to generation capability alone.

    2. Organizing the Task into Three Verifiable Deliverables

    2.1 Functional Documentation and Architecture Diagrams: Define What Needs to Be Built First

    Functional documentation should not merely list modules such as “chat, history, settings.” It should specify, for each feature, the user goal, trigger conditions, state changes, exception handling, and acceptance criteria.

    For the “send message” feature, for example, the documentation should at least answer:

    • Should empty input be submittable?
    • Can users keep editing the input while a request is in flight?
    • How are repeated clicks on send handled?
    • If the service is unavailable, is the user’s input preserved?
    • After canceling generation, how is content already received presented?
    • Does retry create a new message or update the original one?

    These questions determine implementation details—and whether tests can cover real usage scenarios.

    The architecture diagram should express both page structure and data flow, not just navigation bars and content areas. A generic architecture can be represented as:

    User actions
    → Page interaction layer
    → Conversation state management
    → Proprietary server-side API
    → Model service adapter layer
    → External inference service

    At the same time, conversation state management can connect to persistent storage, and the server-side API can connect to authentication, logging, and rate-limiting modules. The diagram should also make the security boundary explicit: the browser is an untrusted runtime environment, and server-side credentials must never enter page resources or client-side logs.

    2.2 Baseline Implementation: Prioritize an End-to-End Loop

    The baseline version aims to make the core workflow work, not to pile up every feature at once. Prioritize:

    • Creating and switching conversations;
    • Typing and sending text messages;
    • Displaying user messages and model responses;
    • Showing waiting, generating, completed, and failed states;
    • Canceling the current generation;
    • Providing clear feedback for failed requests;
    • Saving and restoring history within the agreed scope.

    Extensions such as attachment handling, complex permissions, and multi-user collaboration should be confirmed separately in the requirements. Features without server-side support should not be given a clickable button that creates the illusion of being implemented.

    The baseline version especially needs to distinguish demo data from real service calls. Mocked responses help validate the UI, but they cannot replace real integration testing. If mock data is used temporarily, both the UI and the delivery documentation should clearly state its purpose and limitations.

    2.3 Improved Version: Tie Every Change to a Real Problem

    Improvement should not mean changing colors, adding decoration, or rearranging buttons. More valuable improvements come from user tasks and failure scenarios, for example:

    • Once a long answer appears, users struggle to find their earlier question;
    • When new content keeps arriving, forced scrolling interrupts reading;
    • After a failed request, users must retype the entire message;
    • When switching conversations, responses from the old conversation are written into the new one;
    • Repeated retry clicks cause duplicate requests and duplicate messages.

    Each improvement should form a clear chain:

    Problem description → Design solution → Implementation location → Verification method → Known limitations.

    For the scroll-interruption problem, for instance, you can adopt a strategy of “auto-scroll only when the user is near the bottom”: when the user scrolls up to read, pause auto-following and show a new-content indicator. The acceptance focus is not whether the button looks good, but whether scrolling behavior matches user intent.

    3. How to Structure the Two-Phase Input

    Phase 1: Requirements, Reference Materials, and Constraints

    Phase 1 should not hand the agent nothing but a reference page. The agent needs to know what must be implemented, what can be simplified, and how completion will be proven.

    Recommended inputs include:

    1. Target users and primary usage scenarios;
    2. Authorized page references and API documentation;
    3. The specific scope of the three deliverables;
    4. Available development environment and execution permissions;
    5. Constraints on data storage, security, and deployment;
    6. Acceptance test cases that must be covered;
    7. Capabilities the agent is not allowed to assume on its own.

    Asking the agent to produce an implementation plan first helps surface requirement gaps early. For example, does history only need to be saved on the current device, or synchronized across devices? The two involve different storage and identity systems—developers should not decide on the user’s behalf.

    Phase 2: Configure Credentials and Move to Real Integration

    Phase 2 should be treated as switching from mock development to real service verification—not merely “pasting in an API key.”

    The secure approach is to provide access through server-side configuration or a controlled credential injection mechanism, avoiding writing full credentials into chat logs, code repositories, page source files, or screenshots. The browser only calls your own business API; the server handles calls to the external service.

    After integration, at minimum verify:

    • Whether authentication failures can be detected and explained;
    • Whether normal responses map correctly to the UI;
    • Whether response parsing matches the actual API documentation;
    • Whether request timeouts terminate the waiting state;
    • Whether content already received is preserved when the network drops;
    • Whether cancellation stops frontend consumption and terminates downstream requests according to actual capability;
    • Whether logs contain unnecessary credentials or conversation content.

    Do not conclude that integration is complete because one request succeeded. The value of real integration testing lies in exposing boundary conditions, not just demonstrating the happy path.

    4. State Management Is the Core of a Conversational Web Page

    The problems that plague conversational pages are usually not layout errors but state confusion. Model a single generation process as an explicit state machine:

    Idle → Submitting → Receiving → Completed

    with separate failed and canceled states. Every state transition should correspond to an observable event, rather than multiple scattered variables collectively guessing the current state.

    Requests should be bound to both a conversation identifier and a request identifier. When a response arrives, first confirm which request it belongs to, then update the corresponding conversation. Switching pages or creating a new conversation should not change the data ownership of an in-flight response.

    Also distinguish three classes of data:

    • Persistent data: message content, conversation titles, creation time, etc.;
    • Transient interaction state: input drafts, expanded panels, scroll positions, etc.;
    • Request runtime state: request identifiers, cancellation controls, received fragments, etc.

    Mixing them easily leads to “perpetually generating” indicators after refresh, history messages being overwritten, or drafts silently lost. Proper layering reduces the complexity of state synchronization and restoration.

    5. Streaming Output Requires Dedicated Handling

    A single data fragment in a stream does not necessarily correspond to a complete character, a complete event, or a complete message. Implementation must handle delimiters, encoding, and end markers according to the interface definition—never assume each read yields complete text.

    A reliable processing pipeline typically includes:

    1. Continuously reading response data;
    2. Maintaining decoding and parsing buffers;
    3. Identifying complete events per the protocol;
    4. Extracting displayable content;
    5. Updating the specified message;
    6. Recognizing normal completion, errors, or interruptions;
    7. Releasing connections and temporary resources.

    The page also does not need a full re-render every time a tiny fragment arrives. Updates can be batched without noticeably affecting the real-time experience, avoiding excessive rendering overhead for long answers. Concrete strategies should be determined through actual measurement—do not assert fixed performance conclusions out of thin air.

    Content display also involves security. Model output should be treated as untrusted input; if rich text is supported, dangerous tags, link protocols, and uncontrolled embedded content must be restricted. Displaying a code snippet does not mean allowing code execution.

    6. How to Evaluate Agent Development Outcomes

    6.1 Standardize Conditions, but Account for Environment Differences

    If multiple agent setups complete the same task, standardize the requirement text, reference scope, initial project, execution budget, and acceptance criteria. At the same time, record browsing permissions, available tools, runtime restrictions, and collaboration modes.

    Identical prompts do not mean identical experimental conditions. If one environment cannot access the reference materials while another can actually run tests, their results cannot be ranked as model capability directly.

    6.2 Separate Visual Quality from Functional Quality

    Visual acceptance covers layout, spacing, hierarchy, responsive adaptation, and interaction feedback; functional acceptance must cover message sending, response attribution, exception handling, and data restoration.

    The two metric sets should be recorded separately, preventing “the page looks complete” from masking missing critical workflows. The overall conclusion should clearly state which features were actually tested, which were only statically implemented, and which still depend on external conditions.

    6.3 Build a Layered Test Checklist

    Testing can be organized into these layers:

    • Static checks: configuration completeness, credential leakage;
    • Unit tests: message transformation, state transitions, response parsing;
    • Integration tests: data flow between the page, your server-side API, and the model service;
    • End-to-end tests: the complete user journey from creating a conversation to receiving an answer;
    • Exception tests: network loss, timeouts, authentication failures, duplicate submissions, cancellation, and retry;
    • Experience tests: long content, narrow screens, keyboard operation, and scrolling behavior during reading.

    For each test case, record the input, expected result, actual result, and necessary evidence. When a test was not executed, say so explicitly—never write expected results as if they were verification conclusions.

    7. From Test Findings to Traceable Fixes

    Whether an agent proactively tests directly affects when defects surface, but “ran many tests” does not automatically mean higher quality. Tests should map to requirement risks, and fixes should be followed by regression verification.

    An effective closed loop is:

    Defect found → Confirm reproduction conditions → Locate root cause → Modify implementation → Verify the original problem → Check related workflows.

    For example, after fixing response misattribution during conversation switching, check not only the switching scenario but also cancellation, retry, history restoration, and concurrent requests—because these behaviors often share the same state management logic.

    A delivery report should include, at minimum: implemented features, test coverage, issues found and fixed, items not yet verified, and follow-up recommendations. Transparently stating limitations carries more engineering value than vaguely claiming “fully complete.”

    8. Conclusion: Treat Agents as Development Executors, Not Guarantees of Completion

    AI agents can accelerate requirements analysis, code generation, and test execution, but reliable delivery still depends on clear constraints and objective acceptance. In conversational web page development, what truly needs rebuilding is the user task, state transitions, and service interactions—not the visual symbols of a particular page.

    The practices most worth keeping are: building consensus through functional documentation, validating the end-to-end loop with a baseline implementation, solving real problems through iterative improvements, and then confirming engineering quality through credential security, exception handling, and regression testing. Only when this chain is complete can a generated page evolve from a demo artifact into a maintainable, verifiable application.