Part D — Learning and distribution · Chapter 15 · final chapter

Agentic AI engineering: tools, memory and verification

~40 min read6 interactive widgets8 plates

In this chapter

  1. Why agentic AI now
  2. Agent: working definition and core properties
  3. Building blocks and AI Services
  4. Tools: contracts and function calling
  5. Memory: short-term, long-term, and RAG
  6. Workflows and pure agents
  7. Verification: the three-stage evaluation loop
  8. The whole arc: closing the course
  9. Lab: operational steps and R&D directions
  10. Test your knowledge

1. Why agentic AI now

Deck 12 (Aguzzi, "AI-Engineering: Tools, Agents and Verification") opens with a guiding question that structures the whole chapter: "how can a language model perceive, decide, act, remember, and remain verifiable?" The historical motivation is precise: "modern agentic AI emerges when classical agent (like reinforcement learning) theory meets foundation-model capabilities. Classical AI already gave us the vocabulary of agents, environments, actions, and goals — previous lessons on reinforcement learning and Markov decision processes introduced these concepts in a formal way :)" — the connection to chapter 13 is explicit on the first slide. "Modern LLMs add a practical interface: they can interpret natural-language tasks and coordinate multi-step workflows."

This creates three engineering questions, which map exactly onto the three parts of the chapter's title:

  1. "how can an LLM become the reasoning core of an agent? (thinking model, planner, etc.)" — the agent itself;
  2. "how can that agent interact with external systems?" — tools (and memory);
  3. "how can we verify whether the resulting behavior is correct, safe, and reliable?" — verification.

The reference lens throughout is LangChain4j, "to discuss these ideas at the application level" — a Java/Scala framework whose abstractions (AI Services, tools, ChatMemory, agents, verification helpers) let the lecture talk about architecture instead of plumbing. The closing lesson of the deck, "power without verification is not engineering", is the same thesis that opened the course in chapter 1: validation is pervasive, and it applies to agents too.

WHY AGENTIC AI NOW — THEORY MEETS FOUNDATION MODELS

classical vocabulary: agents, environments, actions, goals (chapter 13, in a formal way :)

ConceptDetails
THE TWO PARENTSclassical agents (RL, MDP): the formal
vocabulary of perception, action, goals
foundation models: interpret natural-
language tasks, coordinate multi-step
workflows — a practical interface
THREE ENGINEERING QUESTIONS1. how can an LLM become the reasoning
core of an agent? (thinking model, planner)
2. how can that agent interact with external
systems? (tools, memory)
3. how can we verify the behaviour?
THE GUIDING QUESTION AND THE LENSguiding question: how can a language model perceive, decide, act, remember, and remain verifiable?
reference lens: LangChain4j — the ideas discussed "at the application level" · tools, memory, agents, verification
"power without verification is not engineering" — the pervasive-validation thesis of chapter 1, applied to agents
Plate 15.1 — Why agentic AI now. The formal vocabulary of agents and environments from RL/MDP theory meets the practical interface of foundation models. The chapter answers the three engineering questions — reasoning core, external interaction, verification — with tools, memory, and an evaluation discipline.

2. Agent: working definition and core properties

The deck's working definition is deliberately classical:

"An agent is a system that perceives an environment, selects actions, and executes them in pursuit of explicit objectives."

Three terms carry the load: "perception provides information about the current state of the world (or of the task)"; "action modifies the environment, the system state, or the available knowledge"; "objectives define the criterion by which one action is preferred over another — in LLM-based agents, objectives are often expressed as natural-language instructions". The key point of the slide: "agency is defined by the full perception-action loop, not by intelligence alone" — a model that only generates text is not an agent; a model embedded in a loop that perceives, decides and acts is.

The four core properties tell us "what kind of system we are building":

The RL echo is deliberate: the perception-action loop is the agent-environment interface of chapter 13, section 3, goal-directedness is the reward hypothesis, temporality is the episode. What changed is the reasoning core: where the RL agent learned a policy from rewards, the LLM agent interprets objectives in natural language and plans multi-step actions — and both face the same engineering problem of abstraction ("the number of states and actions reasonably limited") and of verification.

3. Building blocks and AI Services

