AI Agent Engineering: Six Capabilities for Moving from Demo to Delivery

    Reliable AI agents need more than strong code generation. This article examines six complementary engineering capabilities—token and context management, Skills, RAG, MCP, specification-driven development, and execution harnesses—and explains how they work together to manage requirements, evidence, permissions, tool execution, and validation. A coupon redemption feature illustrates how to turn a convincing demo into a controlled, verifiable software delivery process.

    1. Why AI Agent Demos Succeed but Real-World Delivery Fails

    In a demo environment, an AI agent typically works with a small codebase, a clear task description, and preconfigured tools. It can quickly locate a business module, add request fields, update the implementation, and generate a few tests. The result can look like independent software development.

    Real repositories are different. A request to “add coupon redemption to the order module” may involve order states, coupon expiration, access permissions, idempotency, failure compensation, and backward compatibility. The agent must establish reliable connections across code and documentation, not simply produce syntactically valid code.

    Common failures include:

    • Losing track of an important constraint after reading several files.
    • Finding API documentation but failing to implement or test its idempotency requirements.
    • Treating an expected tool result as an actual result after execution fails.
    • Expanding coupon redemption into refunds or reversals without confirmation.
    • Passing tests while violating permission boundaries, business rules, or repository conventions.

    These problems cannot be attributed solely to model limitations. A larger model may improve understanding and reasoning, but it does not automatically supply requirements, permission policies, or acceptance procedures.

    Tokens, Skills, RAG, MCP, SDD, and Harness provide six perspectives on agent engineering. They are not fixed layers in a universal standard, nor must they run as a sequential pipeline. They are complementary capabilities:

    Capability Core question Primary concern
    Tokens What information can the current reasoning step use? Context capacity and information organization
    Skills How should recurring tasks be performed consistently? Procedures and domain experience
    RAG How can missing knowledge be supported with evidence? External knowledge and retrieval quality
    MCP How can the agent connect to external capabilities? Tool interactions and resource access
    SDD What exactly should be implemented? Requirements, design, and acceptance criteria
    Harness How can the overall process run reliably? State, execution, validation, and recovery

    The engineering goal is not to add all six terms to a system. It is to connect each capability to specific failure modes and controls.

    2. Tokens: Managing Effective Working Context, Not Just Text Length

    The context window is not permanent memory

    Tokens are units used by models to process text. They do not map directly to characters or words. For an agent, the more important issue is that each reasoning step can access only a limited context window.

    System instructions, user requirements, conversation history, code snippets, tool responses, retrieved documents, and error logs can all consume context capacity. How these count toward limits depends on the model and runtime, but the system must reserve space for subsequent tool results and output.

    A large context window does not mean every piece of information receives equal attention. Repetitive logs, outdated conclusions, and irrelevant code can obscure critical constraints. There is a difference between placing information in context and having the model use it correctly.

    Locate first, then read—do not scan the entire repository

    For the coupon redemption task, start with a focused set of questions:

    • Which module should own redemption logic?
    • How does the existing coupon client make requests?
    • Is idempotency handled in the business layer or a shared component?
    • How do order states restrict redemption?
    • What testing and error-handling conventions does the repository already use?

    Then narrow the search through directory structure, symbol definitions, call relationships, and relevant code sections. Expand the reading scope only when dependencies remain unclear.

    This approach is more effective than loading many files at once. It also makes it easier to preserve the relationship between evidence and conclusions.

    Protect constraints and evidence during context compression

    Long-running tasks often require context compression: condensing earlier work into a shorter working summary. Compression is lossy, so a summary should never be assumed to preserve every detail.

    A useful summary should include at least:

    1. Goal:
    2. Add coupon redemption to orders.
    3. Confirmed constraints:
    4. Redemption requests must include an idempotency key.
    5. Refunds, reversals, and settlement are out of scope.
    6. Evidence:
    7. Idempotency requirements in the API documentation.
    8. Existing order-state validation.
    9. Current client error-handling conventions.
    10. Completed:
    11. Located the business entry point and client wrapper.
    12. Remaining:
    13. Confirm concurrent redemption behavior and failure recovery.
    14. Blocked:
    15. Access to the test environment has not been granted.

    Keep references that allow critical source material to be found again, such as file locations, versions, and relevant sections. Before major changes, reread the necessary evidence to avoid propagating omissions or misunderstandings from a summary.

    3. Skills: Turning Reusable Experience into Bounded Procedures

    In agent engineering, a Skill typically represents reusable task knowledge and operating procedures. There is no single required packaging format. A Skill may contain documentation, checklists, templates, or supporting scripts.

    Its purpose is not to make the model follow instructions mechanically. It is to reduce recurring omissions.

    For example, a Skill for adding a business API might require the agent to:

    1. Define scope and compatibility requirements.
    2. Review existing authorization and input validation.
    3. Specify duplicate-request and concurrency behavior.
    4. Organize code within existing module boundaries.
    5. Add tests for normal and exceptional paths.
    6. Check logs for sensitive information exposure.
    7. Report changes and remaining risks.

    More detailed procedures are not automatically more reliable. Each Skill should also define its applicability, required inputs, permitted actions, and stopping conditions.

    If a task requires a database schema change but the current authorization permits only business-code changes, the Skill should trigger a confirmation process rather than expand the scope automatically.

    Skill maintenance should focus on three questions:

    • Which real failures does it address?
    • Does it remain consistent with current repository rules?
    • Can acceptance results demonstrate its effectiveness?

    Without version control and ongoing evaluation, a Skill can turn outdated experience into a recurring source of errors.

    4. RAG: Supplying Evidence, Not Replacing Business Judgment

    Retrieval-augmented generation, or RAG, retrieves external material to provide knowledge relevant to the current task.

    For code changes, sources may include API specifications, design documents, business rules, historical changes, and incident records. The important question is not how much material is retrieved, but whether it is applicable, authoritative, and complete.

    Retrieve around specific questions

    “Coupon” is too broad a search term. More useful questions include:

    • Which fields does the redemption API require?
    • Who generates the idempotency key?
    • What response should repeated submissions of the same request receive?
    • Can a request be retried after a timeout?
    • Which order states permit redemption?

    Retrieval can combine keyword matching, semantic search, and structured filtering. RAG should not be equated with any single indexing technology.

    Preserve constraints when splitting documents

    If request parameters and idempotency requirements are split into separate chunks, a retrieval system may return only the parameter list and omit the business constraint.

    Document chunks should therefore preserve complete semantic units where possible and carry metadata such as version, effective date, applicable environment, and source location. For critical APIs, retrieve parameter definitions, error descriptions, and usage restrictions together.

    Validate retrieved information

    Documents may be outdated, contradictory, or incomplete. Agents should distinguish facts, inferences, and unresolved questions rather than treating every retrieved passage as equally trustworthy.

    Retrieved content is also external data, not a higher-priority instruction. Text that requests credential disclosure, bypassing approval, or unrelated tool calls must not be treated as authorization.

    The final result should establish a traceable chain:

    Evidence requires an idempotency key → the implementation supplies that key → duplicate-request tests verify the expected behavior.

    5. MCP: Standardized Connections Do Not Guarantee Safety

    MCP generally refers to the Model Context Protocol. It standardizes interactions among hosts, clients, and servers so that capabilities such as tools, resources, and reusable prompts can be exposed consistently.

    For coding agents, these capabilities may include reading repository files, querying documentation, running tests, and accessing business systems. Standardized connections reduce repeated integration work, but they do not replace permission controls or security design.

    Tool calls must have explicit execution states

    Tool execution should distinguish between:

    • The request has not been sent.
    • The request has been sent, but the outcome is unknown.
    • The operation succeeded.
    • The operation failed.
    • The operation was denied by permissions or policy.

    “Planning to run tests” is not the same as “tests passed.” Likewise, submitting a write request does not establish that a file was successfully modified.

    If retrieving API documentation fails, the agent should preserve the knowledge gap rather than assume it understands the API constraints.

    Authorize high-risk operations separately

    Reading code, modifying files, running tests, accessing production data, and committing code carry different risks. They should not share unrestricted authorization.

    Use least privilege alongside path restrictions, environment isolation, approval checks, and audit records. Operations such as deleting data, changing permissions, or deploying to production should not depend solely on the model’s judgment.

    Account for side effects before retrying

    Reading a file is usually safe to retry. Redeeming a coupon may produce business side effects. A timeout means the outcome is uncertain; it does not necessarily mean the operation failed.

    Before allowing a retry, confirm the idempotency mechanism, the ability to query the result, or the recovery strategy. The protocol provides connectivity; the business system and execution framework must define safe invocation semantics.

    6. SDD: Define Acceptance Criteria Before Generating Code

    Here, SDD means specification-driven development. It turns requirements into explicit, verifiable specifications that guide implementation and testing, rather than giving the model unrestricted discretion over a natural-language request.

    For coupon redemption, the specification should answer at least:

    • Which order states allow redemption?
    • How are coupons associated with users and orders?
    • How should duplicate and concurrent requests behave?
    • What happens when a remote call fails or its result is unknown?
    • Will existing order APIs be affected?
    • Which capabilities are explicitly outside this change?

    A concise specification might look like this:

    1. Goal:
    2. Eligible orders can initiate coupon redemption.
    3. Scope:
    4. Add a redemption entry point, client invocation, and related tests.
    5. Non-goals:
    6. Do not implement refunds, coupon reversals, or settlement changes.
    7. Key constraints:
    8. Calls must include an idempotency key that follows the business contract.
    9. Duplicate requests must not cause duplicate redemption.
    10. Failures or unknown outcomes must not be reported as successful redemption.
    11. Acceptance:
    12. Cover success, duplicate requests, disallowed order states,
    13. unavailable coupons, and remote-call errors.

    This is only a specification outline, not a substitute for the actual API contract. The composition, validity period, and storage of an idempotency key must be confirmed with the business system, not invented by the agent.

    Cross-system calls also introduce consistency problems. A single local transaction generally cannot guarantee that remote redemption and an order-state update both succeed.

    Depending on business requirements, the design may need intermediate states, persisted tasks, result queries, or compensation workflows. That choice belongs in the design discussion, not in an improvised code-generation decision.

    7. Harness: Coordinating Capabilities into a Reliable Execution Loop

    A Harness is not a specific product. It is the execution and control framework around the model, responsible for organizing context, scheduling tools, managing state, enforcing policies, recording activity, and validating results.

    Without such a framework, an agent can become an ever-growing conversation in which the model decides what to do, performs actions, and declares success without sufficient external controls.

    Replace vague progress with explicit states

    A code-change task can move through stages such as:

    1. Requirements clarification
    2. → Evidence collection
    3. → Design confirmation
    4. → Implementation
    5. → Validation
    6. → Human review
    7. → Delivery

    It should also be able to enter blocked, recovery, or failed states.

    Transitions need explicit conditions. Implementation should not begin while core business constraints remain unresolved. A task should not be marked complete when required tests have not been executed.

    Record plans, actions, and evidence separately

    Plans describe intended work. Actions record actual calls. Evidence records tool responses and validation results.

    Keeping these separate prevents the model from treating its own narrative as fact and supports recovery after an interruption. On resumption, inspect current files, execution state, and unfinished operations before acting, especially when repeated actions could cause side effects.

    Use executable checks for validation

    Self-assessment can help, but it cannot replace builds, tests, and review. Validation typically needs to cover:

    • Whether the code builds and follows repository conventions.
    • Whether normal and exceptional behavior matches the specification.
    • Whether idempotency and concurrency behavior are correct.
    • Whether changes exceed the authorized scope.
    • Whether logs or responses expose sensitive information.
    • Whether existing APIs or behavior have been unintentionally broken.

    The completion report must clearly separate verified results, unverified items, and checks blocked by environmental limitations. “It should work in theory” is not evidence that validation passed.

    8. How the Six Capabilities Work Together

    A robust delivery process can coordinate these capabilities as follows.

    First, use SDD to define redemption scope, non-goals, and acceptance criteria, removing ambiguity from the request.

    Next, use RAG to retrieve API and business evidence. Apply token and context-management practices to keep only the code, constraints, and conclusions needed for the current stage in working context.

    During implementation, Skills provide a checklist aligned with repository conventions. MCP, or another controlled connection mechanism, provides access to files, test execution, and other external capabilities.

    The Harness continuously manages task state and checks tool results, permission denials, budget consumption, and validation outcomes. Conflicting evidence sends the task back to clarification. Permission problems pause the affected action. A business call with an unknown outcome requires a status check before deciding whether to retry.

    The final deliverable should include more than code:

    • The scope of the changes and their business rationale.
    • The specifications and evidence supporting key implementation decisions.
    • The checks actually performed and their results.
    • Unresolved issues and risks.
    • Items requiring human confirmation.

    9. Evaluate Agents for Trustworthy Delivery, Not Apparent Intelligence

    Engineering agents should not be evaluated only by generation speed or test pass rate. More useful dimensions include requirements coverage, consistency with evidence, unauthorized behavior, failure recovery, scope control, and human review effort.

    Early adoption should focus on bounded, manageable-risk tasks. Establish reliable specifications, tool permissions, and acceptance loops before increasing automation. Before adding more capabilities, demonstrate that the existing ones can be observed, verified, and constrained.

    A mature agent is not one that never makes mistakes. It recognizes when evidence is missing, permission is absent, an outcome remains uncertain, or human intervention is required.

    Moving from demo to delivery means placing model reasoning inside a controlled engineering system. Token management preserves effective context. Skills capture reusable execution experience. RAG supplies verifiable knowledge. MCP standardizes external connections. SDD defines the correct target. The Harness closes the execution and validation loop.

    Together, these capabilities make it possible to turn code generation into stable, trustworthy engineering delivery.