Back to libraryContentsContents

Book

People and AI Agents: Transforming Organizations and Engineering Work

How people and AI agents can share work without losing responsibility, judgement or control.

About 80 min read

Contents

An organization-wide perspective on how people, agents and accountable work change together.

Companions: the Engineering Handbook develops the production engineering perspective; the shared executive summary introduces both books.

This document draws on two books, AI Engineering by Chip Huyen and Designing Multi-Agent Systems by Victor Dibia, together with published research, technical documentation, and engineering analyses. References accompany the relevant ideas, with a thematic source guide at the end. The books provide complementary foundations: working with models, data, and evaluation, and designing agent execution, coordination, and human control. 39 45

This is an engineering perspective on transforming work, not a prediction of full autonomy or a list of mandatory technologies. Mechanisms, findings from individual studies, and proposed practices have different levels of evidential support. Their applicability depends on the task, the available data, and the consequences of error.

The argument and workflow recommendations are a synthesis, not a chapter-by-chapter substitute for either source book. Attributions identify borrowed concepts; proposed controls and business applications extend them. Worked scenarios are illustrative unless explicitly attributed to a published account. They do not describe the author’s customers or deployments.

Reader Map

This book can be read as a connected argument or entered through the route that matches the reader’s immediate responsibility.

  • Organization or process owner: start with the Introduction and Part I, then read Connecting the Two Perspectives, A Practical Path and the two worked cases in Sections 25-26. This route frames an outcome, owner, human decision and acceptable failure before discussing implementation.
  • Product or engineering leader: read the Introduction, Part I, Connecting the Two Perspectives, Sections 6-10 and Sections 16, 19 and 21. This route links business accountability to finite engineering work, evidence, security and release operations.
  • Hands-on engineer: start with Connecting the Two Perspectives and A Practical Path, then use Part II according to the task. The companion Engineering Handbook provides the corresponding production contracts, checklists and runbooks.

Introduction. Moving from Established Practice to New Ways of Working

AI changes not only the tools people use but also how work is divided between people and software systems. Previously, employees performed much of an intellectual task themselves, using software to search, calculate, and present their work. Now a system can be asked to produce a substantive result: investigate a question, propose a solution, change code, or reconcile documents. How far delegation should go depends on the task and the controls in place, not on how confidently a model responds.

This transition is happening at three levels simultaneously. For individuals, everyday workflows change: defining a task, finding supporting evidence, producing a result, and checking it. For teams or departments, the division of work, handoff rules, and decision queues change. For organizations, end-to-end processes, accountability, economics, and acceptable risks change. Improvement at one level does not guarantee improvement at the others: an employee may prepare documents faster while the department takes longer to approve them.

Transformation therefore cannot be reduced to buying an assistant or deploying large numbers of agents. Organizations need to understand which established activities remain useful, which should be redesigned, and where new possibilities have emerged. Sometimes AI strengthens an individual specialist’s work; sometimes it enables an entirely different process. Sometimes the main obstacle has nothing to do with the model: there is no data owner, no clear criteria, or no authority to take action.

This document connects two perspectives. Organizational transformation asks what work can be delegated and under what conditions. The transformation of engineering work asks how to design, build, verify, and maintain a system capable of doing that work. Engineers operate in both: they use agents themselves while creating capabilities for other people.

Part I. How Organizational Work Changes

Organizational transformation does not begin with the design of an agent. It begins by defining a useful outcome, accountability, and the human role in the process. Those decisions establish the requirements for the engineering system that follows.

1. From Individual Actions to Completed Work

The starting point should not be assigning agents to departments, but identifying an outcome the business can recognize. A customer issue is resolved without a repeat complaint; data has been reconciled with its owner; a service change has passed verification; a purchasing decision has comparable evidence behind it. “The agent responded” and “a document was generated” describe intermediate actions, not necessarily useful outcomes.

A suitable automation candidate has accessible inputs, a clear owner, sufficient repeatability, and an observable cost of error. Feedback speed matters: when a wrong decision is discovered six months later, expanding autonomy is harder than when immediate reconciliation is possible. A large volume of manual work does not, by itself, establish the value of AI. The underlying problem may be missing access rights, inconsistent reference data, or a lack of agreement between departments.

Before development begins, reconstruct the existing process: who receives the request, what data they seek, where they make decisions, what they change, and who receives the result. Measure not only employees’ active working time but also waiting time, rework, exception rates, and the consequences of errors. Otherwise, faster drafting may make little difference against a week-long approval queue.

A simple baseline is needed for more than a formal comparison. It shows which part of the task actually requires a model. A rule, SQL query, conventional search, or redesigned interface may solve the problem without a probabilistic component. Rules of Machine Learning articulates the principle of building a reliable pipeline before introducing a complex model; here, that principle applies to an entire business process. 2

AI Engineering adds a useful framing: technical quality must be connected to a threshold of practical usefulness. A small improvement in classification may change nothing while an employee still has to check every record; once sufficient reliability is reached, it may enable automatic processing of a narrowly defined class. That threshold is specific to the domain, not taken from a general benchmark. Chapter 4 encourages finding this connection, but its numerical examples are not business standards. 39

A practical starting point: describe one outcome, its recipient, an observable criterion for sufficiency, unacceptable errors, and the current human effort involved. If the criterion is not yet clear, a separate research task to establish it is appropriate. That is a basis for Discovery, not permission for uncontrolled operation.

2. Delegating Goals and Defining Accountability

Assigning work to AI changes how it is executed; it does not remove ownership of the outcome. An organization must distinguish the party proposing an action, the party authorizing it, the party executing it, and the party accepting the result. These responsibilities can be combined where the risk permits; consequential verification requires the right expertise and sufficient independence.

A useful starting point is the boundary of one process: which inputs are available, what result the next participant needs, and which exceptions return to a human. If a department hands another team nothing more than the word “done,” it leaves the recipient to reconstruct the context. A good handoff includes the current result, its supporting evidence, its limitations, and a clear statement of the decision still required.

A goal is more useful than a list of small instructions when it is finite. It needs an outcome, an authorized scope of changes, a budget, and conditions for completion and stopping. The budget covers assistants, retries, and resumptions after a pause. A new run ID must not reset the overall limit. “Improve quality” without a criterion for sufficiency is not an executable, finite goal.

Authority and manual confirmation are not synonymous. An organization can authorize a narrow class of routine operations in advance, subject to verifiable conditions. An exception, a changed payload, or an action outside that class requires a new decision. Agent autonomy is useful within an agreed boundary; it does not grant the right to expand that boundary during execution.

A manager does not have to assign every step to an agent. The manager sets the direction and the conditions for sufficiency, while the system can decompose the work and involve additional workers. Each handoff must still have an owner, resource limits, and a way to determine whether the result has actually been obtained. The organization manages progress toward a final outcome, not the number of active agents.

Evaluate the transition by asking which work a person no longer performs manually and what new responsibility they have acquired. Automating preparation can increase the need for expert verification; autonomous execution requires deliberate exception handling. Quietly transferring risk to an employee is not successful delegation.

3. Human Control and the Delegation Interface

Human-in-the-loop does not mean constantly interrupting people. A good interface presents the exception, the evidence, the proposed action, the risk, and the decision required. People must be able to correct the goal, reject a specific operation, change the authorized scope, and see what has already happened and what cannot be undone.

Victor Dibia’s Designing Multi-Agent Systems, Chapter 3, examines this shift from operating an interface to delegating work. Its discussion of capability discovery, action consequences, visibility and intervention informs this section. The recommendations below apply those ideas to accountable business workflows; they are not a reproduction of the book’s implementation guide. Dibia, Chapter 3

The role of AI shapes the interface. Suggestions for a specialist, autonomous processing of a limited class of cases, and proactive approaches to the user have different requirements. An unsolicited recommendation must justify the interruption. Personalization requires checking the stability of preferences and access to them, not just overall response quality.

Human review capacity is limited. If the system produces proposals faster than people can assess them, a queue develops or approval becomes mechanical. Measure waiting time, the proportion of useful escalations, errors after approval, and the reviewer’s actual attention. A high acceptance rate without edits does not, by itself, demonstrate mature autonomy.

Consequential decisions need owners for the outcome, data, runtime, and exceptions. One person may hold several roles. The problem is not having few job titles; it is a decision whose accountability has silently been transferred to a model. The interface should help people finish their work, not turn them into unpaid suppliers of ratings for the system.

Choose how people participate for each class of action. Dibia discusses approval choices in Section 3.4.2. For the business workflows considered here, use the following working distinction, not a standardized autonomy scale:

  • Execute automatically: the action falls within a preauthorized, verifiable boundary.
  • Execute and notify: authorization is already in place, but the person needs to know the outcome; notification does not substitute for missing authorization.
  • Obtain a decision before acting: an exception or consequential effect requires authorization tied to the operation.
  • Leave the action to a person: the system prepares the evidence, but neither the decision nor its execution is delegated.

These choices do not follow from model confidence alone. They depend on permissions, data, reversibility, the consequences of error, and the ability to confirm the outcome. The cost of an action includes its consequences, not just its computation. In a hypothetical stock-management workflow, changing a reorder threshold may take one inexpensive API call yet cause repeated unnecessary purchases. The interface should expose that effect before asking someone to delegate it.

Make the boundary understandable. Show a few validated workflows and their limits, such as preparing a reconciliation, finding evidence for a decision, or handling a routine request. These are examples of task descriptions, not claims that a particular product has been validated. Any indication of reliability should be grounded in a known task class and version, not an invented probability of success. When a case falls outside the validated scope, offer a bounded investigation or a specialist’s involvement. This applies Dibia’s capability-discovery principle in Section 3.4.1.

Operators need a clear status: what is complete, what is pending, what consequences have already occurred, and what decision is required. Engineers also need versions, routing errors, latency, and causal relationships. These are two views of the same work, not two independent sources of truth. Details are revealed as needed; a stream of technical events does not have to dominate the main screen.

Effective intervention changes a specific part of the work. A person can correct an assumption, clarify a criterion, revoke permission to send something, or perform a difficult step manually. The Magentic-UI research describes collaborative planning, shared execution and action approvals as distinct interaction mechanisms. It offers design ideas, not a guarantee of their effectiveness in another organization. Mozannar et al., Sections 3-4 and 6.4

For an operational workflow, intervention must also create a new version of the relevant state and visibly invalidate results that no longer apply. This is an engineering recommendation, not a claim that the research prototype provides every required safeguard. Simply appending a clarification to a shared chat and hoping every worker adjusts is not enough.

Interactive and background work need different interfaces, a distinction also discussed in Dibia’s Section 3.5. Interactive work depends on responsiveness and correction during execution. Background work places greater emphasis on a clear brief, an exception queue, final reconciliation, and recovery after failure. Background does not mean non-live: an operation running out of sight may still transmit data, spend money, and change the outside world.

Further reading: Victor Dibia, Designing Multi-Agent Systems, Chapter 3, especially Sections 3.4-3.5 (book; companion code). Hussein Mozannar et al., Magentic-UI: Towards Human-in-the-loop Agentic Systems, arXiv:2507.22358v1, 2025 (paper).

4. The Economics of Outcomes and Human Attention

Token prices are convenient for accounting but insufficient for decision-making. The cost of an acceptable outcome includes all model calls, retrieval, storage, orchestration, retries, reviews, corrections, and human time. A cheap answer that requires expensive rework may lose to a stronger model. An expensive team of agents does not become efficient simply because its discussions are detailed.

Useful measures include the acceptable completion rate, time to outcome, cost of completion, manual interventions, consequential errors, and rework after handoff. The cost of an acceptable outcome is calculated as all expenditure over a chosen period, including failed attempts, divided by the number of acceptable completions. If there are no completions, the metric is undefined, but expenditure must still be reported. For the success rate, failures remain in the total number of cases for the chosen unit of observation. Partial and deferred tasks are shown separately so they do not disappear from view.

The next improvement should be judged by its marginal value: which observed problem does an additional cycle address, and at what cost? Early successes with an off-the-shelf model do not support a linear estimate of the effort needed to handle the remaining difficult exceptions. Restricting automation to a well-defined class can be more valuable than pursuing universality. Deciding not to automate further is a legitimate engineering decision.