"An agentic system works only when model, tools, memory, and orchestration remain aligned." The deck's architecture has four layers:

LangChain4j's first high-level abstraction above raw chat is the AI Service: "a declarative Java interface whose methods are implemented by an LLM-backed runtime". "The application invokes a method, while the framework handles prompt construction, model invocation, and result mapping"; "optional capabilities such as tools, memory, and retrieval can be attached to the same abstraction". The canonical example — a sentiment analyser with a typed boolean return:

trait SentimentAnalyzer:
  // The @UserMessage annotation specifies the prompt template for this method.
  @UserMessage(Array("Does {{it}} has a positive sentiment?"))
  def analyzeSentiment(text: String): Boolean

object SentimentAnalyzer:
  def createWith(llmModel: ChatModel): SentimentAnalyzer =
    AiServices.builder(classOf[SentimentAnalyzer])
      .chatModel(llmModel)
      .build()

def testSentimentAnalyzer(): Unit =
  val model = OllamaChatModel.builder().baseUrl("http://localhost:11434")
    .modelName("gemma4:e2b")
    .build()
  val sentimentAnalyzer = SentimentAnalyzer.createWith(model)
  sentimentAnalyzer.analyzeSentiment("Scala is a great programming language!") // true

Read it as an interface-driven design: the application declares what it wants (a function from String to Boolean) and the framework supplies how (prompt construction, model call, result mapping). This is the "declarative over procedural" spirit of the whole course — from the DSLs of chapter 9 to the aggregate programs of chapter 14.

BUILDING BLOCKS — FOUR LAYERS, ONE LOOP

"an agentic system works only when model, tools, memory, and orchestration remain aligned"

ConceptDetails
THE FOUR LAYERSreasoning — LLM: interpret, plan, synthesise
action — tools: search, APIs, databases, code
continuity — memory: across steps and sessions
control — orchestration: outputs → operations
AI SERVICESa declarative Java interface whose methods are
implemented by an LLM-backed runtime
the app invokes a method; the framework handles
prompt construction, model invocation, result mapping
tools, memory, retrieval attach to the same abstraction
THE SENTIMENT ANALYSER — DECLARATIVE OVER PROCEDURALtrait SentimentAnalyzer { @UserMessage(Array("Does {{it}} has a positive sentiment?"))
def analyzeSentiment(text: String): Boolean }
the application declares WHAT (String => Boolean); the runtime supplies HOW — the pattern of the whole course, from DSLs to aggregate programs
Plate 15.3 — The building blocks. Four layers — reasoning, action, continuity, control — must stay aligned. AI Services make the model interaction declarative: an interface whose methods the runtime implements, with prompt templates in annotations. Tools, memory and retrieval plug into the same abstraction.

4. Tools: contracts and function calling

"Tools turn language into action." A tool is "a callable resource outside the model, exposed through a well-defined interface" — "a tool is not stored inside the model parameters; it is made available by the surrounding software system". The minimum contract has four parts:

Why tools matter: grounding — "tools can reduce hallucination by connecting answers to external information sources: before replying, the model can check facts, compute results, or query databases instead of relying solely on internal knowledge (self-augmentation and self-correction patterns)"; capability extension — "tools enable actions that plain text generation cannot perform reliably on its own (e.g. performing calculations, or manipulating structured data)"; system interaction — "tools let the agent read from and write to real systems"; observability — "tool schemas make behavior easier to inspect and evaluate".

"A good tool specification acts as a contract between the model and the execution layer... better tool contracts usually produce more reliable tool selection and safer execution." The LangChain4j calculator shows the pattern — @Tool annotations generate the JSON schema:

class Calculator:
  @Tool(name = "sum", value = Array("Calculate the sum of two numbers"))
  def sum(@P("left value") a: Double, b: Double): Double = a + b
  @Tool(name = "subtract", value = Array("Calculate the difference of two numbers"))
  def subtract(a: Double, b: Double): Double = a - b
  @Tool(name = "multiply", value = Array("Calculate the product of two numbers"))
  def multiply(a: Double, b: Double): Double = a * b
  @Tool(name = "divide", value = Array("Calculate the quotient of two numbers"))
  def divide(a: Double, b: Double): Double = a / b

