L3 · MAESTRO
Agent Frameworks
Where the agent's reasoning, planning, and tool execution happen: the orchestration logic deciding which tools to call, in what sequence, and how results return.
L3 is the agent runtime itself: the planning, action, tool-selection, and short-memory loop inside the AI Agents container.
The Agent Frameworks layer is where the agent’s reasoning, planning, and tool execution happen. It encompasses the orchestration logic that decides which tools to call, in what sequence, with what arguments, and how to incorporate results back into the agent’s context. Commercially deployed frameworks (LangChain, AutoGen, CrewAI, LlamaIndex Agents, Semantic Kernel) all live at this layer, as does any custom orchestration code the team writes around them. This is also the layer where planning loops, reflection cycles, and self-correction behaviours run.
What lives here
- Agent orchestration frameworks (LangChain, AutoGen, CrewAI, Semantic Kernel, LlamaIndex)
- Custom agent runtimes and orchestration wrappers written around framework primitives
- Planning and multi-step reasoning loops (ReAct, chain-of-thought, tree-of-thought)
- Reflection and self-correction logic (critique-revise cycles, plan validation)
- Tool routing: the mapping from agent intent to tool invocation, argument construction, and result handling
- Function-calling and structured-output parsing (JSON schema enforcement, argument validation)
- MCP client-side logic: how the framework issues MCP requests and interprets MCP responses
- Agent-to-agent delegation: how the framework dispatches subtasks to peer agents
- Context window management: what gets summarised, truncated, or evicted from the prompt
This layer is the most complex in a typical agentic deployment. It sits above the data plane (L2) and below the infrastructure that hosts it (L4), and it is the primary surface where attacker-controlled input (via prompt injection, poisoned tool output, or manipulated inter-agent messages) is acted upon rather than merely stored.
Concrete example: A CrewAI deployment uses a researcher agent and a writer agent, both backed by a shared tool registry that includes a web-search tool and a file-write tool. An attacker embeds a prompt-injection payload in a public webpage the researcher fetches; the payload instructs the CrewAI orchestrator to add file-write to the writer agent’s next call, exfiltrating internal context to an attacker-controlled URL. The tool-routing logic at L3 is the surface that fails, not the model or the infrastructure.
Threats that target this layer
- T2 Tool Misuse: the framework’s tool-routing logic can be manipulated by adversarial prompts to call tools with unintended arguments, call the wrong tool, or chain tool calls in sequences the operator never authorised. Because the agent constructs tool arguments from model output, T2 is inherently a L3 threat.
- T6 Intent Breaking and Goal Manipulation: planning and reflection loops can be manipulated mid-task to redirect the agent toward attacker-controlled goals. An agent that re-evaluates its plan in response to tool output or peer messages is susceptible to goal substitution at each reflection cycle.
- T5 Cascading Hallucination Attacks: frameworks that pass tool output directly into the next model call without validation create a pipeline where one hallucinated or attacker-fabricated output becomes the authoritative input for the next step.
- T11 Unexpected RCE and Code Attacks: frameworks that include code-execution tools (Python REPL, shell, SQL query constructors) expose a code-generation and execution surface. Adversarial prompt injection at L3 can produce malicious code that the framework then executes via a code tool.
- T16 Insecure Inter-Agent Protocol Abuse: the framework’s handling of MCP and A2A protocol messages is an L3 concern. Frameworks that trust tool descriptions at face value, or that do not validate response schemas, are susceptible to protocol-layer injection.
Mitigations anchored here
- input sanitisation: sanitize all content that enters the agent’s context before it reaches the planning loop. Covers user input, tool output, retrieved chunks, and peer-agent messages, each of which is a potential prompt-injection surface.
- least-privilege tool scoping: enforce a per-agent tool allowlist at the framework layer. The agent may only call tools in its declared scope; any out-of-scope call is rejected before execution, regardless of what the model requested.
- plan-vs-goal validation: validate agent plans (explicit ReAct plans, CoT chains, or structured action sequences) against a policy before execution begins. Catch goal-substitution (T6) and out-of-scope tool selection (T2) before the first real-world action runs.
- context isolation: prevent context from one agent’s session leaking into another’s. In frameworks that share a context store or prompt cache, isolation is a structural prerequisite for multi-tenant safety.
- MCP response sanitisation: validate MCP server responses against declared schema before injecting them into the agent’s context. Prevents protocol-layer injection (T16) from reaching the planning loop.
- reflection-loop depth cap: bound the number of reflection or critique-revise cycles the framework will execute per task. Unbounded reflection enables goal-drift amplification (T6) and resource exhaustion (T4) via recursive planning.
- code-generation review gate: require static analysis or sandboxed execution review before code generated by the agent is run by a code-execution tool. The primary L3 control for T11.
How L3 relates to its neighbours
L3 consumes data from L2 Data Operations (retrieval results, shared memory, prompt templates) and issues execution requests to L4 Deployment Infrastructure (tool calls that run in containers, shell commands, API calls). A failure of trust at L2 (poisoned retrieval) becomes a planning failure at L3. A planning failure at L3 (tool misuse) becomes an infrastructure-level consequence at L4.
L3 is also the layer that most directly implements the controls recommended by L6 Security and Compliance: policy enforcement (OPA, policy-bound autonomy), intent attestation, and least-privilege tool scoping are all L6 policies that take effect inside the L3 orchestration loop.
The Agent Frameworks layer is where autonomy lives, and where it goes wrong. Controls at L1 and L2 reduce the quality of attacker-controlled input; controls at L4 limit blast radius; only L3 controls can intercept a misaligned plan before it executes.
Threats at this layer
Every threat whose maestroLayers list includes L3. The prose above may discuss a subset; this list is the complete index.
- T2Tool Misuse
- T5Cascading Hallucination Attacks
- T6Intent Breaking and Goal Manipulation
- T11Unexpected RCE and Code Attacks
- T16Insecure Inter-Agent Protocol Abuse
- T17Supply Chain Compromise
- T19Unintended Workflow Execution
- T20Framework Vulnerability Leading to Code Injection
- T21Inconsistent Workflow State
- T29Plugin Vulnerability Leading to Agent Compromise
- T30Insecure Inter-Agent Communication Protocol
- T31Insufficient Isolation Between Agent Actions
- T32Runaway Agent on Solana
- T39Unintended Resource Consumption via MCP
- T40MCP Client Impersonation
- T41Schema Mismatch Leading to Errors
- T42Cross-Client Interference via Shared Server
Controls mapped to this layer
Auto-generated from the mitigation catalog: every mitigation whose maestroLayers list includes L3, sorted by maturity tier (Tier 1 production-canonical first, then Tier 2, then Tier 3 research-stage).
- Tier 1Agent SBOM(Signed AIBOM: a cryptographically-bound inventory of every component an agent loads)
An AI agent assembles itself at runtime from a model, prompt templates, plugins, and library dependencies, any of which can be tampered with before they arrive. A signed AI Bill of Materials (AIBOM) locks down that assembly: it records every component with a version and hash at build time, signs the manifest, and verifies it before the agent accepts traffic. A component that does not match its declared hash cannot silently enter the agent.
- Tier 1Kernel-isolated sandbox(Kernel-isolated sandbox — agent-executed code runs against its own kernel, not the host's)
When an agent executes generated or retrieved code, that code runs as a process with access to the host kernel. A vulnerability in the generated code, or a deliberate exploit injected through the agent's prompt, can reach the kernel and affect other workloads or the host itself. A kernel-isolated sandbox removes that path by giving the workload a kernel of its own: gVisor interposes a user-space kernel so syscalls reach the Sentry rather than the host, and Kata Containers runs the pod in a lightweight VM with a separate kernel. Which one is available is a property of the platform, not of the control — AKS ships Kata as Pod Sandboxing and does not support gVisor; GKE ships gVisor.
- Tier 1OPA authorisation(Open Policy Agent — a policy-as-code engine for every tool call an agent makes)
An agent can invoke any tool it has access to, constrained only by its own reasoning. If that reasoning is manipulated or the agent's permissions are misconfigured, it will call tools it should not. OPA addresses this by placing a policy decision point between the agent and every tool invocation: a Rego policy evaluates the agent identity, the tool, and the parameter envelope before execution proceeds, and the agent cannot reason or argue past the result.
- Tier 2Behavioural red-teaming(Behavioural red-teaming — adversarial evaluation of agent reasoning and tool use)
An agent exposes more attack surface than a static model: it reasons, plans, selects tools, and acts across multiple turns. Static analysis can characterise that surface, and runtime guardrails can block known-bad patterns, but neither can predict what the agent will do under attacker pressure it has never seen. Behavioural red-teaming addresses that gap through structured adversarial evaluation: probing the agent's reasoning, planning, and tool-use paths with attack strategies before each release.
- Tier 2Code review gate(Code-generation review gate — human approval before AI-generated code executes or merges)
An AI coding agent produces code that can be executed or merged to a production branch without a human ever reading it. If the agent has been manipulated, its generated code can contain hidden payloads, backdoors, or privilege-escalating logic. A code-generation review gate prevents that: every change attributable to an AI agent must pass automated static analysis and receive explicit human approval before it can merge or execute, and the agent identity that authored the change is structurally barred from also approving it.
An LLM processes everything in its context window as a single stream of tokens; it has no innate ability to tell instructions apart from data. If an attacker can place content where the model treats it as instruction, they control the agent. Context isolation prevents that by structurally separating untrusted content from system instructions at prompt construction time, so the boundary is enforced before the model ever sees the input.
- Tier 2Cross-client isolation(Cross-client isolation — request-scope tenant boundaries in shared MCP server deployments)
A shared MCP server that accepts connections from multiple clients is a concentration point where one client's session state, credentials, and resource budget are physically co-located with every other client's. Without enforced isolation, a malicious or compromised client can read another session's cached credentials, consume shared resources to the point of denying service to other clients, or exploit aggregate server permissions that exceed its own declared scope. Cross-client isolation is the set of structural controls that close those paths: per-session state scoping, per-client permission evaluation, and per-client resource quotas enforced at the server layer.
An agent's behaviour can shift gradually over time: tool-selection patterns change, refusal rates drop, output style drifts. No single interaction reveals it, and a single-shot evaluation cannot catch a trend that spans weeks. Behavioural divergence monitoring detects that drift by comparing per-window statistical distributions of observable agent signals against a declared baseline, and alerting when the gap exceeds a threshold.
An agent that is uncertain about what to do next faces a choice: refuse and ask for clarification, or proceed on its best guess. In low-stakes situations that tradeoff is tolerable. In agentic systems that write, delete, or send, a confident-sounding but wrong output can commit an irreversible action. A fail-closed gate resolves that choice structurally: below a configured confidence threshold, the agent stops and escalates rather than guessing.
- Tier 2Goal consistency(Goal-consistency monitoring — a per-step check that the agent is still pursuing its original objective)
An agent's goal can drift across reasoning steps without any single catastrophic event: a manipulated tool output, a planted instruction in retrieved content, or an incremental semantic shift across many planner outputs can each redirect the agent away from its original objective. Goal-consistency monitoring addresses this by persisting the originally-declared goal, deriving a goal-state signal at each reasoning step, and computing a similarity score between the two. When the score falls below a per-task threshold, the monitor pauses the agent and surfaces the divergence for human review before any irreversible action executes.
- Tier 2Graceful degradation(Graceful degradation — fail closed where it matters, fail open where it's safe)
An agent that encounters a quota trip, a dependency failure, or a timeout faces a choice: continue at reduced quality, or refuse. Getting that choice wrong is the core operational failure. Graceful degradation requires the answer to be declared before the incident, not improvised during it: write-authority paths fail closed and return a refusal; read-only paths fail open and disclose the degraded state explicitly.
- Tier 2Input sanitisation(Input sanitisation — enforcing the data/instruction boundary before content reaches the model)
An LLM cannot distinguish data from instructions on its own: that boundary has to be enforced at the point where external content enters the prompt. Input sanitisation does this by normalising, filtering, and structurally segmenting untrusted content before the model ever sees it, so retrieved documents, tool results, and user messages are treated as data rather than commands.
- Tier 2Loop limit(Reflection-loop depth limit — a ceiling on how often an agent reworks its own answer)
An AI agent can review and rewrite its own answer to improve it. If that review runs too long it ties up resources and stops the agent responding in time, and an attacker can deliberately trigger those endless cycles to stall the system. A reflection-loop depth limit prevents that: it sets how many review rounds an agent may run before it has to stop.
- Tier 2MCP sanitisation(MCP response sanitisation — validate and normalise tool outputs before they re-enter the LLM context)
An MCP server response is content the LLM will reason over next. The model cannot distinguish tool output from instruction: that boundary must be enforced at the client, before the payload enters the context window. MCP response sanitisation applies schema validation, Unicode normalisation, control-token stripping, and structural wrapping to every tool result at the response boundary, so adversarial content embedded in a server response cannot redirect the agent's planner.
- Tier 2MCP server attestation(MCP server attestation — cryptographic proof of server identity and binary integrity)
An MCP client connecting to a server has no built-in way to verify that the server at a given address is the expected workload or that its binary has not been replaced. An attacker who can intercept or substitute the server exploits that gap directly. MCP server attestation closes it by requiring the server to present cryptographic proof of two properties before the connection proceeds: that it holds a valid workload identity bound to a trusted certificate, and that its binary matches a signed hash recorded at build time.
An inter-agent message travels through channels and intermediate agents the receiver did not originate. If nothing binds the message cryptographically to its source, any intermediate hop can substitute or inject content that the receiving agent will treat as authoritative. Message signing closes that gap: the source agent signs each message payload with its private key, and the receiver verifies the signature against a distributed trust bundle before the content reaches the reasoning layer.
- Tier 2Multi-source verify(Multi-source verification — cross-check factual claims against an independent source before commit)
An agent that writes a false claim to memory, passes it to a downstream agent, or returns it to a user has introduced an error that each subsequent step may treat as established fact. The cascade depends on one condition: the false claim goes unchallenged. Multi-source verification breaks that condition by requiring every novel factual assertion to be corroborated by a structurally independent source before it is committed. If the second source cannot corroborate the claim, the assertion is refused or down-weighted before it enters any downstream step.
An AI agent can produce output that is harmful, deceptive, or factually wrong while still sounding fluent and confident. Output moderation places an independent classifier or moderation model between the agent and its destination, checking every output before it reaches a user or a downstream system. The generating model does not evaluate its own answer; a separate gate does.
- Tier 2Peer consensus(Multi-agent consensus — N-of-M independent agreement before high-impact actions)
A single agent's judgment on a high-impact action can be wrong, manipulated, or compromised. Requiring N of M independent peer agents to agree before the action executes means an attacker or a systematic error must affect the quorum majority, not just one agent, before harm results.
- Tier 2Plan check(Plan-vs-goal validation — independently check each proposed step against the original goal)
A plan-then-execute agent produces a sequence of steps before acting. If the planner is manipulated, it will emit steps that serve the attacker's goal rather than the user's. Plan-vs-goal validation addresses this by placing an independent validator between the planner and the execution loop: it evaluates each proposed step against the originally-declared goal before the agent is permitted to act on it.
- Tier 2Render restriction(Link and HTML rendering restriction — an allow-list control on what agent output may render)
An agent can include links and rich HTML in its output. When that output is attacker-influenced, a clickable link, embedded image, or rich preview card becomes the delivery mechanism for phishing or data exfiltration via markdown image injection. Rendering restriction removes that delivery vector by allowing clickable content only from an explicit allow-list of trusted domains and reducing everything else to plain text before the output reaches the user.
- Tier 2Static analysis(Static analysis on generated code — a pre-execution gate on LLM-emitted artifacts)
An agent that can generate and execute code treats code generation as a tool call and code execution as the outcome. If the generated code contains a known-dangerous pattern, no amount of prompt engineering stops it from running once the execute call goes through. Static analysis closes that gap: it scans every code artifact the agent emits against a rule set before execution is permitted, catching the vulnerability patterns the same tooling already catches in human-written code.
Each tool in an agent's catalog should expose only the methods, resources, and parameter ranges its designated role requires. Over-broad tool surfaces let individually authorised primitives compose into actions no human intended to grant; narrowing the scope at design time reduces both the attack surface and the blast radius of any compromise.
- Tier 3Intent attestation(Intent attestation tokens — a cryptographic binding from user approval to tool execution)
An agent acts on behalf of the user, but nothing in a standard OAuth bearer token records what the user actually approved. If the agent's planning is manipulated, it can invoke tools with parameters the user never sanctioned, while presenting credentials that look valid. Intent attestation fixes this by issuing a short-lived signed token that encodes the exact action and parameter envelope the user authorised, and requiring the resource server to verify that envelope before executing the call.
- Tier 3Workflow state consistency(Workflow state consistency — distributed-state integrity checks for multi-agent workflows)
When multiple agents read and write shared workflow state concurrently, a network partition, a delayed message, or an adversarially timed race condition can produce divergent views. An agent acting on stale or conflicting state may authorise an action it would reject given correct current state. Hash-chained state snapshots, merge-point conflict detection, and optimistic concurrency control close that window.