Dibia’s Section 1.6.2 distinguishes elapsed time from human attention. Background work may take longer than a manual action yet still be worthwhile if it requires little involvement and meets the deadline. The reverse is also true: a fast agent may be less effective if an employee spends a long time framing the request, reconstructing context, checking the result, and reworking it. Applying this distinction, measure not only tokens and end-to-end latency but also minutes of involvement, context switches, time waiting for decisions, and subsequent repair time. The book’s numerical illustration is not an economic estimate for these workflows. 45

A company must also account for the recipient’s ability to process the result. A thousand cheaply generated proposals may increase approval queues, repeat contacts, and customer rejection without improving sales. Similar asymmetries matter in hiring, procurement, support, and internal reviews. Measure useful flow through completed decisions and downstream workload, not the number of documents generated. The volume sent must be constrained by process capacity and agreed contact rules; more agents will not fix an overloaded decision owner.

Organizational research such as DORA provides useful context for systemic changes in development. It does not replace local calculations or establish causality for a particular company. Successful transformation means not only producing more text but also wasting less human attention at an acceptable level of risk. 32

5. How Organizations Learn and Preserve Expertise

A new way of working cannot be declared effective merely because it is technically possible. Organizations need a repeatable way to compare intent with actual outcomes and turn experience into bounded changes. This applies both to software and to the methods people use to work with agents.

A natural cycle for improving methods consists of real work, independent analysis of its traces, workers’ self-assessments, comparison, and a bounded update. The order matters: the researcher first forms a view without prompting, then workers’ accounts reveal what was invisible or misunderstood. Self-reporting is additional evidence, not a substitute for artifacts.

Two problems must be distinguished: a method was not actually used, or it was useful but its contribution was not preserved. The first calls for better routing, accessibility, or a better method; the second calls for a minimal trace of “guide -> changed decision -> evidence.” Requiring every response to list all the skills used does not solve both problems.

An update needs a hypothesis and an observable effect. For example, a clear handoff contract may reduce returns caused by missing evidence. After deployment, ordinary work is collected as evidence; that is the trial in practice. A parallel ceremonial pilot is unnecessary when the real rollout is already bounded, observable, and reversible.

Operational evidence needs three separate readings. Runtime health asks whether systems and tools ran as expected. Outcome health asks whether the recipient received the agreed result. Trajectory health asks whether the route was safe, proportionate, and consistent with the workflow boundary. A technically clean run may still fail the recipient’s goal; a good final result may still reveal a costly or unsafe path. Teams should investigate recurring patterns, turn confirmed failures into bounded evaluation cases, compare a proposed change against a stable baseline, and leave promotion to the owner with release authority.

Preserving human expertise is an engineering requirement for the organization. If employees see only final answers, they may lose the ability to handle exceptions and train new colleagues. Accessible evidence behind decisions, expert examination of difficult cases, and genuine accountability are essential. This does not require reading every transcript; it means preserving the ability to explain and change the process when automation goes wrong.

A worker’s self-assessment and observable work traces answer different questions. The former helps explain decisions and difficulties with the method; the latter shows which actions, checks, and results were actually preserved. A discrepancy may indicate a process error or insufficient visibility, but it should not automatically be interpreted as poor performance.

This cycle does not require endless calibration. After a justified change, the team returns to normal work and gathers experience. Another iteration is justified by a recurring problem or an opportunity for a meaningful outcome, not simply by the existence of another interesting idea.

Connecting the Two Perspectives. From Business Process to Engineering System

Organizational questions can now be translated into technical responsibilities. “A person can revoke a send action” requires specific cancellation and authorization semantics. “The result is verifiable” requires identifiable inputs, accessible evidence, and evaluation criteria. “An employee should not have to watch the agent constantly” requires durable state, clear exceptions, and controlled recovery.

The overall sequence is request -> routing -> context -> execution -> verification -> outcome. It may contain conditional branches and bounded repair loops. These are logical responsibilities, not six mandatory services.

  • Request and goal: the original intent, the recipient of the result, constraints, and a criterion for sufficiency.
  • Routing: existing code, a model call, a workflow, bounded agent exploration, or human involvement.
  • Context: the required data, with provenance, currency, identity, and permission to use it.
  • Execution: the model proposes the next step; authorized tools and the existing components responsible for the behavior perform the actions.
  • Verification: appropriate methods check form, domain invariants, the legitimacy of the execution path, and the fitness of the result.
  • Outcome: the next participant receives a specific artifact or a confirmed change, its limitations, and the remaining decisions.

Three groups of responsibilities run across the entire sequence: state and recovery, authority and security, and observability and resources. The human is not merely a final approval button: people set goals, clarify evidence, make consequential decisions, and can intervene during execution. Their interface presents the same system in terms of meaning, rather than exposing the entire technical transcript.

This map helps check the completeness of a process without prescribing a separate component for every item. A small system may implement several responsibilities in one application. The engineer’s next question is: what is the minimum set of mechanisms needed to fulfill this particular contract?

A Practical Path. The First Working Process

There is no need to master the entire stack described below before starting. Choose one task and build a minimal end-to-end path that produces a useful outcome. A single process needs a few connected responsibilities, not a separate service or agent for each one.

  • Name the outcome and its owner. For example, prepare a reconciled evidence package for deciding a customer case, rather than merely generating a response. Define who will use it, what counts as sufficient, and which errors are unacceptable. Measure current manual effort, waiting time, and work returned for correction.
  • Test the simplest path. A rule, data query, or conventional search may cover part of the task. Reserve the model for interpreting unstructured input. Add multiple agents to meet a demonstrated need for dividing work or checking it, not to match the number of future departments.
  • Prepare inputs and permissions. Choose authoritative data, stable IDs, authorized tools, and the permitted workload. State unknowns explicitly; a long prompt cannot compensate for a missing document.
  • Assemble a minimal system using existing tools. One possible setup is an existing document store, a few domain APIs, one worker, checks, and a screen or another clear way to accept the result. For a consequential result, add a separate reviewer who did not author it. Do not build an orchestration platform of your own until the process requires its specific capabilities.
  • Set boundaries before taking consequential action. Specify authorized effects, the total budget, permitted retries, exit conditions, and human involvement. An uncertain outcome after a timeout must be reconciled before any blind retry. Retain the state needed to continue safely.
  • Check more than the successful example. Use a typical case and relevant failures: the wrong object, missing evidence, a repeated request, or changed authorization. Verify the actual outcome with the system responsible for the operation. The author’s declaration of “done” is not acceptance.
  • Hand over the result and calculate the full cost. The recipient needs the current artifact or confirmed change, supporting evidence, limitations, and the remaining decision. Count every attempt, human review, waiting time, and rework, not just the tokens in a successful run.
  • Expand only a working path. Add the next task type, source, or authorized action after observing value. If the process constantly needs manual rescue, adding more agents scales an unfinished design. First address the reason for those interventions or narrow the supported scenario.

The first outcome may be modest: a prepared and verified package without any external sending. That is a complete delivery if it is the agreed outcome; preparation cannot retrospectively be described as a completed business operation. For research, “there is not yet sufficient evidence” is an acceptable result when accompanied by a specific next action.

Continue according to your task. For everyday AI-assisted development, start with Section 6. Execution design draws on tools, loops, and recovery in Sections 8-10; data and knowledge work on Sections 11-13; diagnosis, models, and quality evaluation on Sections 14-18. Security and confirmation of outcomes apply from the first consequential action, even though their detailed treatment appears later. Fine-tuning and serving optimization in Sections 23-24 are needed only when the corresponding problem exists, not as mandatory implementation stages.

Part II. How Engineering Work Changes

Engineering transformation has two meanings. Engineers use AI in their own work and build AI capabilities for other processes. In both cases, they are responsible for choosing a sufficient design, providing evidence of correctness, and keeping the system understandable as it changes.

The technical choices below are presented as responses to specific responsibilities, not as a list of new technologies to learn and implement all at once.

6. From Writing Code to Managing Verifiable Change

Using AI does not eliminate the established engineering cycle, but it redistributes effort within it. Some code reading, exploration of alternatives, and implementation can be delegated. In return, precise task definition, context selection, assumption checking, and acceptance of changes become more important. Engineers do not need to understand every intermediate model message; they need to understand the consequential decisions and the effects of the result.

A practical workflow begins with the question and the existing system: what needs to change, which component owns the behavior, what already works, and what evidence will be sufficient. A bounded scope is then selected for the agent, the result is checked, and a specific violation is corrected. A new version is not accepted merely because an agent confidently reports its completion.

AI accelerates more than coding: it can help investigate a system, formulate a specification, reproduce a defect, design a migration, and check compatibility. But those outputs must remain connected to the original intent. A chain of documents that does not bring a verifiable change closer can be as costly as endless code generation.

A narrow repair needs a violated invariant, an authorized change, non-goals, and a negative check. Changes to data ownership, API semantics, or authority require full design work. Diff size is not a measure of risk: a few lines can change permissions, while a large mechanical change can preserve behavior.

The implementer checks the specification before implementation: are the requirements, exceptions, dependencies, and required evidence clear? After implementation, verification checks whether the intended outcome has been achieved, not merely whether the author’s plan was followed. Consumer validation requires a real use case. Internal acceptance by the specification team and usefulness to the customer do not substitute for one another.

Structural quality is checked alongside current tests. SlopCodeBench studies the sequential evolution of programs and raises the question of accumulating complexity while functional checks continue to pass. It is a bounded study, not a forecast for every project, but the cost of the next change genuinely belongs in a review. 23

Useful practices include finding duplicate execution paths, checking consumers of shared components, removing unnecessary abstractions, and preserving clear ownership boundaries. Reducing line count is not an end in itself: a universal helper can shorten the code while increasing coupling. Reuse works when the next engineer understands the contract and does not need to study the entire framework to make a local change.

Review also preserves human understanding of the system. HumanLayer’s analysis emphasizes research and planning as ways to maintain a shared understanding of what is happening. This is the authors’ experience, not a controlled guarantee of faster work. Significant decisions, dependencies, and rollback options must remain understandable to the team even when an agent writes the code. 24

Checks should operate at the level of the affected contract. A mock confirms a call, not a migration or the permissions of a real role. A linter checks a local rule but does not rule out an incorrect business path. At the same time, auditing the entire application for every narrow repair destroys the benefit of automation. The risk and failure mechanism determine what verification is sufficient.

Personal effectiveness means engineers spend less time on repetitive operations and exercise more control over consequential decisions without losing their understanding of the system. The amount of generated code and the speed of the first response do not demonstrate this on their own. Good delegation leaves a result that the engineer can explain, verify, and maintain.

7. Choosing a Sufficient Architecture and Type of Work

Deterministic code executes a known rule. A single model call extracts meaning from unstructured input. Retrieval adds external information. A workflow defines sequences and branches. An agent dynamically chooses subsequent actions. Multiple agents divide context or work. These options are not a maturity ladder with a mandatory final rung.

The literature uses the word “agent” broadly. For engineering decisions, a useful working distinction is whether the program defines the sequence of actions or the model chooses it based on observed state. This distinction between workflows and agents helps assess the additional variability, cost, and need for control. 1

The approaches can coexist within one process. A model recognizes the customer’s intent, code checks the order and the limit, an agent investigates an unusual cause, and a person decides on an exception. There is no need to give a model responsibility for balance arithmetic or the right to override a rule already implemented by a service. The ability to reason does not make the model the owner of operational state.

It is useful to distinguish three types of work. Discovery ends with a justified next decision, sometimes with explicitly identified uncertainty. Build creates or changes a product capability and requires evidence that it meets the contract. Operate uses an existing capability and ends with a reconciled operational result. This is a proposed organizational framework, not terminology shared universally by all tools.

“Restore data collection” may include all three: diagnosis, repair of a handler, and a new collection run. These do not have to become three bureaucratic projects. It is enough to distinguish when code changes, when external effects occur, and precisely what is authorized. Acceptance of a repair does not prove that earlier, partially completed operations have been recovered.

The choice has independent dimensions: who determines the next step, how many workers participate, where they run, and which effects they are authorized to produce. Multiple agents can run in one process under a fixed workflow. A single agent can autonomously investigate a failure. Distributed deployment is justified by isolation, load, or organizational boundaries, not merely by the existence of different roles. This separation develops the taxonomy in Dibia’s first two chapters and prevents every team from automatically becoming a distributed platform. 45