trait MathAgent:
  @UserMessage(Array("I need to perform this calculation: {{expression}}"))
  def calculate(expression: String): Double

@main def testMathAgent(): Unit =
  val model = //...
  val mathAgent = AiServices.builder(classOf[MathAgent]).chatModel(model)
    .addTool(new Calculator).build()
  mathAgent.calculate("What is the sum of 5 and 7?") // 12.0

How does language become action? "The orchestration layer converts language into execution and execution back into context": the agentic system must "describe available tools to the model, interpret the model's action request, execute the selected tool, return the result as a new observation". The historical baseline was zero-shot tool use: "tools described directly in the prompt, the model asked to emit a textual pseudo-command — limitation: formatting errors became execution errors". Current practice: "many modern models already support this ReAct-style loop natively — they decide when a tool is needed, emit a structured request, observe the result, and continue reasoning". "Function calling is the usual interface: the model returns a typed function name with validated arguments instead of fragile free text"; "frameworks such as LangChain4j help normalize provider-specific tool-calling APIs at the application level".

Finally, the Model Context Protocol (MCP) addresses integration fragmentation: "traditional integrations (files, Slack, GitHub) require custom point-to-point glue code, leading to fragmentation and duplicate effort"; MCP is "a standardized open protocol to securely connect AI models to any data source or tool — build once, use everywhere". Architecture: "MCP Client: your AI application (e.g. LangChain4j) requesting tool execution; MCP Server: standalone process exposing dynamic schemas (e.g. read_file, write_file)"; "the client discovers tools dynamically at startup via a handshake; communicates via local processes (Stdio) or remote hosts (Streamable HTTP)". The deck's verdict: "conceptually it just a simple way to decouple the model's tool-calling interface from the actual implementation of tools."

TOOLS — A CONTRACT BETWEEN MODEL AND EXECUTION

name · description · input schema · output schema — "better contracts ⇒ more reliable selection, safer execution"

ConceptDetails
WHY TOOLS MATTERgrounding: reduce hallucination — check facts,
compute, query instead of guessing
capability extension: actions beyond text
system interaction: read and write real systems
observability: schemas make behaviour inspectable
FROM TEXT TO ACTIONdescribe tools to the model
interpret the model's action request
execute the selected tool
return the result as a new observation
zero-shot: textual pseudo-commands, fragile
THE REACT LOOP — NATIVE FUNCTION CALLINGtask → action request → execution → observation → continuation
function calling: "the model returns a typed function name with validated arguments instead of fragile free text"
MCP: standardised open protocol — clients and servers, dynamic schema discovery, Stdio or Streamable HTTP
Plate 15.4 — Tools. A tool is a four-part contract (name, description, input schema, output schema) that the orchestration layer turns into execution and back into context. Modern models run the ReAct loop natively via function calling; MCP standardises the client-server plumbing. The widget below steps a ReAct loop by hand.

5. Memory: short-term, long-term, and RAG

"Memory turns interaction into continuity": memory is "the mechanism by which an agent stores, retrieves, and reuses information across reasoning steps or across interactions". The first distinction of the lecture is Memory ≠ History: "History: a raw, passive, chronological transcript of what happened. Memory: an active, curated subset injected into the context to shape the reasoning process." The four pillars of memory: continuity (conversation context across turns and steps), personalization (user preferences, instructions, settings), planning (task state, subgoals, execution progress), retrieval (contextually injecting relevant prior or external knowledge).

The two lifecycles:

RAG splits into two stages. Indexing (offline): "documents are cleaned, parsed, and split into smaller segments (chunking — cuts long texts into cohesive segments fitting the context window); each segment is converted into a numeric vector (embedding — text into numeric coordinates representing semantic concepts) and stored". In LangChain4j, FileSystemDocumentLoader.loadDocuments("/docs") + an in-memory EmbeddingStore + EmbeddingStoreIngestor handle "segment splitting, embedding generation, and database storage" automatically. Retrieval (online): "the query is vectorized using the same embedding model; a specialized vector store (Vector Store: database optimized for high-speed semantic similarity searches) finds and returns semantically similar segments; relevant segments are injected directly into the LLM prompt context" — in code, an EmbeddingStoreContentRetriever bound to the AI Service via contentRetriever(retriever) with maxResults(3). "For both stages, the choice of embedding model (semantic depth), chunking strategy (segment size), and vector store (retrieval architecture) directly determines retrieval precision and relevance."

