liveBook · Manning

Intelligent element

As explained in Agent Design Patterns

An agent component that uses AI to assess information or perform a focused function.

An intelligent element (IE) is an agent component that performs a focused AI-dependent function. A language or vision model can serve as an IE, and an agent component assembled from other IEs can itself be used as one. The surrounding procedure decides what to do with its output: extract an answer, gate information, retry a task, or reconcile several results. section 3.2 section 4.2 section 6.2

The same interface supports several distinct control flows:

  • In an errand, one or more IEs perform a narrow operation, sometimes in parallel. Later steps turn their intermediate results into a final output; the errand exposes that output rather than its working results. section 3.2
  • In a guardrail, an assessor IE judges an input. A separate gating procedure forwards the guarded information when it passes or substitutes a generic response when it fails. section 4.2
  • In a resampler, a worker IE produces a candidate. A check either accepts it or sends the same input back for another trial, up to a limit. The check need not be intelligent. section 5.2
  • In a voter, parallel invocations of a worker IE produce identifiable answers. A reconciliation procedure combines those votes; distinct trajectories can come from sampling or perturbed inputs. section 6.2

A guardrail assessor

An assessor can expose an asynchronous string-to-Boolean call: request a security verdict from a model, extract the tagged verdict, and return false if extraction fails. The guardrail then uses that Boolean to forward the information or return a blocked-response message. Keeping assessment separate from gating makes the failure behavior explicit. section 4.2

Listing 3.1 errand.py: Sketch implementation of a generic Errand class.
import asyncio
from typing import Any
from utils import IE, E, Client, LMCall, FunctionCall
import re
import json
 
 
class Errand(IE[[str], str]):
    def __init__(
        self,
        intelligent_elements: list[IE[[str], Any]],
        procedure: E[[list[Any]], str],
    ):
        self.intelligent_elements = intelligent_elements
        self.procedure = procedure
 
    async def __call__(self, input: str) -> str:
        ie_tasks = [
            ie(input) for ie in self.intelligent_elements
        ]
        ie_results: list[Any] = await asyncio.gather(
            *ie_tasks
        )
        procedure_result: str = await self.procedure(
            ie_results
        )
        return procedure_result

The generic Errand class makes the compositional interface concrete: it calls its IEs concurrently, passes their results to a procedure, and returns only the procedure’s result. section 3.2

An IE’s answer is not automatically a usable agent result. Generative output may miss a required format, and orchestration code cannot reliably recover an answer by reading prose as a person would. Extract or assess outputs at the boundary; when using repeated trials, account for their cost and define what happens when none succeeds. section 5.0 section 5.2

How Agent Design Patterns covers it

How deep it goes
Shows callable interfaces and orchestration sketches for composing IEs, but does not detail model internals.
Examples
Uses a security-verdict assessor, concurrent errand workers, bounded retries, and parallel voting trajectories.
What it assumes
Assumes familiarity with agent workflows and Python-like asynchronous calls while illustrating IE composition through implementation sketches.
What you can do after
Build it from scratch as a callable agent component and compose it with procedures that check, retry, gate, or reconcile its output.
How it connects
Connects intelligent elements to errands, guardrails, resampling, voting, assessment, and reconciliation procedures.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Agent Design Patterns. The section links point to the parts of the book it draws on.