Uncertainty can justify adaptive exploration. A high cost of error, by contrast, calls for narrower actions and stronger checks. An architecture diagram must not be read as a rule that “consequential outcomes require an autonomous team.” A need for different kinds of expertise is likewise a hypothesis about the value of dividing the work, not proof that one well-equipped agent is insufficient.

Studying a small agent implementation of your own can build understanding, but it does not oblige the company to maintain another library. In the epilogue, Dibia explicitly distinguishes learning how systems work from recommending that everything be built in-house. Engineers need to be able to check where state and permissions live, how tools are invoked, and what happens after an exception; reproducing the entire educational framework is less important. 45

Compare existing tools on one representative process. A small set of consequential capabilities can be checked: connecting the required model and tools; versioning and persistence; failure and resume; cancellation; the required human participation; observability; security configuration; data portability; and maintenance cost. Needs determine the weight of each criterion. A missing feature is not a weakness when it is unnecessary, and a rich catalog does not compensate for the absence of safe recovery.

Microsoft Agent Framework, for example, documents individual agents, explicit workflows, context providers, and middleware. It is a candidate for studying existing mechanisms, not a standard selected here or a promise that every language and version has identical capabilities. A build-or-buy decision follows verification of the required path, including migration, support limitations, and an exit strategy. 46

A stronger model may make some additional instructions, handoffs, and workarounds unnecessary. Test this by disabling them on comparable tasks and remove them once the evidence supports doing so. Access controls, operation identity, effect accounting, and accountability do not disappear as model capabilities improve. A prediction of lighter scaffolding is not permission to remove those boundaries.

8. Designing Tools and Integration Boundaries

Tooling consists of the executable capabilities around a model: search, APIs, tests, documents, and system access. A harness connects the model to those capabilities, state, permissions, and execution control. Markdown instructions explain a method; code and infrastructure enforce the actual constraints.

An interface should center on an understandable action: “prepare a refund proposal for this case,” not “make arbitrary changes to the database.” Inputs need types, units, required fields, and explicit constraints. Results should distinguish completed, rejected, decision required, and outcome still unknown. Tool errors should help diagnose the cause without exposing secrets. The contract also limits response volume: object count, content size, and continuation rules. Incomplete output must be visibly incomplete; pagination or a link to an authorized artifact is preferable to silent truncation. A model-call limit does not protect against a single oversized tool result.

In AI Engineering, Chapter 6, “Planning failures,” Huyen distinguishes errors in tool selection, argument structure, argument values, and goal achievement. Applying that distinction, a model may select a nonexistent tool, supply malformed arguments, supply structurally valid but domain-invalid values, or construct a valid but useless plan. Successful parsing is therefore not a sufficient check. 39

The existing owner of a behavior must be preserved. If an agent acquires a second way to change status through a file, direct SQL, or a one-off script, the contract begins to diverge. Reuse means, first and foremost, a single governed path and shared semantics, not the fewest lines achieved by bypassing an interface.

MCP standardizes connections to tools and resources; it does not make them trustworthy. Its security documentation covers authorization, the confused deputy problem, and token passthrough. Installing a connector does not resolve tenant isolation, permissible payloads, or an agent’s authority to take a specific action. 17

An oversized tool catalog also creates risk: incorrect selection, more context, and duplicate paths. Analyze incorrect calls and perform ablations on tasks. Low usage frequency is not sufficient grounds to remove a rare but important safe escalation route. Assess contribution, not popularity.

A shared model adapter must preserve semantics, not just expose the same method name. Check tool calls and their identities, stop reasons, refusals, partial streams, structured output, usage, and cancellation. Where support differs, make the capability matrix explicit and reject unsupported paths. Converting every provider result to a string hides errors the orchestrator needs to make a safe decision.

Delegation to a remote agent requires a contract broader than function arguments: the goal, input version, authorized actions, recipient, minimum context, data restrictions, budget, result and its evidence, cancellation, and reconciliation of uncertain outcomes. The coordinator forwards selected information or provides an authorized artifact link. A shared-context identifier does not assemble dependencies or grant access by itself. A capability card describes the worker’s claims; quality and authority to act are checked separately. MCP and A2A can address different parts of the connection, but there is no need to adopt both for the sake of their names. 25 45

9. Building Finite Loops and Useful Teams

The practical unit of autonomous work is a bounded loop: an input, a small deliverable, a check, and an exit condition. The next loop receives a versioned artifact with limitations, not a statement that “the previous worker did everything.” A sequence of these units is useful when each completes an understandable transformation.

Distinguish successful completion, partial results, insufficient data, and stopping at an authority boundary. Discovery need not eliminate uncertainty that only the next experiment can resolve. Build does not end with a specification alone. Operate does not end with a file count if the files have not been reconciled and are not ready for handoff.

Design a team as a way to manage dependencies and context, not as a replica of an organizational chart. The patterns below draw on Dibia’s Sections 2.2-2.4 and 7.5; their workflow examples and operational constraints are applications to the problems discussed here. None of these patterns establishes the correctness of the result on its own. 45

  • Sequence: extract a document, validate fields, and prepare a response. Appropriate when each step genuinely depends on the previous one; not every node needs a model.
  • Conditional routing: routine cases follow an automatic path, while exceptions go to the owner. Routing may depend on a model, but code enforces critical prohibitions.
  • Parallel branches: independent sources or checks are processed concurrently, then an integrator assembles the result. Concurrency limits and explicit rules for combining results are required.
  • Coordinator with a plan: an unknown path is decomposed into bounded assignments with verifiable outputs. The coordinator can also make mistakes and become a bottleneck; its declaration of success does not replace evidence.
  • Transfer of ownership: a task passes to a specialist with a version of its state and an outstanding obligation. This is different from calling an assistant as a function and receiving a response.
  • Shared conversation: useful for brief exploration of alternatives, but every additional round needs a reason. Conversation must not become the sole state of a long-running process.

A hybrid is often more natural than a single pattern: a fixed outer process contains a bounded investigation of an exception, and the investigator calls specialists with narrow contexts. The internal team retains the parent’s overall limit. A team hidden behind a single API call does not acquire a new budget or additional permissions.

A coordinator needs three distinct things: execution events, the working context for the next worker, and the state of the goal’s outstanding obligations. The last needs only to show the current goal, dependencies, the owner of the current step, attempt number, verified outputs, remaining resources, and the decision awaited. This can live in an existing task record. Exhausting retries for a required predecessor must not turn into an unconditional “move on”: independent preparation may continue, but completion of dependent work remains unproven.

Combining parallel work requires more than waiting for any three messages. The system must know which branches completed, were conditionally skipped, failed, or were cancelled; which input versions they used; and whether a partial result is allowed. A late branch based on an old version must not silently replace a newer conclusion. If two workers change the same object, ownership order or conflict resolution is required. Safe concurrent reading does not automatically imply safe concurrent writing.

An acyclic graph is convenient for dependencies, but it does not represent arbitrary returns along a backward edge. A repair loop can be modeled as a bounded node within such a graph, or a scheduler with explicit cycle support can be selected. Tests should cover not only a successful chain but also an unreachable node, a conditionally skipped dependency, conflicting results, and exhausted limits.

Plan only as far ahead as the available information supports. Research calls for the next justified step and a criterion for changing direction. A known operation calls for a predefined workflow. A complete plan for an uncertain future often creates the appearance of control rather than an executable path.

Every repetition needs a reason: a new defect, new data, or verification of a repaired part. Reviewing an unchanged artifact again without a new question does not automatically add reliability. Repeatedly searching until the first approval may even exploit a verifier’s weakness. Limits protect not only expenditure but also against selecting a chance “green” result.

Three events must be distinguished: the model finished its response; the orchestrator stopped the loop; the result was accepted under the contract. The absence of another tool call may indicate premature stopping, while the string APPROVED inside text may be a quotation or an inappropriate signal. Consequential acceptance binds a reviewer to a specific revision, criteria, and evidence. An iteration limit ends execution; it does not turn an incomplete result into an accepted one.

A pre-exit check is useful when it finds required work that remains unfinished. It must not restart the loop after cancellation, budget exhaustion, lack of authority, or an honestly established limit to the available data. The proposed runtime hooks check whether continuation is permitted before demanding completeness. The resulting outcomes remain distinct: completed, partial, human needed, insufficient information, limit exhausted, and cancelled. This is an application-level discipline built on educational termination patterns, not a promise of a universal verifier.

A hard limit must stop work independently of the success assessment. The condition “the limit has been reached AND the reviewer agrees” does not bound work until the reviewer agrees. Checking only after a turn ends cannot constrain a hanging tool or a large fan-out within that turn. Before dispatch, account for the remaining allowance, the number of parallel calls, and their limits; where exact cost is unknown in advance, explicitly define permissible reservations and limits on potential overspend.

The creator and a coauthor may investigate, build, and repair together. A separate reviewer checks a consequential result against the contract. A team is justified when it separates sources, expertise, verification methods, or independent pieces of work. Several equally informed agents discussing the same issue may spend more without producing an independent signal.

Technically, scaling does not require a window for every agent: a queue can distribute assignments, a bounded worker pool can execute them, and the operator can see goals and exceptions. But a queue does not resolve acceptance semantics. A2A describes tasks, messages, and artifacts exchanged between agents; version relationships, permission for the next step, and the business meaning of the result remain application contracts. 25

Assess a team’s usefulness through additional defects found, reduced downstream rework, and the cost of an acceptable outcome. Comparing tokens alone is unfair if a review would have been required later anyway. Yet the mere fact that a discussion occurred does not justify additional expenditure either.

Conversation history has a cumulative cost. If each of T turns resends all previous messages and each turn adds approximately m tokens, total processed input grows roughly as m × T × (T - 1) / 2, plus the repeated initial context. This simplified estimate assumes no compaction and a constant message size; it is not a bill forecast: caching changes the price, while tools and different models change the workload. It does explain why concise updates to shared state and targeted context delivery matter more than asking agents to “keep answers short.”

Choosing work and executing work are different loops. Keep the business goal separate from the current task. An initiative should state its evidence, expected effect, effort limit, and how the effect will be observed. A person decides on a material change in product direction or investment; the delivery loop then executes the approved scope. Repairing a defect within that scope does not authorize another initiative. After release, revisit the goal using observed outcomes over an appropriate period: a successful build or a reviewer’s approval does not establish business improvement. The cycle can end with no further change justified.

10. Designing for Failure, Resumption, and State

Long-running work must survive interruptions to the model, worker, and network. A conversation is not sufficient storage for a process. The system needs operation identity, durable state, a link to the input version, and clarity about which steps can be repeated.

LangGraph provides checkpoints and interrupts, but the semantics matter: after resumption, the code in the relevant node may execute again from the beginning. An external action before the pause point can be repeated. A persistence mechanism does not remove the need to design the effect boundary. 14 15

Suppose an API accepts a refund, but the response is lost. A timeout means uncertainty for the caller, not a proven operational failure. A blind retry may create a duplicate. A stable business-operation ID, idempotency support from the responsible system where available, and reconciliation by reading the actual state are needed. Durable execution does not create universal exactly-once semantics for external systems. 16

Cancellation is also ambiguous. Stopping the wait does not always stop external execution. Haystack, for example, distinguishes cancellation of native async components from synchronous work in a separate thread. For consequential actions, distinguish “cancellation requested” from “final outcome verified.” Serializing a pipeline graph, meanwhile, is not the same as checkpointing an operation already in progress. 13

Human approval must apply to a specific action: the recipient, payload, amount where relevant, version of the supporting evidence, and authorization expiry. If the proposal changes materially, an earlier “yes” does not automatically carry over. Permissions, balances, or object status may change between verification and execution. Rechecking shortly before execution does not close the race: critical conditions and the change must be linked through an atomic boundary or a conditional operation in the responsible system, such as a write that succeeds only at the expected version. For an external system, authorization semantics, acceptable revocation delay, and behavior when this linkage cannot be guaranteed must be defined separately.

When choosing an orchestrator, evaluate retry handling, persistence, cancellation, debugging, concurrency limits, and the cost of hidden calls, not the visual appeal of its graph. Ordinary code may be sufficient for a short process. A framework is justified by a specific requirement, not by a desire to prepare for every possible scale.