MEMORY — HISTORY ≠ MEMORY, SHORT VS LONG TERM

history: raw passive transcript · memory: active curated subset injected to shape reasoning

ConceptDetails
SHORT-TERMconversation / task scope
injected into the context window
volatile — discarded at session end
ChatMemory: eviction, compression,
filtering · @MemoryId isolation
LONG-TERM (RAG)across conversations, durable
vector stores, retrieved dynamically
retrieve → augment → generate
quality: freshness, provenance,
retrieval relevance
FOUR PILLARScontinuity · personalization
planning · retrieval
memory is curated and injected;
history is everything that happened
RAG — INDEXING (OFFLINE) vs RETRIEVAL (ONLINE)indexing: clean → chunk → embed → store · retrieval: vectorize the query → top-k similar segments → inject into the prompt
embedding model (semantic depth), chunking strategy (segment size), vector store (architecture) decide precision
LangChain4j: FileSystemDocumentLoader + EmbeddingStoreIngestor · EmbeddingStoreContentRetriever on the AI Service
Plate 15.5 — Memory. History is the raw transcript; memory is the curated injection. Short-term memory lives in the context window (ChatMemory with eviction/compression/filtering); long-term memory lives in vector stores and is injected by retrieval. RAG splits into offline indexing and online retrieval, each with its own quality levers.

6. Workflows and pure agents

With tools and memory in place, the question is orchestration. The deck uses Anthropic's taxonomy of two paradigms:

The practical perspective: "start with workflows, introduce pure agency only for high-complexity, unstructured decisions".

In LangChain4j, an agent is "defined as an interface (similar to an AI Service)" with the @Agent annotation; subagents "can write results to a shared state and read input from previous steps". The AgenticScope is "a stateful blackboard containing data shared among the subagents participating in an agentic system": a shared blackboard ("agents read required inputs from the scope and write results back using outputKey"), an automatic registry ("automatically logs the exact sequence of agent invocations and their raw outputs" — the observability that verification needs), and persistence & recovery ("the scope can be serialized, persisted, and reloaded to recover a multi-turn process from failure"). "In practice: the scope decouples agent execution from orchestration routing."

The workflow builders cover the taxonomy:

WORKFLOWS vs PURE AGENTS

"start with workflows, introduce pure agency only for high-complexity, unstructured decisions"

ConceptDetails
WORKFLOWSdeterministic, hardcoded paths
sequences · loops · parallel · branches
predictable, reliable, easy to test — rigid
the default choice, agent-by-agent
PURE AGENTSthe LLM is the planner: decides the next
tool or subagent from the current state
flexible, adaptive — harder to verify
supervisor pattern: planner + subagents
response strategies: LAST · SUMMARY · SCORED
AGENTICSCOPE — THE SHARED BLACKBOARDagents read inputs and write results via outputKey · automatic registry of invocations and raw outputs
serialisable, persistable, reloadable — recover a multi-turn process from failure
patterns: sequential · loop (maxIterations, exitCondition) · parallel (no ChatMemory in mappers) · conditional (router)
"the scope decouples agent execution from orchestration routing" — and gives verification its trace
Plate 15.6 — Workflows and pure agents. Workflows are deterministic compositions (sequence, loop, parallel, conditional); pure agents let the LLM plan dynamically (supervisor). The AgenticScope blackboard connects both: shared state, invocation registry, persistence — the substrate that verification inspects.

7. Verification: the three-stage evaluation loop

"Power without verification is not engineering." Why traditional assertions fail: "agent loops are multi-step, stateful, and non-deterministic"; "unit testing assumes deterministic, reproducible state-to-state mappings"; "models behave as black-boxes with probabilistic output spaces"; "small changes in prompts can cause catastrophic, silent regressions"; "dialogue histories and intermediate tool responses create an infinite state space"; and "error propagation (cascading failures): a minor reasoning or tool-call error in step i propagates and amplifies through subsequent steps". The conclusion: "we must evaluate the entire trace of the interaction, not just the final output".

