Agent Engineering in Practice: Building Reusable Skills and Connecting Tools
This article explains why AI agents should be treated as engineering systems rather than prompt-tuning exercises, and how to structure them for stable delivery. It covers separating planner, executor, and critic responsibilities, defining permission, data, and rollback boundaries, and turning one-off scripts into reusable skills with stable contracts. It also details a unified connection layer for tool discovery, authentication, traffic control, observability, and idempotency, plus evaluation, canary rollout, cost control, common anti-patterns, and a practical implementation checklist.
1. Why Treat Agents as Engineering Objects, Not Prompt Tricks
When many teams start building agents, their first instinct is to tune prompts. But what actually determines whether the system can deliver reliably is structure, boundaries, and reusability. The core problems of agent engineering can be broken down into three layers:
- Structure layer: Which roles make up the agent, and how responsibilities are divided;
- Capability layer: How tasks are abstracted into reusable skills instead of one-off scripts;
- Connection layer: How tools, data, and workflows are integrated through standard protocols.
Optimizing only the prompt is like painting walls on a ground with no foundation. The sections below go through each layer.
2. Agent Structure and Boundaries: First Decide What It Will Not Do
2.1 Separating Three Types of Responsibilities
A maintainable agent usually contains three types of responsibilities, decoupled from each other:
- Planner: Breaks a vague goal into ordered subtasks;
- Executor: Calls skills to perform concrete actions;
- Critic: Checks result consistency and decides whether to retry.
The value of separating responsibilities is that each layer can be replaced and evaluated independently. If the planning strategy changes, the execution logic does not need to be rewritten; if an execution tool is swapped, the validation rules do not need to change.
2.2 Boundaries Are Security
Boundaries do not limit capability; they control the risk surface. Three boundaries are recommended:
- Permission boundary: Grant only the minimum set of tools needed to complete the task;
- Data boundary: Mask sensitive data at the entry point, and prohibit indiscriminate writes to external systems;
- Rollback boundary: Any action with side effects must have a compensation plan.
An illustrative boundary declaration can be written as configuration rather than scattered across prompts:
agent:role: plannerallowed_skills: [search_docs, query_table, render_report]data_policy: {mask_pii: true, allow_external_write: false}rollback: {enabled: true, max_retry: 2}
3. Skills: Turning Tasks from One-Off into Reusable Assets
3.1 The Minimal Contract of a Skill
A qualified skill should have a stable contract: a clear input schema, output schema, error codes, and side-effect description. Only when the contract is stable can the agent safely orchestrate skills at runtime.
{"name": "query_table","input": {"dataset": "string", "filter": "object", "limit": "integer"},"output": {"rows": "array", "truncated": "boolean"},"errors": ["DATASET_NOT_FOUND", "FILTER_INVALID"],"side_effects": "none"}
3.2 The Path to Accumulation: Four Steps from Script to Skill
- Extract: Pull recurring operations out of the conversation flow;
- Define the contract: Fix input, output, and error semantics;
- Add guardrails: Timeouts, rate limiting, idempotency, retries;
- Build evaluation: Prepare a repeatable test set for the skill and include it in regression.
3.3 Skill Library Governance
As the number of skills grows, naming conventions, versioning policies, and deprecation mechanisms are needed. It is recommended that each skill carry a semantic version, that breaking changes must bump the major version, and that a dual-run period be retained to avoid sudden behavior changes in production agents caused by skill drift.
4. Connecting Tools and Data: The Value of Standardized Protocols
4.1 Why a Unified Connection Layer Is Needed
Tools come in different forms: some are called through APIs, some read from object storage, and some are triggered by message queues. If every skill implements its own connection logic, maintenance costs rise exponentially. The responsibility of a unified connection layer is to consolidate capability discovery, invocation, authentication, rate limiting, and logging in one place.
4.2 Five Essential Capabilities of the Connection Layer
- Capability discovery: Declare available tools and their parameter schemas in a manifest;
- Unified authentication: Credentials are centrally managed, and skills never touch plaintext keys;
- Traffic governance: Rate limit by caller quota to prevent cascading failures;
- Observability: Call chains, latency, and error codes are collected uniformly into logs and monitoring alerts;
- Idempotency and compensation: Write operations carry idempotency keys and can be safely replayed after failure.
4.3 Integrating with Workflows
An agent should not be an island. The stable approach is to embed the agent into an existing workflow: the workflow handles triggering and orchestration, the agent handles the steps that require semantic understanding, and results are written back to the workflow state. This preserves determinism while gaining flexibility.
5. Stable Delivery: Evaluation, Canary Release, and Cost
5.1 Evaluation First
Build three layers of evaluation for the agent: skill-level cases (contract correctness), task-level cases (end-to-end completion rate), and a regression set (historical failure samples). Without a regression set, any optimization is a blind change.
5.2 Canary Release and Rollback
A new agent version is first canaried on a small traffic share, observing task success rate, average number of steps, and human takeover rate; when anomalies occur, automatically roll back to the previous skill combination based on preset thresholds.
5.3 Cost Awareness
Costs mainly come from model calls and tool call counts. Control measures include: reducing ineffective planning steps, caching results for high-frequency skills, and pushing deterministic logic down into ordinary code rather than leaving it to model reasoning.
6. Common Anti-Patterns
- Prompt monolith: All logic stuffed into one prompt, impossible to evaluate or reuse;
- Skills without contracts: Arbitrary input and output, frequent parsing failures at runtime;
- Excessive permissions: The agent holds full write permissions, making the incident radius uncontrollable;
- No regression set: Every change relies on manual trial runs, and quality cannot be measured.
7. Implementation Checklist
- Draw the agent’s responsibility layers and boundary declarations;
- Extract the top three high-frequency tasks and define skill contracts;
- Build a unified connection layer to consolidate authentication, rate limiting, and logging;
- Establish skill-level and task-level evaluation plus a regression set;
- Design canary thresholds and a rollback strategy;
- Connect the agent to the existing workflow, and clarify write-back and compensation paths.
By proceeding in this order, an agent system can move from “demoable” to “deliverable,” and remain controllable and maintainable through continuous iteration.
