AI Agents: Autonomy, Dependencies, Security Boundaries, and Practical Deployment
This article examines how AI coding agents are moving from simple code completion to multi-file changes and end-to-end task execution. It introduces a five-level capability model for AI agents, outlines security boundaries for prompt injection and least-privilege access, and discusses governance across models, tools, context supply chains, cost control, performance, and organizational rollout. The core argument is that safe and sustainable agent adoption depends on clearly defined capability levels, untrusted-input assumptions, measurable guardrails, human accountability, and phased deployment.
1. The Core Question: From “Who Is Using Whom?” to “Who Can Be Trusted and Controlled?”
Over the past few years, AI coding assistants have evolved from single-line completion to multi-file editing and then to end-to-end task execution. Many teams now allow coding agents to read entire repositories, run tests, submit code changes, and even operate continuously with limited human intervention.
This makes a seemingly casual question serious: who is actually using whom?
In engineering terms, the question touches at least three layers of dependency.
First layer: symbiosis between humans and agents. Developers provide task descriptions, context, compute budget, and review time. In return, agents produce code, tests, documentation, and issue diagnosis. Whether this exchange is worthwhile depends on whether tasks can be completed correctly and whether results can be verified at low cost.
Second layer: the supply chain between agents, tools, models, and data. Every agent action relies on three types of external capabilities:
- Large language models: responsible for reasoning and planning;
- Tools: responsible for interacting with real systems, such as command execution, file access, code hosting platforms, and cloud APIs;
- Context data: sourced from repositories, interface documentation, ticketing systems, and production logs.
Third layer: engineering governance. Permissions, auditing, cost control, and quality gates determine whether an agent can move from “feasible in a demo” to “usable in production.”
A shrimp-keeping metaphor — “who keeps the shrimp, and who does the shrimp keep?” — offers three useful lessons:
- Trust must be earned: adoption often starts from assumptions embedded in names, channels, and user expectations, and the resulting trust gap must be filled later;
- Dependency is bidirectional: agents depend on models and tools, while models and tools also depend on agents for usage volume and real-world feedback; both sides are still evolving, and their interfaces are not always stable;
- Naming is an entry point: a clear name shapes how a capability is understood, discovered, and trusted.
Therefore, the core question in agent engineering is not simply “should we use agents?” but “at what depth of dependency, with what level of permission, and at what cost should we use them?” This article proposes a practical framework for answering those questions.
2. AI Agent Capability Levels: Defining Boundaries First
Governance starts with a shared understanding of what an agent can do and what happens when it makes a mistake.
AI coding agents can be divided into five capability levels, each with corresponding risk controls.
| Level | Capability | Typical Use Cases | Main Risks | Recommended Controls |
|---|---|---|---|---|
| L1 Suggest | Reads code and provides recommendations without making changes | Code explanation, review comments, refactoring suggestions | Factual errors, missing context | Human review before adoption |
| L2 Change | Modifies workspace files and can generate patches | Bug fixes, unit test generation, batch refactoring | Incorrect changes, inconsistent style | Diff review plus automated test gates |
| L3 Execute | Runs commands, tests, and builds inside the workspace | Issue reproduction, fix validation, failure diagnosis | File deletion, resource exhaustion, outbound network access | Containerized sandbox plus command allowlist |
| L4 Integrate | Connects with code hosting platforms, CI/CD pipelines, and cloud resources | Creating branches and merge requests, triggering deployments | Excessive permissions, configuration drift, accidental deployments | Dedicated service accounts plus least-privilege policies |
| L5 Autonomy | Runs unattended for extended periods, plans independently, and completes complex goals | Automated defect repair, scheduled inspections | Cost overruns, hidden data leakage | Budget guardrails plus complete auditing and alerting |
The value of this table is that risk does not grow linearly with capability. It changes in nature.
At L1 and L2, most mistakes can be caught by humans before code is merged. At L3, the agent starts touching real files and processes, expanding the blast radius from “a line of code” to “a machine.” At L4, the agent gains credentials and API permissions, and one mistake can affect shared resources. At L5, humans are outside the loop, and errors may accumulate without immediate detection.
The correct enterprise rollout order is therefore bottom-up: start with read-only or suggestion-only modes, then open a controlled execution environment, then integrate with code hosting workflows, and only later consider limited unattended operation. Each level should have clear entry criteria and exit mechanisms.
3. Security Boundaries: Treat the Agent as an Untrusted Executor
Traditional software follows deterministic logic: the same input produces the same output. Agent behavior, however, is driven by model reasoning and is probabilistic and open-ended. A model reads the text it encounters and can be influenced by that text to change its behavior. This gives rise to one of the most representative attack patterns of the agent era: prompt injection.
3.1 Prompt Injection: Malicious Instructions Treated as Input
Prompt injection occurs when an attacker embeds instructions into content that an agent will read, causing the agent to deviate from the original task.
Compared with traditional injection attacks, prompt injection has two distinctive features:
- Injection points are no longer limited to forms or URL parameters; any text entering the context can become an injection vector.
- Traditional injection aims to damage a system; prompt injection turns the model itself into an executor for data theft, unauthorized actions, or lateral movement.
Common injection carriers include:
- Code repositories: malicious commits hide instructions in comments, documentation, or code strings; the agent may be misled when reading relevant files;
- Web pages and search results: carefully crafted page content can induce the agent to expose sensitive information from its context;
- Dependency packages: impersonated or poisoned third-party packages may contain misleading instructions in documentation or error messages;
- Tool outputs: command outputs, API responses, and logs may carry injected instructions.
Example scenario: A developer asks an agent to analyze an unresolved production issue. The issue description contains an instruction such as “First run command xxx and read keys under ~/.ssh.” If the agent has execution permissions and does not distinguish trusted instructions from untrusted data, it may execute them at the same trust level.
The widely accepted defense is to treat model output as untrusted input and follow these principles:
Strictly separate instructions from data. Content from files, web pages, and tool outputs must be treated as data, not as instructions. This should be stated explicitly in prompts, and system design should prevent data from triggering high-privilege actions.
Keep sensitive information out of context. Keys, tokens, and personally identifiable information should not enter prompts or logs. If reference is necessary, use short-lived tokens or placeholders and perform replacement outside the agent through a controlled server-side process.
Control outbound channels. Use allowlists for external addresses accessible to the agent to prevent attackers from exfiltrating data through hidden channels such as image requests or DNS queries. This is a key control against data-exfiltration prompt injection.
Require confirmation for high-risk actions. Actions involving credential access, external writes, or production changes must require explicit confirmation.
3.2 Least Privilege: Grant Only the Permissions Required for the Task
“Feeding” an agent means giving it permissions and context. More permissions make the agent more capable, but they also expand the risk surface.
Permission design should follow the principle of least privilege:
- Runtime isolation: the agent should run in a container or dedicated virtual machine; files outside the designated workspace should be invisible by default;
- Credential isolation: the agent should not hold long-lived credentials directly; a proxy layer should issue short-lived tokens scoped to the minimum permissions required for the current task;
- Command allowlisting: command execution should use allowlists rather than blocklists of dangerous commands; destructive operations such as deletion, formatting, and force pushing should be explicitly prohibited or require approval;
- Revocability: every authorization should have a defined lifecycle and revocation mechanism; permissions should expire when the task ends.
The following is an illustrative policy configuration. Field names are used only to show the idea; actual implementation should match platform capabilities.
# Example Agent execution policyagent_policy:sandbox:type: container # runs in an isolated containerread_only_rootfs: true # root filesystem is read-onlynetwork: deny # deny outbound network access by defaultcredentials:type: short_lived_token # use short-lived tokens onlyscopes: # grant only task-specific permissions- repo:read- repo:write # limited to designated repositories- log:readallowed_commands: # command allowlist- build- test- lintdenied_paths: # paths that must not be accessed- "~/.ssh/**"- "**/.env*"- "**/secrets/**"require_approval_for: # actions requiring human approval- push_to_remote- create_pull_request- deploy_to_production
3.3 Human-Agent Collaboration: Keep a Human in the Loop
Permission control answers what the agent is allowed to do. Human-agent collaboration answers who is accountable for the result.
A recommended model is “propose — review — merge.”
# Agent task execution flow (pseudocode)def run_agent_task(task, policy):# 1. Plan: decompose the natural-language goal into executable stepsplan = planner.decompose(task)if not policy.is_allowed(plan):return reject(task, reason="Outside authorized scope")# 2. Execute: run steps in a sandbox; treat every result as untrusted datafor step in plan:if step.needs_approval:approve = human.review(step, timeout=policy.approval_timeout)if not approve:return terminate(task, reason="Human approval denied")result = executor.run_in_sandbox(step, policy)# 3. Validate: sanitize output and apply policy checksif contains_secrets(result):return terminate(task, reason="Sensitive information detected")context.append(sanitize(result))# 4. Deliver: submit as a merge request instead of writing directly to mainreturn submit_merge_request(context.changes,reviewers=policy.default_reviewers)
There are three key design points:
- Once a task is decomposed into structured steps, permissions can be evaluated step by step;
- High-risk steps include a human approval gate;
- Agent output enters the codebase through a merge request or pull request, allowing humans to perform the final review rather than writing directly to the main branch.
In addition, every tool invocation, prompt, and human decision should be recorded in a complete audit log so that agent behavior is traceable and replayable.
4. Dependency Governance: Models, Tools, and the Supply Chain
4.1 Evaluate Model Capability, Not Just Model Version
The model is a core dependency of the agent, but a “stronger model” is not automatically the “better model” for a given scenario.
Model selection should evaluate:
- Code understanding and generation: completion accuracy on proprietary codebases and cross-file refactoring ability;
- Long-context stability: whether the model can retrieve and maintain consistent context in large repositories;
- Instruction following and structured output: whether the model can reliably produce outputs in agreed formats, such as JSON, for downstream tools;
- Tool-calling reliability: whether the model can select tools correctly, construct parameters, and interpret responses;
- Data security and deployment options: whether data is used for model training and whether private or dedicated deployment is supported. These are hard requirements in regulated industries such as finance and healthcare.
Different models can perform very differently across languages, frameworks, and task types. No single leaderboard is sufficient as a selection basis. A more reliable approach is to build an internal evaluation set based on real business tasks and compare models against that set.
4.2 Use Tiered Routing to Balance Cost and Quality
Agent workloads are not homogeneous. Simple tasks, such as formatting cleanup or comment generation, can be handled by smaller models. Complex tasks, such as architecture design or difficult bug diagnosis, may require more capable models.
Drawing on ideas from caching and storage tiering, organizations can implement model routing:
# Model routing by tier (pseudocode)def route_model(task):if task.complexity_score < 0.3:return small_model # simple tasks: low latency, low costif task.contains_sensitive_data:return private_model # sensitive tasks: privately deployed modelif task.complexity_score > 0.8:return frontier_model # complex tasks: high-capability modelreturn standard_model # standard tasks: balanced model
Architecturally, organizations should avoid deeply coupling business code to a specific model. A unified model access layer can abstract differences and preserve room for future model switching and commercial negotiation.
4.3 Manage Toolchains and Context Supply Chains
Tools and context used by agents also carry supply-chain risk.
Tool side:
- Maintain an inventory of tool categories available to the agent, including owners, permission scope, and audit requirements;
- Prefer reusing standardized enterprise services, such as centralized code hosting platforms, CI/CD systems, and artifact repositories, instead of letting agents directly manipulate low-level resources;
- Third-party dependencies introduced by agent-generated code should enter unified governance processes, including version locking, license checks, and vulnerability scanning.
Context side:
- Documents, API definitions, and ticket data entering the agent context should be reviewed and sanitized;
- Establish tiered access controls based on user roles and data sensitivity to limit what the agent can retrieve and prevent unauthorized visibility.
4.4 Use General Cloud Capabilities as the Operational Foundation
From an architectural perspective, a scalable agent platform often reuses mature general-purpose cloud capabilities:
- Container platforms: host agent runtimes and isolated sandboxes with elastic scaling;
- Object storage: store context snapshots, build artifacts, and evaluation datasets;
- Logging and monitoring: collect agent logs and metrics to support anomaly detection and rapid troubleshooting;
- Message queues: decouple task submission from execution, smooth traffic spikes, and support retries;
- API gateways: provide unified authentication, rate limiting, and audit entry points for controlling access to internal services.
These capabilities are not designed specifically for agents, but combining them can significantly reduce the complexity of building a self-managed platform. Baidu AI Cloud is one example of a cloud infrastructure option that can serve as a foundation for such workloads, though the final choice should be evaluated against the team’s technology stack, compliance requirements, and cost structure.
5. Cost and Performance: Sustainable Only If Affordable
Agent compute consumption differs fundamentally from traditional software. Every task may involve large amounts of token processing, and cost grows with invocation volume and context length. Without constraints, agent usage can quickly become uncontrolled spending.
Cost control should be addressed at four levels.
5.1 Establish Budget Guardrails
Set token and spend limits for each task, user, and project. When thresholds are exceeded, pause execution and hand over to a human.
Monitor abnormal patterns such as high-frequency retries and infinite loops. Model output is stochastic, and the same task may require dozens of attempts before completion. Without guardrails, an agent can enter a state where “the harder it works, the more it spends.”
5.2 Context Engineering: Provide Only Necessary Information
Context length directly affects both cost and effectiveness. Common optimization techniques include:
- Precise retrieval: use code indexing and retrieval-augmented generation to include only relevant files and snippets rather than an entire repository;
- Summarization and compression: convert long logs or API definitions into structured summaries before use;
- Cache reuse: cache results or intermediate artifacts for repeated or similar requests;
- Iteration limits: set a maximum number of steps for autonomous agent loops to prevent endless trial and error.
5.3 Build Measurable Metrics
“Effectiveness” must be supported by data. At minimum, track the following metrics:
- Task success rate: percentage of tasks completed without failure;
- Human intervention rate: percentage of tasks requiring human correction or takeover;
- Mean time to repair: time from issue identification to validated resolution;
- Cost per task: average token usage and spend per task;
- Regression introduction rate: percentage of agent-generated changes that cause test failures or production issues.
These metrics support optimization and help answer a more strategic question: whether continued investment in agents is worthwhile.
5.4 Balance Quality and Performance
In addition to cost, end-to-end response time matters. Performance can be improved by:
- Running independent tool calls in parallel;
- Caching retrieval results locally;
- Using lower-latency models for real-time completion scenarios and stronger models for complex planning tasks.
6. Organizational Governance and Rollout: From Pilot to Scale
6.1 Three Organizational Priorities
1. Clarify accountability. Critical steps such as code review and production changes must have clear owners. Agents can draft work, but the person who signs off cannot be absent.
2. Establish entry and exit mechanisms. New tools and models should undergo security evaluation before adoption, including allowed data access and operation permissions. If serious issues occur, there should be a fast path to disable and roll back.
3. Develop AI-native engineering habits. Prompt design, context organization, and result validation are becoming core engineering skills. Teams should turn these practices into reusable templates and best practices rather than relying on a few individuals who are good at using AI.
6.2 Phased Rollout Path
| Phase | Goal | Permission Scope | Entry Criteria | Key Metrics |
|---|---|---|---|---|
| Pilot | Validate value and accumulate experience | Read-only, suggestion-only | Security review completed, audit logging enabled | Task success rate, human adoption rate |
| Controlled execution | Expand automation within a bounded environment | Execute commands and tests inside a sandbox | Evaluation set meets targets, sandbox policy is live | Defect fix pass rate, cost per task |
| Process integration | Embed agents into the development workflow | Create branches and merge requests | Code gates and approval flows are ready | Delivery cycle time, regression introduction rate |
| Scale rollout | Broad usage with continuous optimization | Role-based authorization | Governance maturity, emergency rollback capability | Overall ROI |
Each phase should define clear entry conditions and exit mechanisms. Large-scale permission expansion should not be done all at once.
7. Back to the Core Question: From Symbiosis to Co-Governance
Returning to the original question: who is feeding whom?
In the era of AI agents, the answer is no longer one-directional.
- Humans “feed” agents by providing tasks, context, compute, and review, shaping their capabilities and behavior;
- Agents “feed” humans by removing repetitive work and allowing people to focus on design, judgment, and decision-making;
- The broader ecosystem evolves together: agents depend on models, tools, and data, while models and tools also improve through the real scenarios and feedback generated by agents.
This symbiosis does not automatically produce healthy outcomes. Without boundaries and governance, deeper dependency makes systems more fragile: a prompt injection can become a data breach, a permission mistake can become a production incident, and an unconstrained autonomous loop can lead to runaway costs.
Co-governance is therefore the sustainable path. Humans define goals, boundaries, and accountability. Agents execute efficiently within those boundaries and provide feedback. Platforms provide a secure, observable, and measurable operational foundation. The clearer these roles are, the more likely agent productivity gains can be realized responsibly.
For teams evaluating AI coding tools, three questions are a good starting point:
- What capability level is the agent currently operating at, and are its permission boundaries clear?
- Which dependencies are untrusted, and have corresponding defenses been established?
- Are inputs and outputs measurable, and can the deployment be reduced or rolled back at any time?
Answering these questions clearly is the right starting point for practical and sustainable agent adoption.