The deck's answer is a 3-stage evaluation loop running "continuously at different granularities and speeds":

Verifying the trajectory — "in multi-step agents, the path taken is as important as the final answer": tool selection accuracy (classification metrics Precision, Recall, F1 comparing expected vs actual tool-call traces); argument boundary checking ("validates that arguments emitted by the model fall within safe, expected ranges and schemas — preventing SQL/command injection"); observation grounding ("is the agent's next reasoning step logically coherent with the tool's output, or does it ignore facts/hallucinate past them?"); exception recovery (self-correction) ("inject simulated tool exceptions — API timeouts, rate limits — to verify if the agent's planner gracefully recovers, falls back to other tools, or reports failure cleanly"). The closing reminder: "a correct answer reached through an inefficient or unsafe tool loop is still an engineering failure."

VERIFICATION — EVALUATE THE TRACE, NOT JUST THE OUTPUT

multi-step, stateful, non-deterministic · cascading failures · infinite state space of dialogues and tool responses

high for large k

(faithfulness, relevance, recall)

failure modes backported to L2

ConceptDetails
LEVEL 1 — DETERMINISTICunit tests and assertions on
every code change (CI/CD)
schemas, regex, latency bounds
pass@k over n samples
temperature: low for k=1,
LEVEL 2 — SEMANTICgolden dataset (20–100 cases)
critique shadowing: binary
judgments + one-sentence critique
LLM-as-judge: critique first,
then PASS/FAIL · RAGAs triad
LEVEL 3 — STATISTICALproduction telemetry: implicit
feedback, exception rates, drift
tracing: query → planning →
sub-agent → tool → observation
LangSmith · Langfuse · Phoenix
VERIFYING THE TRAJECTORYtool selection accuracy (P/R/F1 on tool-call traces) · argument boundary checking (against injection)
observation grounding (does the reasoning follow the tool output?) · exception recovery (simulated timeouts, rate limits)
"a correct answer reached through an inefficient or unsafe tool loop is still an engineering failure"
Plate 15.7 — The three-stage evaluation loop. Deterministic filters run on every change; semantic validation runs against a curated golden dataset with human-aligned judges; production telemetry monitors the live behaviour — and failures found at level 3 are distilled back into the golden dataset. The trajectory itself — tool choices, arguments, grounding, recovery — is evaluated, not just the answer.

8. The whole arc: closing the course

This is the last chapter, and the deck's own conclusion points beyond itself: "evaluating multi-step reasoning requires accounting for stochasticity, non-determinism, and complex tool trajectories"; "key dimensions for real-world deployment: model versioning (track behavioral changes over time to establish robust LLMOps pipelines), advanced observability (trace analysis tools like LangSmith), robust verification (simulation environments, synthetic datasets, and adversarial testing)". The frameworks it names — LangSmith, MCP, A2A (agent-to-agent communication) — are where the field is going.

Standing at the end of the course, the four parts assemble into one argument:

The explicit bridges built along the way: Alchemist as the simulator of both chemical systems and aggregate programs (chapters 12 → 14); Q-learning learning policies inside simulations and for device parameters (chapters 12, 13 → 14); the reward hypothesis of chapter 13 as the goal-directedness of chapter 15's agents; the MDP vocabulary of chapter 13 as the formal grounding of the agent definition of this chapter; and the pervasive-validation thread from chapter 1, through model checking in chapter 11, to pass@k and LLM-as-a-judge here. One thread throughout, as the course index promised: rigorous specification, then pervasive validation of it.

Key idea — the course closes where it opened

Chapter 1 taught that validation is pervasive: every artifact — code, model, policy — earns its place by being checked. Chapter 15 applies the same rule to the newest artifact of the course, the LLM agent: not "does it answer correctly" but "does it perceive, decide, act, remember, and does the whole trace stand up to inspection?" The three-stage loop (deterministic filters, semantic validation, production telemetry) is the pervasive-validation pyramid of chapter 1, rebuilt for probabilistic, multi-step, tool-using systems. The course's one thread — rigorous specification, then pervasive validation — holds from the first test to the last judge.

