AI Coding Agents in Practice: Four Operating Modes and Model Integration
\n\nOpen-source AI coding agents let teams choose how the tool runs, control cost by mixing models, and harden usage with security controls. This article walks through the shift from code completion to autonomous coding agents, the five-layer architecture that underpins them, four operating modes (CLI, desktop client, editor extension, and cloud sandbox), strategies for combining free and flagship models, and extension mechanisms such as custom skills, external tool protocols, sub-agents, and rule files. It also covers practical safety and permission guidance, common pitfalls, and a phased adoption roadmap with metrics for measuring results.
1. From Code Completion to Agents: The Shift in AI-Assisted Programming\n\nAI-assisted programming has gone through two major shifts over the past two years.\n\nThe first phase was code completion. The model predicts the next few lines of code based on the current file. It is limited to a single file and local context and cannot reason about dependencies that span modules.\n\nThe second phase is the coding agent. An agent takes natural language as its entry point and builds a closed loop around a large model—perceive, plan, act, reflect. It reads files and directory structures, retrieves relevant code, drafts a plan for changes, edits multiple files, runs commands and tests, and then iterates on the results until the task is done or requires human intervention. The human-machine relationship shifts as well: from “humans write code and the machine autocompletes” to “humans describe intent, the agent executes, and humans review and approve.”\n\nAs capabilities grow stronger, many teams encounter three practical problems when adopting commercial coding tools:\n\n1. Unpredictable cost: With pay-as-you-go pricing and frequent retries under heavy use, expenses can be hard to forecast.\n2. Compliance pressure: Code must be uploaded to an external service, raising concerns about intellectual property, customer data, and cross-border data transfer—especially sensitive in industries such as finance and government.\n3. Ecosystem lock-in: Tools are tightly coupled to specific models and account systems, making it hard to switch models per task or to integrate with an organization’s own R&D platforms.\n\nAgainst this backdrop, open-source AI coding agents have become a focus of community attention. Their code is public and auditable, models and tools are replaceable, they support local or private deployment, and they can extend an organization’s own capabilities through standardized protocols.\n\nThis article uses a class of open-source AI coding agents (referred to below as “the agent”) as an example, examining four dimensions: how to choose an operating mode on demand, how to combine free and flagship models to control cost, how to accumulate team knowledge through extension mechanisms, and how to keep usage secure.\n\n## 2. Overall Architecture: The Five Core Layers of an Agent\n\nBefore discussing specific modes, it helps to clarify the agent’s general architecture. Understanding the layers lets you see which one each configuration affects.\n\n| Layer | Core Responsibility | Key Elements |\n|—-|—-|—-|\n| Runtime | Drives the agent loop | Conversation management, tool-call parsing, session-state maintenance |\n| Tools | Connects the codebase and external environment | File read/write, command execution, code search, browser access |\n| Context | Supplies task-relevant information to the model | Project rule files, file-structure index, task-relevant code snippets |\n| Extensions | Enhances and customizes capabilities | Custom skills, external tool protocols, sub-agents, hooks |\n| Model access | Manages model sources | Local models, cloud models, unified gateway, credentials and quotas |\n\nThe runtime layer defines the agent’s behavioral boundaries; the tools layer determines what it can do; the context layer determines how much it knows; the extensions layer determines what the team can customize; and the model access layer directly affects cost and compliance. Each layer can be configured independently or combined.\n\n## 3. Four Operating Modes: Choosing by Scenario\n\nThe same agent core can be delivered in different modes: interactive command line, a graphical client, a code-editor extension, and unattended cloud execution. Each mode suits different scenarios and has different limitations.\n\n| Mode | Typical User | Suitable Scenario | Main Limitation |\n|—-|—-|—-|—-|\n| CLI | R&D engineers | Day-to-day development, remote development, scripting and pipeline integration | Requires basic terminal skills |\n| Desktop client | Product, QA, and non-engineering roles | Prototyping, quick trials, cross-project tasks | Relatively basic features; some parts still in beta |\n| Editor extension | Front-end and daily coding staff | Editing in place, small-scale refactoring, code explanation | Core capabilities often depend on a CLI program |\n| Cloud sandbox | Platform engineering, DevOps teams | Batch tasks, automated fixes, code review | Complex setup; needs robust isolation and quotas |\n\n### 3.1 The CLI Mode: The Most Complete Primary Form\n\nThe CLI version is the core form of most open-source agents. Editor extensions and cloud sandboxes are often wrappers or extensions of it. Its advantages come in four areas:\n\n- Environment-agnostic: It runs in a local terminal, on a remote server, in a container, or even in a CI environment. Paired with SSH, it can operate on code directly on a remote host.\n- Easy to script: It accepts tasks as arguments and outputs structured results, making it simple to embed in Makefiles, npm scripts, or pipeline scripts.\n- Low resource footprint: You control the pace of interaction and can open multiple sessions at once to handle different tasks.\n- Workflow compatibility: It fits naturally with Git workflows—every code change can be reviewed and rolled back through version diffs.\n\nInstallation\n\nOpen-source agents are typically built on Node.js and distributed via npm, so start by preparing the runtime:\n\n1. Install a current Node.js LTS release; a recent version is recommended. Some tools have explicit minimum-version requirements, and too low a version may cause errors during installation or startup.\n2. Confirm that npm was installed alongside Node.js, then deploy with the global install command:\n\nbash\n# Check Node.js and npm versions (sample commands; refer to your tool's documentation)\nnode --version\nnpm --version\n\n# Globally install the agent CLI\nnpm install --global <agent-cli>\n\n# Enter your project directory and start the agent\ncd <your-project>\n<agent-cli>\n\n\n3. On first run, follow the prompts to configure the model and credentials. Common sign-in methods include calling a cloud model service through a compatible API (which requires an endpoint and key) or connecting to a local inference service to use a local open-source model.\n4. Once in the interactive interface, describe your task in natural language to begin. For example:\n\ntext\nRead the date-handling functions under src/utils, find every branch that fails to\nhandle leap-year boundaries, propose a fix, and add the corresponding unit tests.\n\n\nUsage tips\n\n- Create a rule file (for example, in the style of a Git commit message) in the configuration or project directory, describing the tech stack, directory structure, build and test commands, and coding conventions. This is the most direct way to improve output quality.\n- When the agent generates config and rule files inside a project during installation, note that these files may be tracked by version control. Add any parts that involve secrets to ignore rules, or inject them through environment variables instead.\n- If you use a particular shell environment, refer to the tool’s integration options to embed the agent in your existing terminal experience.\n\nOperations tips\n\n- A global install writes the executable into Node.js’s global directory by default. If you hit a permission error, consider a Node.js version manager rather than installing with administrator privileges.\n- Globally installed versions change with each manual upgrade. Review release notes periodically and stay reasonably cautious about upgrades.\n\n### 3.2 The Desktop Client: A Graphical Entry Point with a Lower Barrier\n\nBeyond the CLI, some open-source agents offer a graphical client. Installation is the same as for any desktop application: download the package that matches your OS from the official source and follow the wizard.\n\nThe desktop client aims to lower the barrier for non-engineers. After launching, you typically select a local folder as the working directory—all of the agent’s file operations are confined to that directory—and then converse as if using a chat tool.\n\nEarly versions of these clients commonly have the following characteristics:\n\n- Basic features: Usually a conversational interface that lacks capabilities such as visual diff review, terminal integration, and multi-session management.\n- Limited maturity: Often in beta, with relatively more defects.\n- Still evolving: Some tools may later be integrated into editors as plugins, at which point you would need to obtain them again.\n\nFor these reasons, the graphical client is better suited to trials and lightweight use. For formal development involving important codebases, prefer the CLI form or an editor extension.\n\n### 3.3 The Editor Extension: Embedding the Agent in the Coding Workflow\n\nThe core value of an editor extension is “collaboration in place.” The agent’s dialog appears in a side panel and stays in sync with the editor: the currently open file and any selected code snippet can be brought into the conversation as context.\n\nA prerequisite is to install the CLI first, because the extension is essentially a wrapper around it. Steps:\n\n1. Install the CLI and make sure it is on the system path.\n2. Search the editor’s extension marketplace for the corresponding plugin and install it, reloading the editor window if needed.\n3. Open the agent panel through the command palette or a custom keybinding.\n\nTwo practical tips when using it:\n\n- Selection on demand: Select code in the editor and press the corresponding keybinding to send the snippet to the chat window.\n- Context association: The agent usually links the currently open file automatically, so you can refer to it directly with phrases like “this function” or “the current file.”\n\nNotably, an editor extension is essentially a “UI layer”; the actual context retrieval, tool calls, and other capabilities are still provided by the CLI program. As a result, the CLI configuration (model, permissions, rule files) also applies to the extension—configure it once and it works for both.\n\n### 3.4 The Cloud Sandbox: For Scale and Unattended Runs\n\nWhen tasks need to run in bulk, run for a long time, or be triggered automatically in a CI/CD pipeline, an interactive session is not up to the job. This is when a cloud runtime or containerized sandbox is needed. Common scenarios include:\n\n- Batch tasks: Such as whole-repository dependency upgrades, uniform code-style migration, or adding API documentation across many files.\n- Continuous integration: Automatically analyzing failed test cases, generating fix patches, and opening merge requests within a pipeline.\n- Code review: Automatically checking merge requests for potential defects, security risks, and convention violations.\n\nThe key to the cloud form is “unattended operation.” Focus on designing these aspects:\n\n1. Non-interactive invocation: Run in a one-shot task mode, pass the task description as an argument, and require structured output (such as JSON) so it can be parsed and archived.\n2. Least privilege: Default to read-only or allow writes only to specific directories; open command execution and network access only as needed, and constrain them through container security policies when necessary.\n3. Runtime isolation: Run each task in its own container, and clean up the environment when the container is destroyed to prevent cross-task contamination.\n4. Quotas and guardrails: Set timeouts, a maximum number of iterations, and execution quotas to prevent a runaway task from continuously consuming compute and model credits.\n5. Observability: Collect run logs and key metrics centrally, alert promptly on task failure, and make it easy to trace back.\n6. Cost control: Tier tasks so routine tasks use low-cost models while complex tasks escalate to flagship models.\n\nWhen building such an environment in the cloud, you can use general-purpose cloud capabilities:\n\n- Use a container platform to host the sandbox runtime and scale it on demand.\n- Use object storage to keep rule files, prompt templates, and run artifacts.\n- Use a message queue for task distribution and peak shaving.\n- Use logging and monitoring-and-alerting services for auditing and anomaly detection.\n\nFor example, general-purpose cloud products from Baidu AI Cloud—such as containers, storage, and logging and monitoring—can be one option for the infrastructure that hosts this kind of agent runtime environment.\n\nTrends in how modes evolve\n\nLooking at the past two years of development in AI coding tools, three main lines emerge:\n\n- Interface convergence: The CLI core provides the full set of capabilities, while editor extensions and graphical interfaces act as different touchpoints, letting every role use the same toolchain at the lowest cost.\n- Protocol standardization: Integrating external tools and data sources is moving from one-by-one adaptation toward a unified standard, so tools can be reused across models and tools.\n- Runtime diversification: Execution is expanding from “interaction with a person at the terminal” to “unattended execution at scale in the cloud.”\n\n## 4. Model Integration: Combining Free and Flagship Models\n\nThe ceiling of an agent’s capabilities largely depends on the model it connects to. A single model rarely balances cost, speed, and quality well, so the sensible approach is to tier models by task.\n\n| Model Tier | Typical Source | Capability Profile | Recommended Use |\n|—-|—-|—-|—-|\n| Local open-source model | Deployed locally or on a private server | Data stays within the network; limited complex reasoning when parameter counts are small | Code completion, simple Q&A, handling confidential code |\n| Free cloud model | Vendor free tier or community-hosted open-source services | Zero-cost start; may be subject to concurrency and rate limits | Learning and practice, capability validation, low-risk small tasks |\n| Flagship cloud model | Vendor flagship model services | Strong complex reasoning and long-context handling; pay-as-you-go or subscription | Architecture design, cross-module refactoring, debugging difficult issues |\n\n### 4.1 Free Models: An Ideal Choice for Low-Cost Practice\n\nFree models matter a great deal for beginners:\n\n- Lower the barrier to trial and error: You can repeatedly practice prompt design, rule-file authoring, skill definitions, and sub-agent orchestration without worrying about cost.\n- Good for practice: Try advanced techniques in throwaway projects or practice repositories; even if something goes wrong, it does not affect production code.\n- Validate feasibility: When a team evaluates whether an agent fits its R&D workflow, it can start with a small pilot using the free tier.\n\nIt is worth being clear that free tiers are a specific vendor’s operating policy and are usually adjusted over time. Common limitations include:\n\n- Concurrency and rate limits;\n- Availability restricted by time window or region;\n- Context-length caps;\n- Possible retention of invocation logs and data-use policies for model training.\n\nSo free models are well suited to learning and validation, but not recommended as the mainstay of production.\n\n### 4.2 Flagship Models: Upgrading by Scenario\n\nFor architecture design, cross-module refactoring, and locating complex defects, flagship models generally perform better in reasoning depth and long-context handling. Three ways to optimize cost:\n\n1. Unified gateway routing: Deploy a gateway with a compatible API format locally or on the internal network that unifies multiple model services behind a single entry point, then configure routing rules by task type. For example, route simple tasks to a lightweight model and route complex tasks with keywords such as “architecture” or “security” to a flagship model.\n2. Fallback chains: When the primary model is unavailable or hits a rate limit, automatically fall back to a backup model so tasks are not interrupted.\n3. Tiering by project: Use free or low-cost models for daily practice and low-risk tasks, and connect flagship models for core projects as needed.\n\n### 4.3 Example Configuration for Unified Access\n\nMost mainstream agents are compatible with common model API protocols, and the configuration usually includes three items: the endpoint, the key, and the model name. The configuration below only illustrates the field structure; refer to your tool’s documentation for the actual format:\n\njsonc\n// Agent configuration file (illustrative; field names and format vary by tool)\n{\n // Model provider: any model service that supports a standard API protocol, or a local gateway\n "provider": {\n "baseURL": "https://<your-gateway-endpoint>/v1",\n "apiKey": "${AGENT_API_KEY}" // Prefer an environment variable placeholder so keys are not stored on disk\n },\n "model": "your-model-name", // Use the model identifier actually supported by your provider\n "permission": {\n "edit": "ask", // Require confirmation before editing files\n "bash": "allow" // Whether to allow direct command execution; tighten this as needed\n }\n}\n\n\nFollow four principles for managing keys:\n\n- Never commit them to the repository;\n- Keep them out of logs and conversation context;\n- Inject them through a secrets manager or CI secret mechanism;\n- Rotate them immediately if a leak is suspected.\n\n## 5. Extension Capabilities: Building a “Custom” Agent\n\nIf you only use the default configuration, the agent experience differs little from one developer to the next. Real efficiency gains come from baking team knowledge, internal tools, and workflows into the agent. Open-source agents offer several main types of extension mechanisms.\n\n### 5.1 Custom Skills: Turning Team Experience into Reusable Capabilities\n\nA skill is an “operating manual” described in Markdown, usually placed in a conventional skills directory and declaring its name and trigger description through metadata. It is loaded on demand at runtime and does not consume the entire context.\n\n| Extension Type | How It Is Defined | Typical Scenario |\n|—-|—-|—-|\n| Custom skill | A Markdown file in the skills directory with name and description metadata | Code-review checklists, release checks, test-case authoring standards |\n| Custom command | A prompt template in the commands directory that can take arguments | Consistently formatted commit messages, changelogs, weekly reports |\n| Hook | A script triggered at a specific event | Auto-formatting after file edits, running code checks |\n| External tool protocol | Connecting databases and internal APIs through a server side | Querying a requirements system, searching internal docs, viewing monitoring metrics |\n| Sub-agent | Defining an independent agent and its available tools | Code review, security audit, test generation |\n\nTake a “code review skill” as an example. You can define the review steps in the skill file:\n\nmarkdown\n---\nname: code-review-checklist\ndescription: Review code changes against team standards and produce structured review comments\n---\n\n# Review Steps\n1. Read the files touched by the change and understand the intent;\n2. Check each dimension in turn: boundary conditions, error handling, concurrency safety, logging conventions, test coverage;\n3. For each issue, provide the file and line number, a description, a suggested fix, and a severity level;\n4. Do not modify the code directly; only output the review comments.\n\n\nThree tips when designing skills:\n\n- Be specific about triggers: Clearly state when the skill applies and when it does not, so unrelated tasks do not trigger it by mistake.\n- Make steps executable: Describe the flow with numbered steps that specify inputs, outputs, and completion criteria.\n- Keep a single responsibility: Each skill should solve one class of problem, which makes it easier to maintain and combine.\n\n### 5.2 External Tool Protocols: Connecting the Agent to Internal Systems\n\nBy default, the agent can operate local files and run commands, but an organization’s requirements management, documentation, monitoring, databases, and other information live in external systems. The industry commonly adopts standards such as the Model Context Protocol (MCP) to wrap external systems as tools or data sources that the agent can call.\n\nOnce you integrate such a protocol:\n\n- The agent can query requirement details, search internal documents, and read monitoring metrics, reducing manual copy-paste;\n- Tool definitions are decoupled from the model, so no re-adaptation is needed after switching models;\n- Permission control can be pushed down to the server, where the protocol service verifies the caller’s identity uniformly.\n\nNote two points:\n\n- Expose selectively: The more tools you expose and the longer their descriptions, the more context they consume—which can actually reduce the model’s accuracy in choosing the right tool. Expose only the necessary tools and state their conditions of use clearly.\n- Open write operations cautiously: For tools that modify internal data, require the agent to confirm explicitly before calling, and record complete audit logs on the server side.\n\n### 5.3 Sub-agents: Division of Labor and Context Isolation\n\nComplex tasks often contain several relatively independent steps, such as “analyze the defect,” “write the fix,” “add tests,” and “review the code.” You can configure several sub-agents for the main agent, each with its own context and a restricted set of tools.\n\n- The main agent handles task decomposition and result aggregation.\n- Each sub-agent focuses on a single responsibility—for example, a “review sub-agent” that can only read code for analysis, or a “test sub-agent” that can only write to a test directory.\n\nThe value of this approach:\n\n1. Context isolation: A sub-agent’s intermediate steps do not pollute the main session, avoiding rapid context bloat.\n2. 收敛 permissions: Each sub-agent has only the tools it needs for its own task.\n3. Easy parallelism: Independent subtasks can run in parallel, shortening overall time.\n\n### 5.4 Rule Files: A Vehicle for Accumulating Project Knowledge\n\nRule files are usually placed in the project root or the user configuration directory and describe background knowledge about the project to the agent. They generally include:\n\n- Tech stack and versions;\n- Directory structure and each module’s responsibilities;\n- Commands for build, test, and code checks;\n- Coding conventions and prohibited practices;\n- Commit and branch conventions.\n\nFor a repository made up of multiple sub-projects, you can place rule files in each subdirectory so the agent automatically loads the corresponding rules when working in a given directory.\n\nFollow two principles when writing rule files:\n\n- Be concise: Too many rules crowd out the context and can conflict with one another.\n- Be verifiable: Write requirements the agent can check itself. For example, use “run all test cases under the test directory and ensure they all pass” instead of “make sure the code is correct.”\n\n## 6. Efficiency and Security: Advanced Practices and Common Pitfalls\n\n### 6.1 Constraining Behavior with Prompts and Rules\n\n- Require planning first: For complex, cross-file changes, ask the agent to output a plan for confirmation before executing.\n- Specify verification: State in the task description which tests to run after the change, so the agent can self-verify.\n- Limit the scope of changes: Make it explicit that “only files within a certain directory” may be modified, reducing the risk of unintended edits.\n- Show the diff: Review the diff after each change, confirm it, then proceed.\n\n### 6.2 Watch Out for Default Permission Risks\n\nBecause the agent can read and write files and run commands, it effectively has the same operating power as the current user. Improper permission configuration can lead to:\n\n- Accidentally deleting files or overwriting uncommitted changes;\n- Running destructive commands;\n- Reading and uploading sensitive information such as keys;\n- Modifying or pushing code without review.\n\nPermission configuration should follow the least-privilege principle: for capabilities such as command execution, file writes, and network access, disable them where possible, and require human confirmation for anything that must be open. An agent running in an isolated environment still needs clear permission boundaries—do not relax limits just because it is “in a container.”\n\n### 6.3 Common Pitfalls and How to Address Them\n\n| Common Pitfall | Consequence | How to Address It |\n|—-|—-|—-|\n| Not clearing long sessions | Context bloat, declining answer quality, higher cost | Start a new session when switching tasks; clear history periodically |\n| Piling too much into rule files | Key information gets buried and instructions get ignored | Keep only high-frequency, critical, verifiable rules |\n| Writing keys in plaintext in config | Keys leak along with the repository | Use placeholders, a secrets manager, or a CI secret mechanism |\n| Heavy concurrency on a free tier | Triggers rate limits and tasks fail | Control concurrency; design retry and fallback strategies |\n| Letting the agent operate on production directly | Misoperations affect the business | Production operations must be human-confirmed, with a rollback plan in place |\n\n## 7. Adoption Roadmap and Measuring Results\n\nAdopting open-source AI coding agents is best done in phases:\n\nPhase 1: Individual trial. Install the CLI, connect a free model, and get familiar with basic interactions—conversation, file edits, and command execution—in a practice project.\n\nPhase 2: Team accumulation. Write rule files and custom skills in real projects to codify team standards and common workflows; connect read-only external tools and try dividing work among sub-agents.\n\nPhase 3: Platform integration. Build a unified model gateway for multi-model routing and fallback; embed the agent into R&D processes such as code review and continuous integration; and combine it with a cloud runtime for batch tasks.\n\nWhen measuring results, consider these metrics:\n\n- First-pass task completion rate: The share of tasks completed without major manual rework;\n- Human modification ratio: The share of agent-produced code that gets modified by hand;\n- Review pass rate: The share of related merge requests that pass review on the first attempt;\n- Task duration: The average time from raising a task to completing and verifying it;\n- Resource cost: The model calls and runtime consumed per task.\n\n## 8. Conclusion\n\nOpen-source AI coding agents turn AI programming from a “single tool” into a “composable capability platform”: the CLI, graphical interface, editor extension, and cloud sandbox cover different roles and scenarios; free models lower the learning barrier, and a unified gateway makes on-demand switching across multiple models possible; and skills, external tool protocols, and sub-agents gradually make the agent fit a team’s real workflow.\n\nAt the same time, the greater the agent’s permissions, the higher the governance requirements. Permission control, credential management, operation auditing, and data compliance are not optional—they are prerequisites for using the agent at scale. Start from a small but complete scenario, gradually accumulate rules and extension capabilities, and let the agent truly integrate into day-to-day R&D.