An access pattern in which an agent searches for relevant tools first, then executes only a small set of candidates. It reduces prompt bloat and improves governance by keeping long-tail capabilities out of the default context.
How the Search-and-Run Pattern Works
The search-and-run pattern splits agent tool use into two stages: first, the agent searches for relevant capabilities, then it executes only a small, filtered set. That keeps the active context smaller and makes the toolchain easier to reason about during runtime.
This is different from preloading every available tool into the prompt. Instead of assuming the agent should consider the full capability set on every turn, the pattern treats tool discovery as a separate step and narrows the decision space before action.
Why It Improves Agent Control
The main value is control. When only a short list of candidate tools reaches the execution stage, it is easier to understand why the agent chose a tool, what alternatives were considered, and whether the chosen path matches policy or intent.
That reduction in context also lowers the chance that rarely used or sensitive capabilities will be invoked by default. In practice, the pattern helps teams separate broad discoverability from actual permission to act, which is a useful distinction in governed agent environments.
Where It Fits in Agent Design
Search-and-run is most useful when the tool catalog is large, capabilities change often, or the agent must operate with narrow task scopes. It works well when the system can search by function, metadata, policy tags, or semantic match before the execution step.
The pattern is especially helpful when teams want an agent to stay adaptable without turning the prompt into a permanent inventory of everything it could do. Used well, it becomes a design choice for capability routing, not just a prompt-optimization trick.
Common Failure Modes
The pattern can fail if search is too broad, too shallow, or too permissive. If the search stage returns weak candidates, the agent may still drift into the wrong action path, only with a false sense of discipline because the final list looked “filtered.”
It can also hide important capabilities from review if search criteria are poorly governed. When the search layer becomes the real decision-maker, teams need to ensure that selection rules, ranking signals, and exclusions are deliberate rather than accidental.
Risk and Threat Considerations
Search-and-run can reduce exposure, but it also creates a new control point: if search is manipulated, the agent may be shown the wrong tools or miss the right ones. That makes the discovery step part of the trust boundary, not just a convenience layer.
Failure mechanism: An attacker, poisoned index, or malformed tool description can bias search toward unsafe capabilities, obscure safer ones, or cause the agent to execute a tool that was never meant to be in the candidate set.
Impact: The result can be unauthorized actions, capability misuse, policy bypass, or harder-to-detect abuse because the agent appears to have followed a normal search-and-selection flow.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-53 Rev 5, NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-2 — Account Management | Search-and-run changes which tools are exposed for execution, so controlled capability inventory matters. |
| AC-6 — Least Privilege | The pattern narrows default capabilities to the minimum needed for the current task. | |
| AU-2 — Event Logging | Search and selection decisions should be observable to support review of tool choice and misuse. | |
| Recommendation — Limit the agent's usable tool set to approved accounts, roles, and functions before execution. Constrain tool access so the agent can invoke only the smallest necessary set of capabilities. Log tool search and selection events so reviewers can reconstruct why a capability was chosen. | ||
| NIST CSF 2.0 | PR.AA-01 — Identity and Access Management Policy | The pattern depends on governance over which capabilities are discoverable and executable. |
| Recommendation — Define policy for how agent capability discovery and execution are governed. | ||
| CIS Controls v8 | CIS-5 — Account Management | Managing the active tool set is analogous to managing which capabilities are available by default. |
| Recommendation — Remove unnecessary default capabilities and keep the active tool inventory tightly managed. | ||
Practitioner Guidance
Why practitioners should care: Treat the search stage as a governed control surface, not a neutral pre-step. The quality of the candidate set determines whether the agent’s later action is explainable, constrained, and aligned with policy.
What to watch for: Review whether search results are stable, scoped, and auditable enough to support safe tool execution. If the candidate set changes unpredictably, the pattern can become harder to govern than a smaller static tool list.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 22, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org