9. Lab: operational steps and R&D directions

The lab deck (12-Lab) sums up: "agents: autonomous entities that perceive their environment, make decisions, and act to achieve goals; in the generative AI era, agents leverage LLMs/SLMs for reasoning and planning — tools: enable agents to interact with the external world (e.g. APIs, databases, and files); memory: stores short-term conversation context or long-term facts; coordination: complex tasks can be split across multiple specialized sub-agents. Verification and monitoring of agents: why? to ensure reliability, safety, correctness, and alignment with user intent; how? by evaluating tool traces, analyzing LLM reasoning (thought paths), and using programmatic assertions or other LLMs as judges; human-in-the-loop: monitoring execution loops to support user validation and feedback."

Operational steps

R&D tasks

TaskWhat it asks
Task 1 — autonomous robot navigationGuide a robot from (0.0, 0.0) to the target goal at (3.0, 3.0), avoiding obstacles: in RobotTools.scala describe the robot's capabilities (movement, environment status) by annotating methods with @Tool and implementing the environment steps; in RobotSimulationApp.scala implement the RobotAgent trait and configure the OllamaChatModel and AiServices with conversational memory and tools to plan and execute the path — the perception-action loop of section 2, with the robot grid echoing the RL grids of chapter 13.
Task 2 — verification and interactive tracingProgrammatically inspect MessageWindowChatMemory in the loop to assert which tools were chosen in the last step; test the agent across alternative grid configurations with different obstacle placements to evaluate navigation robustness — trajectory verification (section 7) on a concrete system.
Task 3 — model and temperature comparisonCompare different reasoning models (e.g. qwen3.5:4b vs gemma4:e2b) in terms of navigation success, path length, and tool execution efficiency; experiment with temperature settings (0.0 vs 0.7) to analyze their impact on deterministic path planning and exploration — the pass@k temperature trade-off of section 7 in practice.
Task 4 — advanced scenarios (optional)Enhance the environment to support carrying objects and implement tools for Hold and Release actions; run the other workflow examples in it.unibo.agents (Sequential, Parallel, Loop, Conditional, Supervisor) to see how multi-agent coordination works.
For the exam — the whole course in one answer

The strongest closing presentation connects the three chapters of Part D and the course's thread: the agent of this chapter is the RL agent of chapter 13 with an LLM planner and tools (the perception-action loop, formalised by MDPs); its environment can be a simulation from chapter 12 (Alchemist, kinetic Monte Carlo) or an aggregate system from chapter 14 (fields as the state space); and its verification reuses everything the course taught about validation — deterministic checks (chapter 1–3), quantitative reasoning (chapter 11), and human-aligned evaluation (chapters 4–5). If you can walk one system — say, a robot navigating a grid with a learned or planned policy — through all four parts, you have the course.

Test your knowledge

What are the three engineering questions of agentic AI, and how does the chapter answer them?

(1) How can an LLM become the reasoning core of an agent? — the agent definition, core properties and AI Services. (2) How can that agent interact with external systems? — tools (contracts, function calling, MCP) and memory (short/long-term, RAG). (3) How can we verify whether the resulting behavior is correct, safe, and reliable? — the three-stage evaluation loop and trajectory verification.

Give the working definition of an agent and the four core properties.

An agent is a system that perceives an environment, selects actions, and executes them in pursuit of explicit objectives; agency is defined by the full perception-action loop, not by intelligence alone. Properties: situatedness (embedded and effective), autonomy (a spectrum, not binary), goal-directedness (evaluated relative to explicit objectives), temporality (decisions unfold over time).

What are the four building blocks of an agentic system, and what is an AI Service?

Reasoning layer (LLM: interpret, plan, synthesise), action layer (tools: search, APIs, databases, code execution), continuity layer (memory), control layer (orchestration: translate model outputs into executable operations and return observations). An AI Service is a declarative Java interface whose methods are implemented by an LLM-backed runtime: the app invokes a method, the framework handles prompt construction, model invocation, and result mapping; tools, memory and retrieval attach to the same abstraction.

What is the minimum contract of a tool, and why do tools matter?

