Agent Engineering: From Prompts to Reusable Capability Packages

    Moving agents from demos into production usually stalls not on longer prompts, but on whether specialized work can be reused, audited, and evolved. This article explains capability packages—bounded units of instructions, scripts, resources, and tests—and how to design, load, combine, govern, and observe them.

    When agents move from demos into production, the bottleneck is rarely “write a longer prompt.” It is whether a specialized task can be reused, audited, and evolved. Turning that task into a capability package is the step from prompt engineering to agent engineering.

    What a capability package is

    A capability package is not a one-off instruction. It is a work unit with a clear boundary. It is usually organized as a directory and contains at least three kinds of material: task instructions that both people and the model can read, scripts or procedure fragments that can be run repeatedly, and resources needed to finish the task, such as templates, examples, and validation rules. At runtime, only the packages that match the task are loaded. The full background is not pushed into context at once.

    This shape has three direct benefits. First, context stays cleaner: the model sees only the constraints and examples the current task actually needs. Second, behavior is more stable: critical steps are carried by scripts or fixed procedures, which reduces drift from free-form generation. Third, ownership is clearer: each package has its own inputs, outputs, failure conditions, and maintainer, which makes review and rollback practical.

    How this differs from a prompt

    Prompts are good at expressing intent and poor at carrying engineering constraints. A prompt can say “please organize the meeting notes,” but it can hardly guarantee complete fields, redaction of sensitive information, retryable failure, and output that a downstream system can consume. A capability package splits those requirements. The instruction document owns the goal, the boundaries, and what is forbidden. Scripts own deterministic steps, such as format conversion, field checks, and wrappers around internal interfaces. Resources own positive and negative examples, vocabularies, and output templates.

    The division of labor is straightforward. The prompt decides what to do and what not to do. The program decides how to do it in a repeatable way. Resources decide what “good enough” looks like. The agent still decides when to call a package and how to combine packages, but reliability no longer rests on a single generation.

    A practical directory convention

    Keep each package small and complete. A useful layout is:

    • Instructions: task goal, applicable and non-applicable scenarios, input and output contract, and safety and compliance constraints.
    • Procedure: step-by-step operations, human confirmation points, and timeout and retry policy.
    • Scripts: deterministic logic for validation, transformation, and aggregation. Do not restate complex rules in natural language inside the instructions.
    • Resources: templates, examples, error-code mappings, and glossaries.
    • Tests: normal, boundary, and refusal cases, plus the expected structured results.

    Loading can stay simple. Match coarsely against the user’s goal, and read only the summary and trigger conditions in the instructions. Load scripts and resources only after a hit is confirmed. Packages that do not match never enter context. That controls cost and reduces interference from unrelated instructions.

    1. capability-package/
    2. instructions.md # goal, boundaries, inputs and outputs
    3. procedure.md # steps and human confirmation points
    4. scripts/ # validation and transformation
    5. resources/ # templates and examples
    6. tests/ # normal, boundary, and refusal cases

    Design principles

    Single responsibility. One package solves one class of specialized task, such as “extract structured action items from a meeting,” not “handle all office documents.” Mixed duties blur trigger conditions, and the model is more likely to call the wrong package.

    Contract first. Define input fields, output structure, and error types before writing the instructions. Downstream systems depend on the contract, not on the wording of one generation. Missing fields, wrong types, and values outside an allowed set should be rejected when data enters or leaves the model.

    Refusal by default. State non-applicable scenarios in the instructions: insufficient information, actions beyond authority, unauthorized data, or results that cannot be validated. A refusal is a valid output and is safer than a forced generation.

    Push determinism down. Sorting, deduplication, unit conversion, regular-expression checks, and masking of sensitive fields belong in scripts. The model should understand and orchestrate. It should not act as an untestable business-rule engine.

    Load the minimum. Use the summary for discovery. Read the full text, scripts, and resources only when needed. Large examples should not enter every turn by default.

    From a pilot to an engineering practice

    Advance in four steps. Do not convert every prompt into a package at once.

    1. Inventory repeated work. Find prompts that are pasted again and again, manual recovery steps, and outputs that are often reworked. These are the first candidate packages.
    2. Extract the contract and failure modes. Record what real inputs look like, which outputs downstream systems reject, and which requests should have been refused. A package with no failure samples is hard to judge after launch.
    3. Script the executable parts. Cover validation and formatting first, then more complex procedures. Every step needs an observable intermediate result so failures can be diagnosed.
    4. Set a release bar. Treat package changes like code changes: review the instructions for contradictions, run regression cases, and record the version and the reason for the change. During a gradual rollout, enable the package for only some sessions and compare refusal rate, rework rate, and human-takeover rate.

    Version control does not need to be elaborate, but it must exist. Version instructions, scripts, and resources together. Do not allow “the live instructions have changed while the script still runs the old logic.” Retire obsolete packages explicitly so old trigger conditions are not still matched.

    How the runtime selects and combines packages

    Dynamic loading is not unconstrained calling. Three layers of control are enough.

    • Discovery: recall candidates from short summaries and trigger conditions, and cap how many candidates are considered.
    • Admission: check caller identity, data scope, and task type. If preconditions are not met, do not load the package.
    • Execution: run against the contract. For significant side effects—writing back to a business system or sending something externally—require human confirmation or a second check.

    Packages may be combined, but the combination must be explicit. The output of an upstream package must satisfy the input contract of the downstream package. Do not let the model invent the link when an intermediate result is missing. If the same combination appears often, promote it to a higher-level procedure package instead of stitching it together on the spot every time.

    Quality, safety, and observation

    After a package is live, watch at least four signals: whether triggers are accurate (missed calls and calls that should not have happened), contract pass rate, whether refusals are justified, and how much humans still edit the result. “The model thinks it is done” is not a useful metric.

    On safety, instructions and resources may contain business rules and should be managed by data classification. Script permissions should follow least privilege and reach only the storage, messaging, or compute needed for that task. Logs should record package name, version, an input summary, and validation results, and should not retain full sensitive source text for long. Treat external input as untrusted: user content must not rewrite rules inside the package or let the model skip validation scripts.

    In a cloud deployment, object storage fits versioned instructions and resources, containers or functions fit stateless validation scripts, and logs plus monitoring alerts surface wrong triggers and abnormal failures. These are ordinary platform capabilities. The choice should follow the architecture you already have, not a platform invented only for capability packages. If a team already uses storage, compute, and observability components on Baidu AI Cloud, connect package artifacts, execution, and audit to the existing pipeline. That does not change the contracts or governance principles above.

    Common mistakes

    Stuffing an entire policy document into one package inflates context and makes the package untestable. Extract the executable rules and attach a source note.

    Using a package to hide an unclear requirement. A package can stabilize a known task. It cannot replace a definition of input quality and acceptance criteria.

    Writing instructions and skipping tests. A package with no refusal cases will confidently emit the wrong structure on boundary input.

    Letting packages implicitly share a global prompt. Shared constraints should be referenced explicitly and versioned together. Otherwise one edit produces unexpected side effects on every task.

    Closing

    Agent engineering shows up when a specialized task stops being “a prompt” and becomes a capability package that can be discovered, loaded, verified, and retired. Instructions own the boundary, scripts own determinism, resources own the standard, and tests plus observation keep the result trustworthy over time. What the team gains is not a more elaborate prompt. It is production capacity that can be handed over, audited, and extended step by step.