Distinguish the system definition, the execution snapshot, and the external-effect log. Serialized configuration defines what to run. A checkpoint records where execution stopped. Confirmation from the system responsible for the operation establishes what actually happened. Chapter 6 of Dibia’s book connects checkpoints with workflow structure checks; in production, that is insufficient if an unchanged graph receives a different prompt, tool schema, or policy. Resume compatibility is checked against the consequential configuration, input version, and state migration rules. 45

After a worker is lost, another worker must receive authoritative state and permission to continue that specific work. “Stateless worker” means the process is replaceable, not that state does not exist. Client-supplied JSON cannot be trusted as a source of authority: it must be authorized and tied to a stored server-side version. A redelivered event must be handled according to its identity and version, not treated as a new assignment.

One important negative scenario is a cancellation request arriving between dispatch of an action and receipt of its response. The system stops subsequent steps, preserves the status of the uncertain effect, and performs only permitted reconciliation. If the action did complete, that is what the user must be told. Returning to the previous business state may require a separate compensating operation with its own conditions and authority.

Tasks, user sessions, network connections, and waits for approval have different lifecycles. A background task may survive a closed browser tab; an interactive request may intentionally be cancelled on disconnection. That choice must be explicit. There is no need to occupy a worker while a person spends hours making a decision: the pending action is stored, and the eventual response is checked against the user’s identity, the version, and current authority.

A workflow definition, a specific run, and a business operation have different identities. Restoring “the latest checkpoint for this workflow” is unsafe when requests from different customers coexist. Resume checks must cover the tenant, run, input version, and execution compatibility. Two workers must not claim the same work simultaneously: the selected store needs an atomic claim or a lease with protection against a stale owner. Shared storage does not provide that guarantee on its own.

Cancellation has a propagation path: from the operator to the coordinator, active model and tool calls, and child tasks. Responsibility for termination, cleanup, and accounting for effects already produced must be defined. Cooperatively checking a flag does not interrupt an arbitrary synchronous function. Consequential recovery scenarios include failure after an external action but before a checkpoint, two simultaneous resumptions, another tenant’s checkpoint, a changed prompt with an unchanged graph, and cancellation with active child work. This is a set to select from according to risk, not a universal testing ritual.

Events and Human Interaction

An ordinary chat is sometimes insufficient. Version comparison, change previews, a decision queue, evidence links, and a clear responsible party may be needed. AG-UI offers an event model connecting the interface and agent backend, but required behavior must be checked in the specific implementation and adapter, not inferred from the protocol’s roadmap. 26

For voice, interruptions, turn queues, recognition, synthesis, and handoff to a person become separate engineering concerns. LiveKit Agents is an example of infrastructure for real-time interaction. The quality of a voice process is not reducible to the accuracy of a model’s text response. 27

The engineering foundation of the interface is a set of events with clear identities and meanings: a text fragment, a final message, a tool result, a decision request, a cancellation request, and a confirmed status. If final text repeats chunks already displayed, the interface must not append it again. Reconnection requires reading the current state and handling duplicate events, not restarting the same business operation. Events from another task must not enter the current session.

SSE through EventSource defines a server-to-client event stream, identifiers, and a reconnection mechanism; WebSocket provides a bidirectional channel. Neither transport creates durable task state, safe cancellation, or horizontal scaling by itself. The choice depends on the interaction and infrastructure; storage, backpressure, and resumption are designed separately. This qualification matters when reading educational comparisons of transports. 49 50

11. Preparing Data, Provenance, and Evaluation Sets

A practical dataset lifecycle includes the source and permission to use it, transformation versions, labeling instructions, consistency checks, dataset splits, duplicate control, and a clear correction process. These can be stored alongside the data without a separate large platform. A company’s valuable asset is not the volume of text accumulated, but examples available for justified use.

AI does not automatically reconcile discrepancies between a CRM, documents, and spreadsheets. Key objects need an owner and a stable identity: customer, contract, product, case, and document version. Canonical state is defined by the existing product contract, not by whichever text the agent read most recently.

Distinguish observation, inference, proposal, and accepted decision. A capability mentioned on a vendor’s website does not prove its availability in the required plan. Similar company names do not establish that they refer to the same company. Acceptance of a draft does not authorize publication. These distinctions must survive handoff to another agent or person.

A consequential fact should have a source, observation date, period of applicability, usage restrictions, and a link to the original object. Change history is needed to reconstruct the basis for a decision, not to accumulate reports. New information can refute old information, but a later timestamp alone does not establish greater authority.

Completeness has several dimensions. Are metadata, full text, attachments, the required time range, and all authorized sources available? “We read 20 documents” does not answer whether they included the two documents on which the decision depended. Research results should separately state corpus boundaries and deliberate exclusions.

Temporal separation also matters in ML. A feature must be available at prediction time, rather than appearing after the outcome is known. Related documents from one customer must not accidentally be split between training and evaluation in a way that makes the task recognizable. Fit preprocessing only after splitting the data; otherwise, evaluation may reflect leakage. 21

Usage rights are purpose-specific: reading material for a task, sending it to a provider, retaining a derivative, including it in evaluation, and using it for training are different actions. Technical access to a file does not answer all these questions. Design must account for minimization, retention, deletion, and ownership of permissions; specific legal decisions require domain-specific review, not a blanket promise that “everything is anonymized.”

Dataset Engineering

A knowledge corpus, training set, evaluation set, and operational logs may originate from the same processes but serve different purposes. They must not be mixed without an explicit transformation. A successful production response does not automatically become a high-quality training example, and a user’s correction does not always address a model error.

Chapter 8 of AI Engineering treats data quality, coverage, volume, synthesis, and processing as engineering work in their own right. The useful unit for a company is not a line of text but an example with clear provenance: the input, context at decision time, required outcome, labeling rules, and permitted use. 39

Quality depends on the task. “Cleaning” can remove information the model needs to learn to understand: customer typos, unusual names, mixed languages, or damaged formatting. Preserve raw input within the authorized environment, version transformations, and give each correction a specific purpose. Text extraction errors, ambiguous labels, and outdated facts should not all be grouped together as “noise.”

Deduplication is not only about savings. Nearly identical emails, templates, and documents can create train-test leakage and overemphasize a single scenario. Yet two similar documents with different dates or consequential conditions must not be automatically collapsed. First define the unit of identity and its version, then the deduplication rule.

Synthetic data is useful for difficult scenarios, format transformations, and constraint checks. It is not independent confirmation of reality. A generator can reproduce its own assumptions, reduce diversity, and create artificially easy tasks. Structural validation filters out only some problems; domain-specific sampling, provenance, and a separate real test set remain necessary.

Data proportions are also a design decision. When easy routine requests dominate, the average score may look excellent even while rare, consequential exceptions fail. A representative set for evaluating normal traffic and targeted failure sets for diagnosis are both needed. Their results cannot be combined into a single “production error rate” without accounting for how cases were selected.

12. Finding Sufficient Evidence through Retrieval

Minimum RAG checks: the required document was found; the context includes the information needed to establish the relevant condition; the source supports the claim; dates and permissions are respected; and the system can acknowledge that no sufficiently supported answer is available. Negative scenarios include conflicting versions, revoked access, similar names, and a fact absent from the corpus.

RAG comprises, at a minimum, corpus preparation, retrieval, context construction, and generation. A vector database addresses only part of the task. Document extraction must preserve the meaning of tables, headings, negations, units, and relationships. An error at this level can survive the entire pipeline and become a confident recommendation.

Docling is a useful tool for processing complex documents, but conversion alone does not establish extraction accuracy. Complex tables, columns, and scans should be compared with the originals on a domain-specific sample. For numerical decisions, the accuracy of currency, period, and sign matters, not just text readability. 37

Lexical search works well for exact terms, product codes, and identifiers. Semantic search helps with paraphrases. Hybrid search and reranking can be more useful than increasing the number of returned fragments. Chunk size should reflect document structure and the questions being asked: a small fragment may lose a condition, while a large one may add irrelevant context and cost. There is no universally correct token count.

Contextual Retrieval proposes adding brief document context to a fragment before indexing. This is a specific, testable technique, not a guarantee of improvement on every corpus. The generated description must remain grounded in the original text and must not introduce new facts. 4

Three measures must be distinguished. Relevance precision measures what proportion of retrieved material is useful for the question. Relevance recall requires a known set of relevant material and measures how much of it was found. ANN recall compares approximate nearest-neighbor search with exact search in the same embedding space. Good ANN recall does not establish domain relevance, and production recall generally cannot be honestly calculated over an unknown universe of useful documents. This is an important distinction in Chapter 6. 39

Permissions restrict information before it reaches the model. However, secure filtering can reduce retrieval completeness: pgvector documentation specifically describes filtering after approximate search, which can leave fewer results. Multi-tenant retrieval therefore needs both tests that other tenants’ data is inaccessible and tests that the user’s own results are sufficiently complete. 5

Answer verification goes beyond search. Does the source support the specific claim? Is the source itself reliable? Does it concern the right object and time? Lack of confirmation does not establish the absence of a feature. An answer that agrees with an incorrect document is locally consistent, not necessarily factually correct overall.

Query rewriting must be checked for changes to intent and identity. A question such as “what about the other customer?” must not be expanded by guessing who was meant. Aggregates, current statuses, and balances often belong in an authoritative API or an authorized query, rather than in a paraphrase of incidental textual mentions.

13. Managing Context, Memory, Prompts, and Skills

Context is the information available to the model at a particular step. Memory consists of objects retained between steps or tasks. A prompt specifies behavior for a call. A skill packages a reusable method with its scope, constraints, and resources. A tool provides an executable capability. None substitutes for the others.

Context needs the current goal, consequential constraints, and sufficient evidence. Other material is loaded as needed. This is not a contest to minimize token count: insufficient context causes repeated searches and errors. Yet indiscriminately adding old instructions and complete transcripts makes current information harder to identify. Context engineering is about selecting high-signal context, not filling the window to capacity. 3

Memory should distinguish unfinished task state, verified facts, preferences, and proposed lessons. These have different owners, access rules, lifetimes, and correction procedures. A compressed account can lose a constraint or turn an assumption into a fact. Key decisions and identities should therefore be recoverable from durable state, not just a model-generated summary.

Context Hub is interesting as a narrow example of delivering versioned documentation and annotations rather than an abstract “memory of everything.” Evaluate its mechanism separately from claims that the agent is now learning. Its current description treats annotations as untrusted input; a local note does not become policy. 6

Prompt engineering is ordinary iterative interface development: a clear task, necessary constraints, response structure, and good examples. Examples should show decision boundaries, not just the happy path. Contradictory rules, unclear terminology, and mandatory lengthy reasoning can increase cost without improving the outcome. Schemas and code control JSON format; content, permissions, and factual accuracy are checked separately.

Optimizing a prompt on visible examples requires a held-out evaluation; otherwise, the team quietly learns to pass its own test. DSPy supports describing a compound AI program and optimizing it against a metric. This is a useful alternative to manual trial and error, but the team remains responsible for metric quality and preventing leakage. 12

A skill needs two checks: does the agent select the method correctly, and does using it improve the outcome? “Loaded five skills” answers neither. A useful trace records the method, the specific decision it changed, and a link to the result. For comparison, disable the new skill on comparable tasks and check for losses in quality, time, or reliability.

SkillsBench and research on repository-level instructions provide reasons to measure effects rather than assume every additional instruction is useful. Their findings are limited to the study design and model configurations. The Agent Skills format simplifies packaging, but it does not equalize support across hosts or grant runtime authority. 35 36 7

Methods are worth making portable when they have several real uses, a clear contract, and a way to verify them. Customer names, specific permissions, local APIs, and unresolved decisions remain domain-specific. Removing an obsolete skill or consolidating duplicate instructions is necessary maintenance, not a loss of accumulated experience.

Memory can be managed by the application or by the agent through tools. In the first case, the application chooses what to retain and insert; in the second, the agent proposes records and queries. In both cases, data owners determine access scope, lifetime, and permissible status. An agent’s note that “this helped last time” does not become a verified instruction, and text from an external source must not become a permanent behavioral rule. Chapter 4 of Dibia’s book is useful as an examination of mechanisms, not as permission for memory to promote itself to truth. 45

