Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Design middleware for reusable capabilities across the solution, including logging, authorization, and exception handling

A worked example

Multiple answers

Woodgrove Bank runs a loan-advice agent built with Microsoft Agent Framework. The team registers four agent middleware components:

  • Logging: records each request as it receives it, and the final response.
  • Redaction: removes account numbers from the prompt before passing it on.
  • Authorization: returns a rejection response directly, without calling the next layer, when the caller lacks the required role.
  • Moderation: sends the prompt to an external content-moderation API and blocks prompts that fail.

Requirements:

  1. The log must record each prompt exactly as the caller sent it.
  2. Account numbers must never be sent to the external content-moderation API.
  3. Requests rejected by Authorization must still be logged.
  4. Requests rejected by Authorization must not be sent to the external content-moderation API.

Which two registration orders, listed from first registered to last registered, meet all the requirements? Each correct answer presents a complete solution.

Choose 2 answers.
Why

Middleware nests in registration order: the first registered component is the outermost layer and sees the input before any other layer modifies it. Logging must therefore be first so it records raw prompts and also sees requests that Authorization later rejects. Redaction and Authorization must both sit outside Moderation, because Moderation must receive only redacted prompts and a short-circuiting Authorization layer stops inner layers from running. Redaction and Authorization can appear in either order, which gives the two valid sequences.

Source

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free