Web-Based Coding Agent Architecture: Workspace, Session, and Execution Design

    This article breaks down the architecture of web-based coding agents that run locally while exposing a browser interface. It explains the three-layer abstraction of workspace, session, and timeline; why multiple capability modes are defined by risk boundaries; the perceive-plan-act-verify execution loop; context engineering strategies for long sessions; and the security and governance controls required for local execution. Readers will find pseudocode and configuration examples, common pitfalls, and selection criteria for evaluating such tools.

    1. Introduction: From Chat Box to Auditable Execution Environment

    Coding tools powered by large language models have shifted shape over the past two years. Early products placed the model behind a chat window: users copied code in and pasted errors back. A newer generation puts the model inside a runtime that has a file system, command execution, and retrieval capabilities, so it can actually take action.

    A web-based coding agent of this kind sits somewhere between a command-line coding assistant and an online IDE. The key difference is that computation and file operations happen on the user’s own machine, while the interface lives in the browser.

    This combination of local execution and browser interaction is not primarily an interface innovation. It is a redesign of the trust model and of observability. This article sets aside specific product features and discusses the design as a general architecture problem.

    2. Shape: Three Layers of Workspace, Session, and Timeline

    These tools typically present a three-column layout backed by three clear abstractions:

    • Workspace: maps to a local project directory and defines the boundary for permissions and context. All file reads and writes and all command execution should be confined to that directory and its subpaths.
    • Session: a task context within a workspace. It holds message history, files already read, commands already executed, and intermediate artifacts, and it supports interruption and resume.
    • Timeline: lays out every tool call (read file, write file, run command, search) in order, producing an execution trace that can be replayed and audited.

    A sketch of the data structures (pseudocode):

    1. class Workspace:
    2. root: Path # the only root directory allowed for access
    3. policy: Policy # rules for allowed/denied commands and paths
    4. class Session:
    5. id: str
    6. workspace: Workspace
    7. messages: list[Message]
    8. tool_calls: list[ToolCall] # the body of the timeline
    9. artifacts: dict[str, Path] # list of changed files
    10. class ToolCall:
    11. name: str # read_file / write_file / run_shell / search
    12. args: dict
    13. status: str # pending / running / ok / error
    14. diff: str | None # preview of changes
    15. duration_ms: int

    The value of these three layers is that they constrain the model’s uncertainty inside engineering controllability. The model decides what to do next, but what it is allowed to do, which paths it may touch, and whether confirmation is required are determined jointly by the workspace policy and the timeline record.

    3. Capability Layers: Why Multiple Modes Instead of One Do-Everything Mode

    The source material describes four modes. The standard mode includes file editing, command execution, retrieval, skills, planning, goal management, sub-agents, and workflows. From an engineering standpoint, modes are not feature amputations. They are an explicit grading of risk and cost:

    1. Minimal mode: read-only retrieval and Q&A, suited to code comprehension, review, and documentation, with almost no side effects.
    2. Standard mode: the full tool set, aimed at real development tasks, requiring change previews and a confirmation mechanism.
    3. Autonomous/batch mode: aimed at multi-file refactoring and bulk migration, emphasizing sub-agent parallelism and task decomposition.
    4. Restricted/demo mode: external network access and write operations disabled, suited to teaching, interviews, and customer demos.

    Mode differences should show up in three places: the available tool set, the granularity of the command allowlist, and the threshold for human confirmation. A single declaration at the policy layer can express this:

    1. mode: standard
    2. tools: [read_file, write_file, run_shell, search_web, sub_agent]
    3. shell:
    4. allow: ["git status", "git diff", "npm test", "pytest"]
    5. confirm: ["git push", "rm -rf", "package install"]
    6. filesystem:
    7. writable_within: workspace.root
    8. deny: [".env", "secrets/**", "~/.ssh/**"]

    4. Execution Loop: Perceive, Plan, Act, Verify

    A reliable coding agent runs a loop with four stages rather than treating generation as the finish line:

    • Perceive: read configuration and directory structure first (dependency manifests, build scripts, code conventions) to build a project model, instead of assuming a tech stack out of thin air.
    • Plan: decompose the requirement into verifiable sub-goals, with an acceptance criterion for each step (compiles, tests pass, API returns what is expected).
    • Act: call tools to land changes, where every write produces a reviewable diff.
    • Verify: run builds and tests, read logs and monitoring metrics; on failure, return to planning with the error information attached.

    Pseudocode for the loop:

    1. while not goal.done():
    2. ctx = perceive(workspace) # directory, config, failure logs
    3. plan = model.plan(goal, ctx) # outputs sub-goals and acceptance criteria
    4. for step in plan.steps:
    5. result = dispatch(step, policy) # policy-constrained tool call
    6. timeline.append(result)
    7. if result.status == "error":
    8. goal.add_context(result.stderr)
    9. break
    10. goal.update(verify(goal)) # build / test / lint

    The key engineering point: verification must be machine-decidable. Any step that relies on the model judging that things “should be fine” should be replaced by the exit code of an executable command or by a test assertion.

    5. Context Engineering: The Core of Long-Running Tasks

    Long sessions inevitably overflow the context window. There are three general remedies, usually combined:

    • Retrieval-based context: read file fragments and symbol definitions on demand rather than loading the whole repository at once.
    • Layered summarization: progressively compress message history, keeping decisions, constraints, and unfinished items while dropping verbose logs.
    • External memory: write task lists, interface contracts, and notes on pitfalls into structured files inside the workspace for reuse across sessions.

    A simplified context budget strategy:

    1. def build_context(session, budget=120_000):
    2. parts = [system_prompt(), goal_card(session.goal)] # high priority
    3. parts += session.pinned_constraints() # hard user constraints
    4. parts += retrieve(session.workspace, session.query) # relevant code fragments
    5. parts += rolling_summary(session.messages, budget // 3) # compressed history
    6. return truncate_to_budget(parts, budget) # trim by priority when over budget

    6. Security and Governance: The Unavoidable Boundary of Local Execution

    Handing execution capability to a model carries real risk. At minimum, put these constraints in place:

    • Dual allowlists for paths and commands, with sensitive files (keys, credentials, private keys) denied read access by default.
    • Diffs before writes, explicit confirmation for high-risk commands, and a complete timeline retained for retrospective review.
    • Tiered network access, with separate authorization for dependency downloads and external retrieval.
    • Artifact isolation: run in a container or a dedicated user account to avoid polluting the host environment.
    • Rollback capability: base all changes on version control so a task’s changes can be discarded with one action.

    For team-level adoption, general cloud capabilities can fill out the governance chain: object storage to archive execution traces, a logging service to collect runtime logs centrally, monitoring and alerting with thresholds on abnormal command frequency, and a container platform to provide isolated execution environments. Baidu AI Cloud offers corresponding capabilities in these general categories, and they can be combined as needed rather than binding to a single tool.

    7. Common Pitfalls and Selection Advice

    • Pitfall 1: treating modes as marketing tiers. Define modes by risk boundaries, and never open write access when a read-only mode can solve the problem.
    • Pitfall 2: aiming to generate a complete solution in one shot. Large changes should be committed in small steps, each verifiable and revertible.
    • Pitfall 3: ignoring non-functional constraints. Performance, compatibility, and secure coding conventions should be written into a project-level constraints file for long-term reuse.
    • Selection advice: look at four things first — whether execution isolation is thorough, whether the timeline is auditable, whether context management is configurable, and whether custom tools and skill extensions are supported.

    8. Conclusion

    The real progress of web-based coding agents is not that they can chat. It is that they embed the generative capability of a large model in a constrained, observable, and revertible engineering environment: the workspace draws the boundary, the timeline provides auditability, mode grading controls risk, and loop verification keeps results trustworthy. Understanding this structure has more long-term value than memorizing the interface of any single product.