Context reduction must preserve coherence: a tool call and its result form a pair; a consequential constraint remains connected to the decision; and a summary contains links to original artifacts. Overly aggressive compaction causes agents to reread files they have already inspected. Diagnosis should examine not only window size but also repeated retrieval of unchanged data, lost constraints, and the proportion of steps with no progress. A universal percentage of repeated reads is not a ready-made quality threshold: sometimes a source has genuinely changed and must be checked again.

A hierarchy of contexts reduces noise when specialists receive sufficient input and return results with supporting evidence. A concise assistant response must not conceal gaps, uncertainty, or prohibitions. Confidential material does not become safe because another model paraphrases it. The coordinator needs links, coverage, and result status, not necessarily every worker’s complete internal conversation.

Long-running work needs a compact coverage record outside the conversation being shortened: which objects have been checked, which were only partly read, where data is missing, and which revision was accepted. This is not a full transcript. Without it, compaction combined with “continue until finished” creates a loop: progress information is removed, the check demands completion, and the agent retrieves the same data again. The remedy is to restore state and limit repetitions that produce no new result, not to issue an even more insistent instruction.

For runtime design, distinguish request interception from task-boundary handling. Middleware intercepts an individual model or tool request or response for authorization, accounting, limits, or transformation. Lifecycle hooks can handle task boundaries such as start or attempted completion. Dibia discusses middleware in Section 4.9 and start/completion hooks in Section 4.12.5; permission-related pauses are treated separately in Section 4.13.1. A system may also need explicit pause handling, but that is an implementation requirement, not a third hook category attributed to the book. A guaranteed hook invocation does not guarantee compliance with the textual request it inserts. A checklist marked complete by the worker is useful for navigation, but completion is established by the corresponding artifacts. Add these mechanisms to address an observed problem, not as a package for every agent. 45

14. Locate the Error before Choosing an Improvement

A common reaction to a poor result is to add an instruction, a stronger model, or another reviewer. Yet the same visible symptom can have different causes. An incorrect answer about a contract may arise because the document was not extracted, an old document was retrieved, a negation was missed, the task was misunderstood, or the source document itself was wrong. One new skill cannot address all those mechanisms.

A useful diagnostic sequence starts with a reproducible case and the nearest reliable state. Did the component receive the correct input? Was the required information available? Which part of the contract did it violate? Was the action actually performed or merely described? Then choose the smallest intervention.

  • Missing fact: check the source, access, retrieval, or authoritative API rather than immediately fine-tuning the model.
  • Misunderstood instruction: clarify the contract, examples, and task boundaries; check for contradictory instructions.
  • Persistent behavioral error despite sufficient context: compare prompts, models, and, where data is available, model adaptation.
  • Incorrect action: repair the tool contract, validation, permissions, and reconciliation; an eloquent explanation of the error is not a safeguard.
  • Expensive but correct result: look for unnecessary steps, repeated reads, generation volume, tool waits, and human review.
  • Good technical result that nobody uses: examine the process definition, interface, and human need.

This diagnostic approach draws on the different intervention points examined in Huyen’s AI Engineering, particularly Chapters 5-10: instructions, context, the model, and the surrounding system. The workflow recommendation here is to choose according to the observed cause. Fine-tuning will not fix broken permission-aware search; a long context cannot create a missing document; another reviewer will not undo a duplicate write after a timeout. 39

One testable hypothesis is enough for an experiment: “Query rewriting confuses customer identities, so we will prohibit unsupported pronoun resolution.” Compare the affected cases and possible regressions. Do not change the model, tools, skills, and acceptance criteria simultaneously if the aim is to establish the contribution of one change. A coordinated update is legitimate as a package, but its overall effect cannot be attributed to one component without an appropriate comparison. Removing an unnecessary step is as much an improvement as adding a safeguard.

Coordination needs separate examination in a multi-agent system. A worker may have processed its input correctly but received an outdated version, missed a consequential constraint, or repeated work already done by someone else. Giving it a more detailed prompt will not help in those cases. Diagnosis must distinguish task-definition errors, local execution errors, handoff errors, and integration errors. A shared message history does not rule out incompatible assumptions.

15. Selecting Models and Managing Access to Them

Choosing an Operational Configuration

Compare a model in its operational configuration: with the prompt, retrieval, tools, decoding, and checks. A public leaderboard helps narrow the list; it does not make the company’s decision. Multiple-choice tests, solution generation, tool use, and maintaining multi-turn context assess different abilities. Averaging several correlated benchmarks may count the same advantage repeatedly.

First eliminate incompatible options: an unacceptable data transfer path, missing modality or feature, excessive latency, or usage restrictions. Then test a bounded shortlist on company tasks. Among suitable options, choose a balance of quality, cost, and speed. A high average score cannot compensate for violating a mandatory constraint.

Evaluation needs domain-relevant slices: language, length, complexity, multiple turns, source-document quality, tools, and behavior under uncertainty. Good results on English examples do not validate Ukrainian-language customer support or mixed-language technical correspondence. Translation through an intermediate language can also change meaning and add cost.

Hugging Face is useful as a hub for models, datasets, and educational materials. Model cards describe purpose, limitations, training, and licensing, but they are not independent guarantees. Available weights, open source code, permitted data use, and authorized commercial use are different properties; the specific version and its terms must be checked. 8 11

Compare APIs and self-hosting by total cost of ownership: utilization, peaks, redundancy, engineering support, observability, updates, and the ability to exit the dependency. In-house inference does not become free because there is no per-token tariff. A ready-made platform may be more rational than owned infrastructure if its data and execution boundaries fit the process. Chapter 4 of AI Engineering is valuable for its multidimensional build-versus-buy framing, not for predicting which type of provider will win. 39

Routing between models also needs verification. A weaker model may handle routine cases and a stronger one difficult cases, but complexity itself must be observable. A fallback must preserve data policy, context, and permitted actions. Confidential material cannot be sent to another provider merely because the primary provider is unavailable.

Revisit a decision when there is a signal: a change in load, a consequential price change, quality, or a dependency. There is no need to rebuild the entire process for every release. An improved base model may make an internal workaround unnecessary; the ability to remove it is an architectural strength.

A model router and a model gateway solve different problems. Huyen distinguishes them in Chapter 10, “Step 3. Add Model Router and Gateway.” A router selects a model for a particular request based on required capabilities, quality, latency, and constraints. A gateway provides a governed path to providers: access, quotas, accounting, and interface normalization. A router can be a simple application rule; a gateway can be an existing service. Having several models does not imply a need to build a platform. 39

A common interface must not conceal differences in context windows, tool calling, refusal formats, data processing locations, or authorized fallbacks. Permission to access a model is not permission to perform a business action through its tool. If a backup provider is incompatible with the data boundary, the correct outcome is refusal or an authorized limited continuation, not automatic forwarding of the request.

Why Model Behavior Needs Verification

A foundation model transfers capabilities acquired from a large training corpus to many tasks. Pretraining develops a basic ability to predict and represent patterns; post-training adapts behavior to instructions and preferences. Neither implies knowledge of the company’s current state or guaranteed truth in every response. A model can plausibly continue text that does not match the facts of the process.

Key properties for an application engineer include tokenization, limited context, decoding, generation variability, tool use, and modalities. Tokens are not words; the same document in different languages can occupy different amounts of context. Window size does not guarantee that every piece of information will be used equally well. In a multimodal system, errors can begin with recognition of a table, speech, or an image.

Sampling changes the choice of continuation but does not create factual support. Lower temperature does not make an answer true. Temperature zero and a fixed seed are also not universal guarantees of bitwise reproducibility across the serving path. vLLM documentation, for example, explicitly qualifies reproducibility settings and their dependence on hardware and version. 40

Token probability, confidence expressed in language, and the probability that a business decision is correct are different quantities. If a system must decide when to hand work to a person, the threshold needs calibration against observed errors. “I am 95% confident” without that validation is not a basis for authorizing action.

Chapter 2 of AI Engineering is useful as an explanation of these mechanisms, not as a catalog of current models. The implication for an engineering team is that application quality is jointly determined by the model, context, tools, data, configuration, and checks. Changing any part can change behavior while leaving the interface unchanged. 39

16. Verifying Outcomes at Multiple Levels

A useful evaluation set combines inexpensive deterministic checks, targeted negative cases, domain-expert human sampling, and model judges where they add signal. Failure examples include different customers with identical names; the right document with the wrong link; a missing fact; expired authorization; a partial write; a duplicate webhook; and a well-written answer that violates the goal.

Verification should cover several levels: component capability, end-to-end task execution, and business impact. A schema confirms form; an authorized reference confirms the object’s association; reconciliation after a repeated request confirms the absence of a duplicate; and a specialist’s judgment confirms domain sufficiency. One green number cannot replace the other levels.

Chapter 3 of AI Engineering explains the limitations of familiar metrics. Exact match can reject an acceptable formulation; searching for an expected string can miss false additions; semantic similarity does not establish truth; and an incomplete reference can penalize a correct answer. Each scorer should state what it establishes, what it does not, and how an incorrect reference can be corrected. 39

Perplexity characterizes text predictability under particular data and tokenization, not the quality of a business decision. pass@k indicates that a passing candidate exists among several attempts, not that the system can select it without a correct evaluator. Solving a task once in ten runs is different from reliably solving it in one pass. Comparisons must report the number of attempts, the selection criterion, and their total cost.

Repeatability and robustness are also distinct. The former is tested by repeating identical input; the latter by meaning-preserving changes to number formatting, the order of equivalent conditions, language, or phrasing. Open-ended text need not be byte-identical; what matters is preserving the correct decision and constraints.

For an agent, the primary object of verification is the observable state of the environment, not its account of what it did. Demystifying Evals for AI Agents distinguishes tasks, attempts, graders, traces, and outcomes. Checking a plan or completion message does not prove that a file was saved, a migration was applied, or the customer received the correct result. 20

Section 10.3.3 of Dibia’s book examines what is extracted from the trajectory for evaluation. Its example shows why the final assistant message need not contain the substantive result already obtained through a tool. For an operational workflow, this raises a further question: did the recipient actually receive the right result? The extraction strategy and its version therefore belong to the measurement system alongside the judge. The correctness of the result obtained and the fitness of the artifact actually delivered are checked separately. Finding the correct answer somewhere in the history is not enough. 45

A trajectory can reveal whether the path was authorized: which sources were used, which actions were invoked, how many retries occurred, and why a different worker took over. But not every departure from a reference sequence is an error: an agent may find a shorter legitimate path. Check consequential dependencies and prohibitions, not mandatory similarity between conversations. Analytical replay of stored events must not silently repeat real external actions.

Sequential errors require sequential tests. Hypothesis provides stateful testing: generating sequences of operations and checking invariants after individual steps. This helps find failures after repetitions and state changes, but it does not replace deliberately chosen domain-specific scenarios. 38

An evaluation should enable a decision: release a limited scenario, fix a specific defect, gather missing data, or retain the current version. A metric that never changes a decision probably does not justify the ongoing cost of collecting it.

17. Verifying the Evaluator

An LLM-as-judge is a measurement system with its own model, prompt, rubric, examples, and generation parameters. Changing these changes the scale. A rise in the application’s score may result from a more lenient judge. Two libraries using the name faithfulness do not necessarily measure the same thing.

What is needed is calibration, not faith in “a strong model for review.” Domain specialists label a set of acceptable and defective results, examine disagreements, and refine the criteria. Then check which errors the judge misses and which correct results it rejects. A repeatable judge can be consistently wrong, and agreement between two models can reflect a shared misconception. Chapters 3 and 4 of AI Engineering examine these limitations in detail. 39

Useful counterexamples target known biases: a long incorrect answer versus a short correct one; swapping A/B order; polished text containing an unsupported claim; the model’s own answer versus another’s; insufficient information; and instructions inside the document being assessed that attempt to change the criteria. Review material remains data, not a source of new rules for the judge.

Preference and correctness are measured separately. One of two bad answers will still win a pairwise comparison. First check mandatory constraints and sufficiency, then compare style or convenience among acceptable options. A user seeking expertise they lack cannot always recognize the correct answer; “I cannot assess this” is a legitimate outcome.

Store the judge’s minimum identity alongside the evaluation run: version, rubric, examples, parameters, and calibration date. When changing the measurement system, evaluate a shared bridging set under the old and new configurations. If the scale changes, the historical series cannot continue as though the product itself improved.