Name (identification), description (when to use), input schema (valid arguments), output schema (interpretable results). They matter for: grounding (reduce hallucination by connecting answers to external sources), capability extension (calculations, structured data), system interaction (read/write real systems), observability (schemas make behaviour inspectable).

How does the orchestration layer turn language into action, and what changed from zero-shot tool use to native ReAct?

It must describe available tools to the model, interpret the model's action request, execute the selected tool, and return the result as a new observation. Zero-shot tool use described tools in the prompt and asked for textual pseudo-commands — formatting errors became execution errors. Modern models support the ReAct loop natively: they decide when a tool is needed, emit a structured request (function calling: a typed function name with validated arguments), observe the result, and continue reasoning.

What is MCP, and what problem does it solve?

The Model Context Protocol: a standardized open protocol to securely connect AI models to any data source or tool, replacing custom point-to-point glue code. Architecture: MCP Client (the AI application requesting tool execution) and MCP Server (a standalone process exposing dynamic schemas); discovery via a startup handshake; transports via local processes (Stdio) or remote hosts (Streamable HTTP). It decouples the model's tool-calling interface from the actual implementation of tools.

What is the difference between history and memory, and what are the four pillars?

History: a raw, passive, chronological transcript. Memory: an active, curated subset injected into the context to shape reasoning. Pillars: continuity (context across turns and steps), personalization (preferences and instructions), planning (task state, subgoals, progress), retrieval (contextually injecting relevant prior or external knowledge).

Compare short-term and long-term memory, and describe the RAG pipeline.

Short-term: current conversation scope, injected into the context window, volatile; managed by ChatMemory with eviction, compression and filtering policies, isolated per session via @MemoryId. Long-term: across conversations, stored in external databases/vector stores, durable. RAG: Retrieve (match the query against a vector store), Augment (inject the most relevant chunks into the context), Generate (answer with the injected knowledge). Indexing (offline): clean, chunk, embed, store. Retrieval (online): vectorize the query, top-k similar segments, inject into the prompt.

What is the Anthropic taxonomy of agentic architectures, and what are the workflow patterns?

Workflows: deterministic hardcoded paths (sequences, loops, parallel, conditional branches) — predictable, reliable, testable, rigid. Pure agents: the LLM as autonomous reasoning core and planner deciding the next tool/subagent from state — flexible, adaptive, harder to verify. "Start with workflows, introduce pure agency only for high-complexity, unstructured decisions." Patterns: sequential, loop (maxIterations + exitCondition), parallel (no ChatMemory in mappers), conditional (router), supervisor (LLM planner; response strategies LAST, SUMMARY, SCORED; context policies).

What is the AgenticScope, and why does it matter for verification?

A stateful blackboard containing data shared among subagents: agents read inputs and write results via outputKey; an automatic registry logs the exact sequence of agent invocations and their raw outputs; the scope can be serialized, persisted and reloaded to recover a multi-turn process from failure. It decouples execution from orchestration routing — and its registry is the trace that verification evaluates.

Why do traditional assertions fail for agents, and what are the three stages of the evaluation loop?

Agent loops are multi-step, stateful and non-deterministic; models are probabilistic black-boxes; small prompt changes cause silent regressions; the state space is infinite; errors cascade. Level 1: unit tests and assertions (deterministic filter, CI/CD, schemas/latency; pass@k). Level 2: semantic validation against a golden dataset with human-aligned LLM-as-a-judge (critique-first prompting, few-shot real alignment, RAGAs triad). Level 3: production telemetry and monitoring (implicit feedback, exception rates, drift, tracing) with failure modes backported into the dataset.

Define pass@k, the critique shadowing protocol, and the four trajectory-verification checks.

pass@k: fraction of problems solved when generating k candidate solutions (solved if at least one passes verification); unbiased estimator over n samples with c successes: pass@k = 1 − C(n−c,k)/C(n,k); low temperature for pass@1, high for large k. Critique shadowing: binary judgments ("ready for production?") plus a one-sentence critique, instead of biased 1–5 ratings. Trajectory checks: tool selection accuracy (P/R/F1 on traces), argument boundary checking (against injection), observation grounding (reasoning coherent with tool output), exception recovery (simulated failures).