Agent Capability Units as Skills: A Practical Guide to Skill-Based Agent Architecture
This guide explains how to turn monolithic agents into composable capability units, often called Skills. It covers standardized Skill packaging with metadata, input and output contracts, and side-effect declarations; intent recognition and capability routing with measurable evaluation metrics; orchestration of multi-step tasks across devices; contract testing for generated Skills; and governance for capability distribution, including discoverability, trust, and rollback. The goal is to help developers move agents from demos to production by writing clear capability contracts.
1. Why Capability Units: From Monolithic Agents to Composable Capabilities
In agent engineering, the most common failure mode is not insufficient model capability but blurry capability boundaries. When an entire complex workflow is packed into a single prompt or one giant function, three problems appear quickly: poor reuse, because the same capability is reimplemented at different entry points; poor stability, because any small process change forces a full regression; and poor governability, because it is impossible to tell whether intent recognition, parameter extraction, or execution failed.
Capability units—often called Skills in the HarmonyOS ecosystem—are an abstraction designed to address these problems. They describe what an application can do, organizing domain knowledge, processes, and best practices in a structured, standardized way so that agents can perform specialized tasks reliably and on demand. A Skill can be understood as a three-part bundle in the agent world: function, contract, and documentation. The function performs execution, the contract constrains inputs and outputs, and the documentation helps routing and the model understand when to call it.
A mature Skill-based architecture typically has four characteristics:
- Declarative description: capabilities are exposed as metadata for easy retrieval and matching;
- Strong contract constraints: inputs, outputs, error codes, and idempotency are clearly defined;
- Composability: each Skill does one thing, and complex tasks are composed by an orchestration layer;
- Observability: call chains, latency, and failure reasons are traceable.
2. Standardized Skill Packaging: Metadata, Contracts, and Side-Effect Declarations
For an agent to use Skills with confidence, each Skill must first be described in a standardized way. A widely accepted practice is to provide a machine-readable capability declaration that covers at least the capability name and semantic description, applicable and non-applicable scenarios, input schema, output schema, permission scope, side-effect level, and timeout and retry policies.
Illustrative declaration (pseudocode that expresses structure only and does not reference any specific product interface):
{"name": "query_order_status","description": "Query the current status and latest logistics event of an order by order ID","when_to_use": "The user asks about order progress, whether it has shipped, or estimated delivery","when_not_to_use": "The user asks to change the address or cancel the order","input_schema": {"order_id": "string, required","carrier_hint": "string, optional"},"output_schema": {"status": "enum[created,paid,shipped,delivered]","last_event": "object","eta": "string(date-time)"},"side_effect": "none","idempotent": true,"timeout_ms": 3000,"retry": { "max": 2, "backoff": "exponential" }}
The most critical engineering constraint here is side-effect classification. It is recommended to divide all capabilities into three levels: read (read-only), write (writable and retryable), and commit (operations involving funds, entitlements, or irreversible actions). Commit-level capabilities must require secondary confirmation and an idempotency key, for example:
Confirmation gate: amount > threshold or irreversible operation → read-back confirmation requiredIdempotency key: request_id = hash(session_id + intent + payload)
A missing side-effect declaration is the most dangerous design flaw in an agent execution chain, because it allows the model to trigger irreversible actions even when information is insufficient.
3. Intent Recognition and Capability Routing: Making “Choosing the Right Skill” a Measurable Metric
Once system capabilities are fully Skill-based, the real difficulty shifts from implementing capabilities to selecting them. Routing quality determines the upper limit of user experience. It is recommended to split routing into three layers:
- Recall layer: coarse filtering based on semantic vectors and keywords to control the candidate set size;
- Discrimination layer: a model scores the suitability of candidate capabilities, outputting confidence and missing slots;
- Fallback layer: when confidence is below the threshold, enter clarifying questions rather than guessing.
Routing evaluation must be quantified. At least four metrics are recommended: Top-1 hit rate, wrong-invocation rate (calling a capability that should not be called), slot-completion rounds, and task completion rate. A practical way to build an evaluation set is “same question, multiple phrasings”: prepare more than 20 different expressions for each Skill (including colloquial, elliptical, and typo variants), and record the expected invocation and expected slots.
def route(utterance, candidates, threshold=0.62):scored = rank_by_semantics(utterance, candidates)top = scored[0]if top.score < threshold:return clarify(top.missing_slots)if top.side_effect == "commit":return confirm_then_call(top, need_user_ack=True)return invoke(top, slots=extract_slots(utterance, top.input_schema))
It is important to emphasize that clarification is not a failure but low-cost correction. Replacing blind execution with one precise follow-up question usually reduces the wrong-invocation rate significantly.
4. Orchestrating Multi-Step Composite Tasks: From Single Calls to Closed-Loop Flows
The value of Skills is amplified through composition. Cross-capability tasks (for example, “check an order and request after-sales service” or “recognize a receipt and file an expense claim”) require an orchestration layer to handle state management, failure compensation, and parallel acceleration.
The recommended pattern is a hybrid of “explicit state machine plus implicit planning”: stable flows are fixed with a state machine, while open-ended flows are delegated to a planner, but the planner can only produce constrained action sequences, and each step must map to a declared Skill.
Plan: [identify_document, extract_fields, validate_policy, submit_claim]Guard: validate side_effect and permissions before each stepCompensate: submit failure → roll back draft / retain evidence / notify user
In cross-device scenarios, the orchestration layer must also handle the “capability location” problem: the same capability may exist on a phone, tablet, car head unit, or in the cloud. A practical recommendation is to introduce a capability routing table that records each Skill’s deployment location, latency characteristics, and availability, and to schedule with a “nearest-first, failover” strategy. For device-cloud collaboration, put heavy computation in the cloud and strong-privacy, low-latency work on the device.
5. Development and Debugging: Using VibeCoding to Improve Build Efficiency and Contract Tests to Hold the Line
Natural-language-driven development (often called VibeCoding in the industry) significantly lowers the barrier to building Skills: developers describe intent and flow, the platform generates skeletons and description files, and users can even create and share personal custom capabilities. But the side effect of generative building is vague descriptions and drifting boundaries, so contract tests must be added:
- Schema validation: whether missing inputs, type errors, and overly long text are correctly rejected;
- Boundary cases: empty results, timeouts, partial failures, and duplicate submissions;
- Security cases: unauthorized access, prompt injection, and sensitive-field echo;
- Regression baseline: run the full test suite after every change to descriptions or flows.
A minimal test skeleton example:
cases = [{"in": {}, "expect": "reject:missing_order_id"},{"in": {"order_id": "A1"}, "expect": "ok", "assert": "status in enum"},{"in": {"order_id": "A1"}, "expect": "idempotent", "repeat": 2},]for c in cases:assert run_skill("query_order_status", c["in"]) == c["expect"]
6. Distribution, Listing, and Governance: A Capability Marketplace Needs Discoverability, Trust, and Recall
When capabilities are distributed through a marketplace, governance complexity exceeds technical complexity. Three gates are recommended:
- Discoverability: optimize description text for routing, clearly state applicable and non-applicable scenarios, and avoid same-name capabilities competing with each other;
- Trust: declare least-privilege permissions, mask privacy fields, enforce confirmation for commit-level capabilities, and provide versions and change records;
- Recall: support canary release, rate limiting, circuit breaking, and one-click delisting to stop losses quickly when abnormal invocations occur.
Governance metrics are recommended for a daily dashboard: invocation success rate, P95 latency, wrong-invocation rate, permission-denial rate, and delisting recovery time. As the ecosystem grows (for example, one ecosystem has accumulated hundreds of capability units and thousands of agents), description conflicts and capability overlap become the main noise sources, requiring regular semantic deduplication and naming-convention governance.
7. Implementation Recommendations on Baidu AI Cloud
To support a Skill-based architecture on the cloud side, general capability categories can be combined: use a container platform to host the Skill runtime and orchestration services, a message queue for asynchronous tasks and peak shaving, object storage for credentials and intermediate artifacts, logging and monitoring with alerting for call-chain observability, and an API gateway for unified authentication, rate limiting, and canary release. The general cloud product categories offered by Baidu AI Cloud can meet these layered needs, while specific selection should weigh three constraints: side-effect classification, latency budget, and compliance requirements.
8. Conclusion: Writing “What It Can Do” as a Contract Is the Prerequisite for Scaling Agents
The essence of Skill-based design is an interface governance movement: breaking vague “intelligence” into clear capability contracts. When every capability has clear semantics, strongly constrained inputs and outputs, composability, observability, and recall, agents can move from demos to production. For developers, the three most worthwhile investments are: writing good descriptions, drawing clear side-effect boundaries, and building evaluation sets—these three determine whether your capability is invoked precisely or “guessed” by the model.