A metric’s name does not guarantee its meaning. String matching can credit the correct number beside a false conclusion. High correlation between source and displayed values does not rule out a constant offset or an incorrect chart scale. Test coverage does not establish whether a test catches a dangerous defect. First define the prohibited error and test the scorer with a counterexample; consider ease of computation afterward. If a required assessment is missing, renormalizing the remaining scores must not conceal the gap.

A separate reviewer who did not author the work matters for consequential acceptance, but the mere presence of a second agent is insufficient evidence of independent judgment. The reviewer needs the original contract, the artifact, and primary evidence. A coauthor is useful for collaborative construction and repair but no longer qualifies as a nonauthor of the result. The author’s self-check remains required preparation, not a substitute for acceptance.

The cost of evaluation must itself be evaluated. An inexpensive check of all work plus an expensive expert sample can sometimes be appropriate. Asynchronous review reduces the user’s wait but does not prevent an action that has already occurred. The greater the cost of an irreversible error, the more important pre-effect verification and the ability to decline safely become.

18. Comparing Versions without Self-Deception

Two average percentages are not enough to conclude that a new system is better. A unit of observation, target population, practically meaningful effect, and decision rule are needed. A case, conversation, customer, and individual model call are different statistical units. Ten repetitions for one customer are not equivalent to ten independent customers.

A quick check on whether complexity is necessary: compare comparable tasks without the new skill; without the second agent but with the same available tools; with conventional search instead of more complex retrieval; or with a cheaper model among those that satisfy quality and permission requirements. Account for checks lost, human time, and all attempts. This is a menu of experiments for an observed problem, not four mandatory tests for every change.

Compare versions on the same tasks and permissible starting states where possible. Assess generation variability and sampling uncertainty separately. Related documents, customers, and time periods require appropriate grouping. Slices by language, risk, length, and complexity protect against an apparent overall gain caused only by an easier mix of work.

Suppose, in a hypothetical teaching example, two versions process the same 200 cases. The old version passes 160 and the new one 168. The new version fixes 14 previous failures but breaks 6 previous successes: a net gain of 8, or 4 percentage points. These numbers alone do not justify a rollout. The six regressions may cost more than the fourteen fixes, and the difference may not hold on another sample.

The next analysis examines the types of fixes and regressions, cost, human time, and an uncertainty interval for the paired difference. Bootstrapping resamples with replacement and helps assess how the conclusion depends on a finite set of observations. SciPy provides a ready-made mechanism for simple paired data; grouped or temporal dependencies require a separately chosen resampling design. 44

Bootstrapping does not create missing rare failures or correct a biased corpus. Zero dangerous errors in a small set does not mean zero risk. Stress tests provide evidence about specific failure mechanisms; a representative sample assesses normal traffic. Neither substitutes for the other.

Data used to tune prompts, skills, and judges must be separate from held-out evaluation. Repeatedly inspecting a holdout and making corrections turns it into a development set. MLflow helps organize datasets, scorers, and prompt-version comparisons, but a sound experiment is defined before the tool is run. 22

Sample size depends on event frequency, required precision, and the cost of the decision. There is no universal rule that “a hundred examples are enough.” An honest outcome of a bounded experiment may be “a practically meaningful gain has not been established.” This does not require expanding the dataset indefinitely: retain the baseline and identify the evidence that would justify revisiting the question.

Finally, an observational before-and-after comparison is not a causal effect. Users, tasks, and habits change in production. A controlled comparison, where feasible and safe, is stronger than a general impression. METR illustrates why findings from one experiment involving developers cannot be turned into a universal speedup percentage; a later update also discusses changes in the measurement conditions themselves. 33 34

How to read a convincing demonstration critically. In Sections 10.6.1-10.6.5, Dibia compares a direct model call, a single agent with tools, and teams on a small educational dataset. Importantly, Section 10.6.2 includes a single agent with the team’s execution tools, and Section 10.6.5 discusses the effect of search access. These controls help distinguish tool access from coordination benefits. The broader lesson is to compare teams with a capable single agent using comparable tools, inputs, and resource accounting; beating a model without search is not sufficient evidence for multiple agents. Section 10.6.3 also describes adjusting the judge after unexpected scores. Correcting a measurement system may be justified, but it requires a new version and separate validation; a more pleasing score does not, by itself, mean the product improved. The experiment is useful for learning how to compare designs, not a universal demonstration of team superiority. 45

19. Providing Security beyond the System Prompt

A model may tend to follow an instruction, but only the runtime determines which data and actions are available. External pages, emails, documents, and tool outputs are data even when they contain commands. Prompt injection is dangerous precisely because it confuses a source of information with a source of authority.

Protection consists of several independent boundaries: least privilege, tenant isolation, constrained tools, permitted network destinations, validated parameters, and actions through the existing responsible component. Unnecessary secrets must not enter context. A sandbox reduces the consequences of error only within the limits of its actual network, file, and credential configuration.

OWASP provides a threat catalog for agentic applications, while Kubernetes Agent Sandbox provides a mechanism for managing sandbox workloads. Neither a catalog nor the name sandbox certifies the security of a particular solution. Low-level isolation depends on the runtime and configuration. 18 19

Measure not only successful attacks but also erroneous refusals of legitimate requests. A system that refuses legitimate work may look successful on a narrow attack-prevention metric while failing its business task; this does not establish its overall security. Content safety, data access, and authority to act have different checks; they cannot be collapsed into a single “security” score.

Reversible masking replaces sensitive values and retains a reverse mapping. It is not complete anonymization: context may reveal identity, and the recovery map is itself sensitive. Restoring original values in a response is permissible only within the correct access context, not as an automatic final pipeline step.

Streaming introduces a separate tradeoff. Once text has been shown to the user, a later validator cannot undo the disclosure. Critical fragments may need checking before display. Deleting a message after detecting an error is not equivalent to preventing a leak. Chapter 10 of AI Engineering helps expose this tension between latency and control instead of treating streaming as a cost-free interface improvement. 39

The Rule of Two is a useful heuristic that identifies the combination of three capabilities: untrusted input, access to sensitive data, and state changes or external communication. In Meta’s formulation, an autonomous system may combine no more than two; all three require human involvement or another reliable verification mechanism. This is a way to notice a dangerous combination, not proof that any two capabilities are safe. 47

Meta’s hypothetical email assistant illustrates the risk of allowing an external message to determine where private information is sent. Applying that lesson to delegated work, role separation helps only when the transition is genuinely filtered and authorized. If a second agent receives the compromised context and all the first agent’s permissions, a new role creates no security boundary. Switching modes does not clear instructions already read either; it requires controlled data transfer and a fresh action check.

Middleware order matters. A privacy filter after a logger cannot remove a secret already recorded; a result check after a network send cannot prevent a leak. Two retry layers can multiply attempts, while a rate limiter that waits does not constrain the goal’s total budget. For a consequential path, define the order of pre-effect checks, a single owner of retries, cancellable waits, resource cleanup, and each layer’s failure behavior. A regex filter may catch known examples, but it does not replace these constraints.

20. Turning Feedback into Verifiable Improvement

Huyen’s Chapter 10, particularly “Extracting Conversational Feedback” and “Feedback Limitations,” examines why feedback is ambiguous and how optimizing for it can change behavior in undesirable ways. Applying that caution to business workflows, clicks, acceptance, regeneration, and abandonment admit multiple explanations. No complaint does not prove correctness, and a complaint does not always indicate a technical defect. 39

A user may accept text because time is short, rewrite it because their intent changed, repeat a request for a different style, or end a conversation after a successful resolution. These events are useful signals for testing hypotheses, not automatic labels. Preserve enough context, within authorized data boundaries, to distinguish correcting an error from changing the task.

A preference pair also needs a meaningful basis: why is one answer better, who judged it, and does it address the same original intent? Back-translation checks translation consistency, not factual truth. A synthetic “ideal answer” and a test produced by the same model may share the same error. Training on them without verification propagates an assumption.

The denominator is just as important. Only displayed results receive feedback. Failed, excessively costly, abandoned, and unfinished tasks may be missing from the sample, creating an illusion of improving quality. If the system increasingly selects easy cases, its average score can improve without any change in its ability to handle the original workload.

The feedback interface itself shapes the data. Option order, text length, button placement, and ambiguous scales change responses. People must not be forced to judge factual reliability outside their expertise. An uncertainty option and the ability to make a substantive correction are often more useful than mandatory star ratings after every operation.

The practical path from experience to improvement is to select informative cases, establish what happened, confirm the outcome, identify the error type, change the data, prompt, tool, or model, and check an independent set. Updating weights is not a mandatory endpoint. Improving retrieval, examples, the interface, or an existing contract is often sufficient.

Optimizing for pleasant responses is a separate risk. A system may learn to agree with users more often and receive better ratings while losing factual correctness. Human preference, technical success, and business outcomes must therefore remain distinct measures.

A “lesson for memory” also needs validation: observation, proposed cause, confirmation, and a limited scope of applicability. An agent’s confident explanation of an error does not establish causality. If an unverified diagnosis is stored as a permanent rule, the next agent will reproduce it as accumulated experience. Correcting memory and removing refuted lessons are as important as adding new ones.

Constructed example: from a reported anomaly to a regression check. Consider a hypothetical monitoring service that prepares a temperature summary for one greenhouse. Two sensors in different greenhouses share the display label “Entrance,” but have different stable IDs. An operator says the summary contains a reading from the other site. That report is a signal, not proof of either the mismatch or its cause. The engineer compares the authorized input, sensor IDs, tool results, and delivered summary to establish where the association was lost.

Build a synthetic fixture with both sensor IDs and the shared label. A label-only request must not produce an unsupported match; a request containing the correct authorized ID must succeed. Preserve the fixture’s synthetic origin, the contract version, and the basis for the expected outcome. A real case used for the same purpose would additionally need appropriate usage rights and protection against re-identification; removing names alone would not establish either.

If investigation confirms identity selection as the cause, repair that selection and run both the negative and valid cases, followed by the necessary regression checks. Until then, retain an investigative hypothesis rather than a permanent memory rule. An evaluation example does not automatically become training data. The purpose is a reproducible check of a confirmed failure mechanism, not a new report for every message.

A simulated user is not customer evidence. Distinguish a real human report, a product event, an agent’s executed interface test, a synthetic scenario, and an analyst’s hypothesis. Preserve that distinction when summarizing, storing, or handing off the evidence. A simulation can suggest a research question; it cannot become a confirmed customer request merely through repetition. Even an authentic request from one customer does not establish prevalence or priority.

Protect the meaning of the metric. Define the desired customer outcome, event origin, measurement unit, period, denominator, and exclusions before optimizing. Count human, automated, and test activity separately when the distinction matters. Ask how the measure could improve without the intended benefit, and test that counterexample. An automatically created CRM record is not by itself a qualified lead. Changing the metric’s definition requires an explicit owner decision, not a quiet change bundled with a feature.

Constructed example: a test is not a learner. Imagine an online course service whose agent runs 40 automated playback checks after a player update. A dashboard counts every playback reaching the end as a completed lesson. The agent then reports higher learner engagement and recommends investing in more courses. The checks may genuinely demonstrate that playback works under the tested conditions, but no learner participated in those 40 runs. A technical event has crossed into a customer metric and then into an investment argument without evidence for either transition.

Keep those runs in the technical test results, not in learner-engagement totals. An authorized real learner completion can count under the declared measurement rule; replaying its event must not count as another learner outcome. Even that completion alone does not establish learning or demand for another course. Test both sides: synthetic playback must not increase the customer metric, and a qualifying real completion must still count once. Before changing the product roadmap, investigate the actual learner need. This is a hypothetical teaching example, not a reported deployment or an estimate of business benefit.

21. Releasing and Observing the Whole System

An AI process release is a coordinated configuration: code, model or available version ID, prompt, skills, tools, permissions, retrieval/index, and evaluation. In-house training adds the dataset, tokenizer, chat template, adapter, and numerical precision. API compatibility does not guarantee identical behavior; a provider changing a model without strict version pinning is a separate dependency.

Shadow mode allows proposals to be compared without business mutations, but it may still transmit data and spend money. A canary limits live exposure but requires stop criteria. Rolling back a version does not undo emails already sent or records already written. These properties must be understood before production, not discovered after an incident.

Observability connects the goal, input versions, chosen route, consequential actions, checks, and outcome. A compact operator-facing record should be separate from detailed technical traces with restricted access and retention. “Log everything” must not be applied literally to confidential data, secrets, or a model’s internal reasoning.

OpenTelemetry develops GenAI semantic conventions, while OpenLineage connects jobs, runs, and datasets. These are useful infrastructure agreements, but they do not establish content quality or business authority. Pin schema and instrumentation versions, and explicitly choose how much sensitive content to include. 28 29

For a long sequence of tasks, a link to the parent decision is useful: which question is being continued, what changed, and which next step is now justified. Historical records should not be rewritten with invented precision. A one-off operation does not need a separate goal hierarchy when its meaning is already clear.

Monitoring must distinguish availability, result quality, and changes in the work mix. Higher latency may reflect longer inputs; shorter responses may reflect users learning to ask more precise questions. Drift is a signal to investigate, not automatic proof that the model has deteriorated. An alert threshold should lead to action by an owner.

An incident requires reconstructing what actually happened: the input, configuration, available data, tool results, and observed state. An agent’s polished explanation after the event is not primary evidence. The response should add a specific regression case or change a constraint, not introduce a universal instruction to “be more careful.”

Instrumentation must also be checked under failure: was the span closed correctly on exception and cancellation, was its parent relationship preserved, was streaming usage counted twice, and did child work disappear from the record? Metadata may contain a customer’s name or a sensitive identifier. Connecting an exporter does not turn a diagnostic trace into an immutable audit record; consequential action accounting requires an appropriate storage contract.

22. Using the Interface as an Execution Environment

Browser or desktop interaction extends automation where no suitable API exists or the outcome genuinely depends on a visual interface. But UI interaction must not bypass an existing safe API or access controls. A domain tool usually expresses the object, action, and error more precisely. Chapter 5 of Dibia’s book is useful as a distinct architectural examination of computer use, not as a recommendation to replace other integrations with it. 45

The basic protocol is observation -> action selection -> action -> confirmation of environmental change. A page may change between observation and click: a different customer, a new amount, a pop-up, or a session reload. Before a consequential action, check the current object, profile, and authority. A long, precomputed click sequence is acceptable only with sufficient guarantees of stability; dependent mutations need intermediate confirmations.

The DOM, accessibility tree, and screenshot represent different parts of the environment. A filter that retains only clickable elements may remove an amount, warning, or recipient name. An image without current viewport geometry makes coordinates ambiguous. A hybrid is useful when its representations belong to a consistent observation, not different page states. An observation ID, timestamp, and session identity help connect a decision to what was seen. Neither page text nor recognized lettering becomes a higher-trust instruction.

Representation choices affect privacy: a screenshot may capture other tabs or adjacent data, while the DOM can contain information not visible on screen. Give the agent an isolated session and sufficient but bounded context. Credentials must not be extracted into the model for convenience. Viewing an authorized interface does not imply permission to export its contents to another service.

Observation failure requires an explicit state. If a screenshot is unavailable, an authorized text-only mode may be sufficient to read a table but not to perform a visual check. The system must not silently end the stream and present that as success, or continue a mutation without required evidence. A confirmation failure after an action also differs from a failure before it.

Count the actual unit of risk. Five model iterations may contain twenty UI calls. Limits on actions, external sends, time, and cost should be checked separately as needed. Waiting for a button to become ready establishes that it can be clicked, not that the business operation succeeded. A closed dialog does not prove payment or sending. After an unknown outcome, reconcile the record with the system responsible for the operation; another click may create a duplicate.

In a hypothetical example, an agent transfers approved supplier data into a portal. It checks the organization and selected profile, matches fields to the authorized source, presents consequential changes, saves within the established boundary, and reads the confirmation. If the connection fails after Save, it first looks for the created record using a stable identifier. A new vendor, changed bank details, or an ownership mismatch sends the work to a person rather than triggering another confident automatic click. This illustrates a contract, not a ready-made payment policy.

Checks for this worker include state changes between observation and action, the wrong session, a hidden warning, loss of screenshots, a timeout after saving, and cancellation with an open browser. Cleanup must release resources and terminate child actions without destroying evidence of an operation already performed. Visual verification is necessary, but screen evidence does not replace authoritative state where that state is available.

Further Depth. Model Adaptation and Performance

These sections are relevant when diagnosis has already identified the corresponding limitation. They are not a mandatory program for every process. First establish that a simpler solution is insufficient and define the measurement that will assess the effect.

23. Fine-Tuning a Model When Justified

Fine-tuning creates a model version that must be maintained, not merely a better prompt. Continued pretraining, supervised fine-tuning, and preference training use different data and objectives. The first continues training on sequences, the second supplies examples of desired behavior, and the third expresses comparative preferences. None automatically establishes factual truth or authority.

Consider fine-tuning for a recurring behavioral error despite sufficient input: consistent formatting, domain-specific style, a specialized task, or expensive repeated context. Changing corporate facts are usually easier to maintain through retrieval or an API. This is a diagnostic heuristic, not a prohibition on teaching domain knowledge. RAG and fine-tuning are compatible, but the combination is not guaranteed to outperform the original model with good retrieval. 39

Before an experiment, establish a compact contract: which error class is being addressed; which baseline already works; why a simpler change is insufficient; where the data comes from; which regressions are unacceptable; who maintains the model; and how to return to the previous configuration. Without sound evaluation, it is impossible to know whether training helped. Low training loss does not establish usefulness in the workflow.

Parameter-efficient fine-tuning reduces the number of trainable parameters. LoRA adds a trainable low-rank adjustment to frozen weights. Rank and target layers are experimental parameters, not universal constants. Adapters are useful for specializations of a shared base, but they require correct serving; a separate adapter does not create tenant isolation. 41

QLoRA combines low-bit storage of base weights with adapter training. It is primarily a way to reduce memory requirements; memory savings do not imply proportional speedups. Activations, training-parameter states, and computation remain in addition to the weights. Compatibility depends on the model, library, hardware, and format. 42

Evaluation must cover not only the target scenario but also neighboring capabilities. A model that produces better order responses may become worse at preserving constraints or working in another language. Account for training data, tokenizer, chat template, adapter, numerical precision, and serving parameters. Previous success does not automatically transfer to a new base model.

Distillation can make a narrow task cheaper, but the student may acquire the teacher’s persuasive style without its ability to solve the task. Model merging combines parameters, an ensemble combines call results, and an agent team interacts during execution. These are different techniques. None should be chosen simply because it allows the system to be called “multi-agent” or “specialized.”

24. Accelerating the System without Losing Correctness

A system contains different sources of delay: queuing, context preparation, retrieval, the model, tools, review, and waiting for a person. Model TTFT, time to first token, is not the time to the agent’s first useful result. Several calls may happen behind the scenes before the user sees a usable answer.

Prefill processes input; decoding generates output sequentially. Input and output tokens therefore have different cost profiles. Compute capacity, memory capacity, and data-transfer bandwidth all matter. A model can fit in memory and still run slowly. Long contexts and concurrent requests increase the KV cache; estimating memory from weights alone is insufficient.

Chapter 9 of AI Engineering is particularly useful for its distinction between throughput and goodput. Throughput counts processed volume; infrastructure goodput counts requests that meet a selected SLO. The business needs a stricter measure still: acceptable outcomes delivered on time. This is our application-level extension, not a synonym for every form of technical goodput. 39

Useful measures include end-to-end p95/p99 by work type, time to first useful result, completion cost, concurrency, queuing, and cold/warm behavior. Average latency hides the long tail. Tokens per second across different tokenizers are also not a direct comparison of how quickly the same task is completed.

Choose an optimization based on the bottleneck. Less output helps when decoding is long. Batching improves efficiency across the workload but may add waiting time. Continuous batching reuses slots freed by completed sequences. Speculative decoding depends on draft quality and verification cost. Quantization reduces memory, but its effect on speed and quality must be measured in the target configuration.

vLLM and llama.cpp are useful directions for studying serving and local inference. Do not adopt both simply to complete the stack: the choice depends on the model, hardware, request profile, and operational responsibility. A short batch process and a voice conversation have different requirements. 9 10

Before optimizing GPUs, check whether document access or human review constrains the overall process. Reducing model latency from a hypothetical ten seconds to five does not shorten a two-day approval queue. Hardware utilization is a diagnostic measure, not the company’s ultimate goal.

Caches and Trust Boundaries

A KV cache reuses intermediate attention computations. A prefix cache reuses computations for a matching prefix. An exact answer cache stores a completed result. A semantic answer cache looks for a similar query. These are different mechanisms with different risks; none is verified business memory.

For a cached answer, identical query text does not mean identical conditions. Two employees may have different permissions, contracts, or accessible document versions. A price, policy, or permission change can make the old answer unusable. Cache keys and invalidation must account for identities, versions, and access scope that materially affect the result.

A semantic cache is particularly sensitive to similar wording involving different dates, amounts, or objects. High similarity does not establish equivalent decisions. Evaluate such a cache in a separate quality experiment and restrict it to scenarios where errors are acceptable and detectable. It must not bypass access or currency checks.

Prefix caching saves computation; it does not establish the user’s right to the source data. vLLM documentation describes a salt for separating cache reuse between trust groups. This is an example of a specific technical mechanism, not a substitute for the full tenant-isolation model and correct caller configuration. 43

Measure hit rate, latency and cost gains, invalidations, and stale-response errors. Keeping a cache merely for a high hit rate is pointless if it returns outdated decisions. For operations with external effects, a stored response also does not establish that a new action was performed: state from the system responsible for the operation is required.

Bringing the Two Perspectives Together in Practice

Architecture becomes meaningful when one process can be traced from organizational need to engineering evidence. The following examples do not define an industry product or a ready-made policy. They show how outcomes, authority, data, checks, and learning form a connected sequence.

25. A Query about an Incorrect Invoice

Consider a hypothetical B2B process: a customer reports an incorrect invoice amount. This example brings together communication, data, operational actions, and development. It does not propose delegating financial decisions to a model without an existing policy.

Input and goal. The system receives the query and customer identity through an authorized channel. The outcome is an explained and resolved discrepancy or a domain-specific escalation, not merely a polite response. Permitted actions are recorded: reading related documents, calculating the discrepancy, and preparing a proposal. Changing the invoice and sending externally have their own rules.

Data and context. The invoice, order, and current version of the terms come from authoritative systems. OCR extracts the attached document, but numbers are checked with the responsible source. Retrieval explains an unusual condition; it does not calculate the current balance. If a document belongs to another customer, the system does not send it to the model, even if it is semantically similar.

Decision and action. Code calculates the difference and checks the rules; the model explains the findings and identifies unknown conditions. A routine case follows the existing workflow. An unusual case receives a bounded investigation. A proposal to correct an invoice does not become a change until the required authorization is in place. A timeout after an accepted operation triggers readback using a stable identity, not a blind repeat write.

Verification. A schema confirms extraction form. Tests check amounts, currency, and object relationships. Negative cases include identical numbers for different customers, an outdated contract, a repeated request, and missing evidence. A reviewer checks the sufficiency of the explanation and compliance with the boundary; a person decides on the exception. No aggregate score replaces these different forms of evidence.

Measurement. The business tracks time to resolution, repeat contacts, manual minutes, and errors after completion. The technical team sees retrieval misses, incorrect tool arguments, the review queue, and the cost of all attempts. Positive feedback on a polite response does not count as resolving the discrepancy until the state is reconciled.

Improvement. If the main error is currency recognition, fix extraction. If an amendment is regularly missed, change retrieval. If correct data is explained unclearly, examine examples and the prompt. If the routine style is stable and volume is high, model adaptation may become economically justified. If approval of exceptions is the source of delay, faster inference will not solve the problem.

The same architectural discipline transfers to other processes. In sales, sources support claims in a proposal but do not authorize a price. In procurement, evidence helps a person choose but does not sign a contract. In data engineering, a model locates an anomaly while a verifiable pipeline applies the correction. In DevOps, an agent investigates an incident while a change follows the existing deployment and rollback path. In development, the next consumer receives a verified artifact, not the author’s promise.

26. Business Decisions from Unstructured Data

Another substantial area of agent-centric business needs no external mutation at all: understanding which product or process change is justified by accumulated customer contacts. Dibia’s Sections 14.2-14.5 provide an example of analyzing unstructured business material. For the hypothetical customer-contact workflow below, adapt that approach as corpus -> inexpensive filtering -> model classification -> aggregates. This is a schematic adaptation, not a quotation or a reproduction of the book’s case study. Neither multiple agents nor open-ended planning is mandatory; a reliable pipeline with one probabilistic stage may be sufficient. The following controls are recommendations for this workflow, not findings about the author’s original dataset. 45

Decision and unit of analysis. A team wants to choose one onboarding improvement based on a quarter’s customer contacts. Before classification, define what constitutes a customer case, how duplicates are combined, the period, available channels, and permission to use the data. Categories should serve the decision: missing capability, confusing interface, data error, external constraint, and insufficient information. Message count is not customer count or pain intensity; one active customer may account for much of the correspondence.

Corpus and selection. Authorized systems provide a versioned dataset with identity and provenance. Inexpensive rules remove clearly irrelevant material while retaining reasons for exclusion. Domain-specific samples are taken from both selected and discarded records. Otherwise, even a good classifier will never see a problem excluded upstream. Assess the first filter’s recall separately from the downstream model’s accuracy; reviewing only the final table cannot reveal a keyword miss.

Classification. The model returns a permitted category or unknown, a reference to a supporting passage, and a brief rationale. Check that the passage exists and may be used. A schema protects form; it does not prove the category is correct. A category list in a string field’s description is not an enum constraint. A mandatory boolean for weak source text encourages false certainty. The absence of the word “error” does not mean there is no defect, and a customer’s statement is not an established cause.

Verification and aggregation. Engineers and the domain owner agree on examples at category boundaries; tuning uses a separate set from final evaluation. Code counts unique cases and customers, segment distributions, unknowns, and omissions. A model may explain the table but must not silently recalculate the denominator. Show different dimensions where useful: frequency, severity, recurrence, and availability of an alternative. A single overall ranking conceals the product owner’s value judgment.

Recovery. Caches and checkpoints are tied to the source, filter, schema, prompt, and model versions. Changing the classifier must not mix old and new labels into one result. API errors, incomplete documents, and access denials remain separate statuses rather than disappearing from the denominator. Retries count toward cost; an empty result does not prove that no problems exist.

Findings and decision. The artifact contains a verifiable table, a coverage description, consequential examples, and options for the next action. It may establish that a particular difficulty occurs frequently in the available corpus. It does not establish prevalence across all customers, causation of churn, or the return on development investment. The product owner chooses an action using other information as well and checks the outcome after the change. Research can honestly end with “clarification is needed in a selected group” instead of turning into endless classification.

The same approach applies to supplier analysis, contract terms, incident reports, and customer discovery. In every case, a public description of a capability, the capability’s actual availability, and permission to use it remain distinct states. The value of automation is that the engineer gains a verifiable basis for a decision, not a more confident summary.

Value through triage. A useful read-only pilot can reduce the expert’s search burden without receiving permission to change source records. Measure review time, consequential misses, and the quality of the resulting decision, including samples of discarded cases. Confirmation of selected findings alone does not establish recall across the full dataset.

Separate three jobs: finding candidates, ordering their review, and deciding what they mean. Deterministic rules may already identify the candidate cases. An agent can then propose a review order with references and reasons, while the expert checks the source and makes the consequential judgement. The proposed value is better use of expert attention, not an assumption that the agent found cases the rules could not find.

Compare that proposal with reviewing the same candidate set in its existing order, using comparable reviewer time and the same outcome criteria. Include lower-ranked and excluded cases in the checks; a convincing top-ranked example can conceal an important miss. If ranking adds no useful benefit, retain the rules and ordinary review order. The pilot has answered a decision question even when the right conclusion is not to add an agent.

Conclusion. Transformation as a Sequence of Justified Changes

At the organizational level, the questions are: what work can now be delegated, who is accountable for the outcome, and has the entire process improved? At the engineering level: what design fulfills this contract reliably enough, and how can we establish that the next change improves it? These questions must be considered together.

A company’s reusable foundation includes identity and access, governed tools, configuration versions, context delivery, measurement, durable execution, and a decision interface. Object meaning, acceptable error, authority to act, and criteria for usefulness and acceptance remain domain-specific. A universal schema must not erase the differences between a contract, a customer case, and a deployment.

A shared component emerges when several real consumers require the same behavior. There is no need to build a platform for every conceivable agent in advance. First create a working end-to-end process using available tools, then extract stable contracts. If an existing service solves the task more cheaply within acceptable boundaries, buying and integrating it is more rational than building an orchestration framework.

For each new capability, ask a few questions: what work does it complete; why is probabilistic choice needed; which data and actions are authorized; how will errors be detected; how will it survive failure; what does an acceptable outcome cost; and what changes for the person? If answers are missing, the next step may be Discovery rather than new infrastructure.

For a personal workflow, the next step may be defining and checking one agent assignment more precisely. For a team, it may be repairing the handoff between a worker and a reviewer. For an organization, it may be redesigning a process whose automation is already constrained by decision queues or input-data quality. The scales differ, but the method is shared: choose an observed constraint, make a sufficient change, and check the result in real work.

The central principle: improve the system in response to an observed cause, not an architectural fashion. A good harness helps people and agents reach finite goals through verifiable outcomes and a manageable process. Engineering maturity means justified complexity and the ability to remove what no longer adds value.

Sources and Further Reading

This is a thematic guide for further study, not a list of mandatory dependencies. The books provide a systematic foundation; research helps formulate testable hypotheses; documentation describes the mechanisms and limitations of specific tools. Numerical findings apply within the boundaries of their study design. Implementation requires suitable versions and validation on organizational tasks; main/latest links may change.

Foundations and Architecture

39. Chip Huyen. AI Engineering: Building Applications with Foundation Models. O’Reilly, first edition, December 2024; copyright 2025. A foundation for models, evaluation, prompting, retrieval, adaptation, data, inference, architecture, and feedback. Chapter and section references identify the book, not its companion repository. Practical controls and workflow applications in this text are a separate synthesis.

45. Victor Dibia. Designing Multi-Agent Systems. Agent and workflow architecture, computer use, context engineering, evaluation, distributed protocols, and human control. References name relevant chapters and sections; educational examples are not validated production implementations. The companion code repository is a separate resource, not a license to reproduce the book.

46. Microsoft. Agent Framework overview. Existing agents, workflows, context, and middleware. Check the required language, version, lifecycle, and migration path; not a recommendation for a mandatory dependency.

47. Meta. Practical AI Agent Security. The Rule of Two as a heuristic for designing combinations of data and actions, not a universal security guarantee.

48. Research, 2025. Magentic-UI: Towards Human-in-the-loop Agentic Systems. Co-planning, co-tasking, and action guards. An architectural example of interaction, not evidence of an economic effect within a company.

49. WHATWG. Server-sent events. EventSource, event identifiers, and reconnection. Transport properties do not replace durable task state.

50. IETF. RFC 6455: The WebSocket Protocol. A bidirectional connection. Worker scaling and business-process durability are designed separately.

1. Anthropic, 2024. Building Effective Agents. Workflows versus dynamic action selection. Read as an architectural framework, not a mandatory implementation sequence.

2. Google. Rules of Machine Learning. Baselines, pipelines, metrics, and training-serving skew. Useful before choosing a complex solution.

32. DORA, 2025. State of AI-assisted Software Development. An organizational perspective on AI-assisted development. For numerical conclusions, study the full report and methodology, not just the overview.

Data, Retrieval, and Memory

3. Anthropic, 2025. Effective Context Engineering. Selecting sufficient context and handling long-running tasks.

4. Anthropic, 2024. Contextual Retrieval. Chunk context, embeddings, BM25, and reranking; compare on your own corpus.

5. pgvector. Vector similarity search. Exact and approximate search, indexes, and filtering. Particularly useful for examining completeness after filtering.

6. Context Hub. Versioned context for coding agents. Targeted delivery of documentation and annotations; check the trust assigned to added information.

21. scikit-learn. Common Pitfalls. Leakage, preprocessing, and consistent validation of an ML pipeline.

29. OpenLineage. Object Model. Jobs, runs, and datasets; lineage is supplemented by checks on content and permitted use.

31. MosaicML. Streaming. Further reading on large datasets and resuming data delivery. Not a guarantee of fully deterministic training.

37. Docling. Document processing. Preparing complex documents. Check tables and structure against the originals.

Models, Adaptation, and Performance

8. Hugging Face. Model Cards. Model purpose, limitations, training, and metadata. A starting point for due diligence, not a substitute for it.

11. Hugging Face. Agents Course. A learning path through agents, tools, and evaluation; useful for engineers seeking practical grounding.

9. vLLM. Documentation. Serving, batching, and memory management. Measure on the target workload.

10. llama.cpp. Local inference. Local execution and quantization across platforms. Check the specific model and hardware.

40. vLLM. Reproducibility. Reproducibility boundaries and dependence on configuration, version, and hardware.

41. Hugging Face PEFT. LoRA. Low-rank adjustments, parameters, and merging with a base model. Performance claims require your own verification.

42. Hugging Face PEFT. Quantization. Adapting a low-bit base, QLoRA, and implementation limitations. Not a universal estimate of memory requirements.

43. vLLM. Automatic Prefix Caching. KV reuse and separation of caches by trust group. Not a ready-made cache of business answers.

Skills, Prompts, and Development

7. Agent Skills. Specification. A format for packaging instructions and resources; check runtime support.

12. DSPy. Programming language models. Composing and optimizing AI programs. Start with a metric and a held-out test set.

35. Research, 2026, v4. SkillsBench. Testing the usefulness of skills across tasks and configurations. Not a suitability ranking for every business.

36. Research, 2026, v2. Evaluating AGENTS.md. Repository-level context and its effects. A useful counterweight to accumulating instructions without measuring their impact.

23. Research, 2026, v1. SlopCodeBench. Sequential software evolution, functional correctness, and structural quality.

24. HumanLayer. Advanced Context Engineering for Coding Agents. Code investigation, planning, and preserving human understanding. Engineering experience, not controlled evidence of acceleration.

Evaluation and Impact Measurement

20. Anthropic, 2026. Demystifying Evals for AI Agents. Tasks, attempts, graders, and outcomes; verify actual state, not just the response.

22. MLflow. Evaluating Prompts. Comparing alternatives with datasets and scorers. Tracking an experiment does not ensure representativeness.

30. Evidently. LLM Evaluation Guide. An additional guide to reference-based and reference-free evaluation, testing, and monitoring.

38. Hypothesis. Stateful Tests. Generating action sequences and checking state invariants.

44. SciPy. Bootstrap. Confidence intervals and paired samples. Choosing the unit of observation and resampling design remains a statistical decision.

33. METR, 2025. AI and Experienced Developers. A controlled study of particular developers and tasks. Not a universal assessment of AI productivity.

34. METR, 2026. Productivity Measurement Update. Changing conditions and the difficulties of measuring effects as practice evolves.

Execution, Interaction, and Security

13. Haystack. Pipelines. Typed composition, branching, and async execution; distinguish serialization, persistence, and cancellation.

14. LangGraph. Persistence. State and checkpoints; requires a suitable backend and operational configuration.

15. LangGraph. Interrupts. Pausing for a decision and the semantics of node re-execution.

16. Temporal. Idempotency and Durable Execution. Retries and external effects; check the guarantees of the system responsible for the external operation.

17. MCP, revision 2025-11-25. Security Best Practices. Authorization and threats at tool boundaries, including the confused deputy problem.

18. OWASP, 2026. Top 10 for Agentic Applications. An entry point to a threat catalog for threat modeling. Not a security certificate.

19. Kubernetes SIGs. Agent Sandbox. Managing sandbox workloads; actual isolation depends on the runtime and configuration.

25. A2A. Life of a Task. Tasks, messages, and artifacts. Business acceptance and lineage require an application contract.

26. AG-UI. Introduction. Event-based interaction between the user and agent backend; check implemented feature support.

27. LiveKit. Agents. Voice and real-time systems, where interaction quality encompasses more than model-generated text.

28. OpenTelemetry. GenAI Semantic Conventions. Evolving instrumentation conventions; pin versions and limit sensitive content.