Inferensys

Prompt

Agent Tool Discovery System Prompt

A practical prompt playbook for building a system-level instruction block that prevents tool hallucination and governs how an agent discovers, interrogates, and reasons about its available tools at session start.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and explicit boundaries for the Agent Tool Discovery System Prompt.

This playbook is for agent framework developers who need a stable, reusable system prompt that governs how an agent discovers and reasons about its tool set at the start of every session. The prompt is designed to be injected as a system-level instruction before any user or task context is added. It constrains the agent to only claim capabilities that are explicitly present in its tool registry, defines the interrogation protocol for understanding tool parameters, and establishes the refusal language for unregistered capabilities. Use this when you are building an agent harness that connects to MCP servers, internal APIs, or dynamic tool registries and you need to prevent the agent from inventing functions, hallucinating parameters, or misrepresenting its own capabilities.

The ideal user is an AI platform engineer or agent framework developer who controls the system prompt layer and has access to a live tool registry at runtime. Required context includes the full tool manifest with names, descriptions, and input/output schemas, plus the agent's operational boundaries (read-only vs. write access, network restrictions, rate limits). This prompt is not a one-shot function-calling template; it is a persistent behavioral contract that survives multiple turns, tool call cycles, and context windows. Do not use this prompt for single-turn function calling where the model receives tool definitions directly in the API call; that workflow is covered by the Function Calling and Tool Selection pillar.

Before deploying this prompt, ensure your tool registry is the single source of truth. If the registry is stale, incomplete, or manually maintained without automation, the prompt will faithfully enforce a broken contract. Pair this prompt with a Dynamic Tool Registry Refresh Prompt and a Stale Tool Registry Detection Prompt to keep the registry current. For high-stakes domains where incorrect tool invocation could cause financial loss, data corruption, or safety incidents, add a human-in-the-loop approval gate before any write operation and log every capability claim for audit. Start by copying the template in the next section, replacing the placeholders with your registry schema and operational constraints, then run the eval suite to verify the agent refuses at least five categories of unregistered capabilities.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and the operational preconditions required before deploying it in a production agent system.

01

Good Fit: Greenfield Agent Framework Development

Use when: You are building the base system prompt for a new agent framework and need a stable, anti-hallucination contract for tool discovery. Guardrail: Pair this prompt with a structured tool registry (JSON Schema or MCP manifest) so the agent always has a ground-truth capability list to reference.

02

Bad Fit: Ad-Hoc Tool Invocation Without a Registry

Avoid when: The agent has no formal tool registry and tools are described inline in user messages. This prompt assumes a pre-populated, structured registry exists at session start. Guardrail: Implement a tool registration step before invoking this system prompt; otherwise, the agent will correctly refuse to claim capabilities it cannot verify.

03

Required Input: Validated Tool Manifest

Risk: Without a complete, validated tool manifest, the prompt's anti-hallucination instructions will cause the agent to refuse all tool use. Guardrail: Run the Tool Manifest Validation Prompt against your registry before session initialization. Reject any manifest with missing required fields or malformed parameter definitions.

04

Required Input: Session-Scoped Capability Snapshot

Risk: If the agent's tool registry changes mid-session, the system prompt becomes stale and the agent may refuse newly added tools or claim deprecated ones. Guardrail: Take a snapshot of the registry at session start and include it in the system prompt context. Use the Dynamic Tool Registry Refresh Prompt for long-running sessions that require mid-session updates.

05

Operational Risk: Silent Capability Refusal in Production

Risk: When the agent correctly refuses to claim unregistered capabilities, users may interpret this as a broken agent rather than correct behavior. Guardrail: Add explicit user-facing refusal language in the system prompt that explains why a capability is unavailable and suggests alternative actions. Log all capability refusals for ops review.

06

Operational Risk: Stale Registry Drift Over Long Sessions

Risk: In long-running agent sessions, tools may be added, removed, or modified on the server side while the agent operates against a frozen snapshot. Guardrail: Implement a periodic registry health check using the MCP Server Health Check and Capability Refresh Prompt. Trigger a controlled session context update when drift is detected, rather than silently continuing with stale capabilities.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A system-level instruction block that governs how an agent discovers, interrogates, and reasons about available tools at session start without hallucinating capabilities.

This system prompt is the first instruction your agent receives, establishing the foundational rules for tool awareness. It constrains the agent to operate strictly within its registered tool set, preventing capability hallucination and ensuring that every action is grounded in an actual, available function. Deploy this prompt before any user context, task instructions, or few-shot examples to create a hard boundary around tool claims.

text
You are a tool-aware agent operating within a managed execution environment. Your primary directive is to accomplish user goals using only the tools explicitly registered in your active tool manifest. You must never claim, imply, or attempt to use a capability that is not present in that manifest.

## Core Directives
- At session start, you will receive a [TOOL_MANIFEST] containing every available tool, its description, input schema, and output contract. This is your sole source of truth for capabilities.
- Before responding to any user request, internally map the request to the tools in [TOOL_MANIFEST]. If no tool matches, respond with: "I don't have a tool registered to [ACTION]. My available capabilities are: [CAPABILITY_SUMMARY]."
- If a tool's description or schema is ambiguous, you may ask exactly one clarification question before proceeding. Do not guess parameter meanings or default values.
- When you invoke a tool, you must format the call according to [TOOL_CALL_FORMAT] and include only parameters defined in the tool's input schema.
- After receiving a tool's output, validate it against the expected output schema before using the result. If validation fails, report the mismatch to the user and do not fabricate data.
- You must maintain an internal [CAPABILITY_STATE] that tracks: confirmed capabilities (from manifest), discovered constraints (from tool responses), and explicit gaps (capabilities you know you lack). Update this state after every tool interaction.
- If a tool call fails with an error defined in [ERROR_CONTRACT], follow the specified retry or fallback logic. Do not invent recovery steps.
- You operate under a [RISK_LEVEL] policy. For [RISK_LEVEL]=HIGH, you must request human approval before any tool invocation that modifies external state. For [RISK_LEVEL]=MEDIUM, log the intended action before proceeding. For [RISK_LEVEL]=LOW, proceed autonomously but report outcomes.
- At the end of every turn, if your [CAPABILITY_STATE] changed, emit a structured [CAPABILITY_DIFF] summarizing additions, removals, or constraint updates.

## Anti-Hallucination Rules
- Never say "I can" or "I will" followed by an action unless the exact tool exists in [TOOL_MANIFEST].
- If a user asks for a capability you lack, refuse clearly and offer the closest available alternative, if any.
- Do not extrapolate tool behavior from similar-sounding names. A tool named `search_docs` does not imply `search_code` exists.

## Inputs
- [TOOL_MANIFEST]: JSON array of tool definitions with name, description, input_schema, output_schema, error_contract.
- [TOOL_CALL_FORMAT]: The required function-calling format (e.g., OpenAI tool_choice, Anthropic tool_use block).
- [RISK_LEVEL]: One of LOW, MEDIUM, HIGH.
- [ERROR_CONTRACT]: Standard error codes and their prescribed handling.

## Outputs
- [CAPABILITY_SUMMARY]: A concise, user-facing list of what you can do.
- [CAPABILITY_DIFF]: A structured record of capability state changes after each turn.

To adapt this template, replace each square-bracket placeholder with your runtime configuration. The [TOOL_MANIFEST] should be injected dynamically at session start from your tool registry or MCP server introspection. The [TOOL_CALL_FORMAT] must match your model's function-calling API exactly—mismatches here cause silent parsing failures. The [RISK_LEVEL] should be set per deployment context, not per request. The [ERROR_CONTRACT] should map to your actual tool error responses; generic error handling produces generic failures. After deployment, monitor the [CAPABILITY_DIFF] output to detect registry drift and stale manifests before they cause production incidents.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be replaced before the prompt is injected into the agent's system instructions. Validation notes describe what the harness should check before sending.

PlaceholderPurposeExampleValidation Notes

[TOOL_REGISTRY_SOURCE]

Specifies where the agent should look for available tools at session start

mcp://internal-tools.local:8080

Must be a valid URI. Harness should resolve the endpoint and confirm a 200 response before prompt injection. Null not allowed.

[REGISTRY_REFRESH_POLICY]

Defines how often the agent should re-query the tool registry during a session

on_session_start

Must be one of: on_session_start, on_tool_failure, every_n_turns:integer, or never. Harness should reject unknown values.

[MAX_TOOLS_PER_CALL]

Hard limit on the number of tools the agent can invoke in a single response

5

Must be a positive integer. Harness should enforce this limit at the tool-call parsing layer and reject responses exceeding it.

[CAPABILITY_CONFIDENCE_THRESHOLD]

Minimum confidence score required before the agent claims a tool capability exists

0.85

Must be a float between 0.0 and 1.0. Harness should suppress capability claims below this threshold and trigger a registry re-check.

[UNKNOWN_TOOL_BEHAVIOR]

Instruction for how the agent should respond when a user requests an unregistered capability

state_missing_and_offer_alternatives

Must be one of: state_missing_and_stop, state_missing_and_offer_alternatives, or escalate_to_human. Harness should validate against allowed enum.

[STALENESS_TIMEOUT_SECONDS]

Maximum age of cached registry data before the agent must refresh

300

Must be a positive integer. Harness should track last-refresh timestamp and force a re-fetch if elapsed time exceeds this value.

[TOOL_NAMESPACE_PREFIX]

Optional prefix applied to all tool names to prevent cross-registry collisions

prod_us_east_1

Must match regex ^[a-z][a-z0-9_]{0,31}$ if provided. Null allowed for single-registry deployments. Harness should prepend to all tool names before registration.

[HALLUCINATION_GUARD_LEVEL]

Controls how aggressively the agent is constrained from inventing tool capabilities

strict

Must be one of: strict, moderate, or lenient. Strict mode appends explicit refusal language to every capability claim. Harness should inject corresponding guard instructions into the system prompt.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Agent Tool Discovery System Prompt into an application harness with validation, enforcement, and observability.

This prompt is designed to be the first system message in your agent's instruction stack. The harness is responsible for injecting it at session start, parsing the capability summary output, and enforcing the behavioral constraints at the application layer. Do not rely on the prompt alone to prevent capability hallucination—the harness must validate claims against the actual tool registry before any tool call is dispatched.

At session initialization, the harness should: (1) assemble the current tool registry snapshot with tool names, descriptions, parameter schemas, and endpoint status; (2) inject the registry into the [TOOL_REGISTRY] placeholder; (3) send the system prompt as the first message; and (4) parse the agent's capability summary response into a structured object with fields for confirmed_capabilities, explicit_gaps, and confidence_scores. Before any subsequent tool call, validate that the requested tool name and parameters exist in the live registry. If the agent attempts to call a tool not present in the registry, block the call and inject a correction message: 'Tool [NAME] is not registered. Available tools: [LIST]. Re-plan using only registered tools.' This is not a suggestion—it is the primary defense against capability hallucination in production.

For observability, log every capability summary generation event with the registry snapshot hash, the raw summary output, and any validation failures. Set up an eval that compares the agent's claimed capabilities against the registry ground truth at session start, flagging any hallucinated capabilities with a capability_hallucination_rate metric. If this rate exceeds zero in production, the prompt needs hardening or the registry injection format needs debugging. For multi-turn sessions, re-inject the system prompt and registry snapshot whenever the tool set changes due to dynamic registration, deprecation, or health-check-driven removal. Do not assume the agent remembers its capability boundaries across turns—context windows drift, and tool state changes are invisible to the model unless explicitly re-stated.

Model choice matters here. Smaller or older models are more likely to hallucinate capabilities even with a well-structured registry injection. Test across your candidate models with a fixed registry and a set of capability-probing questions like 'Can you delete production databases?' or 'Can you send emails on my behalf?' If the model claims capabilities not in the registry, either switch to a more instruction-following model or add explicit negative examples to the prompt showing the correct refusal pattern. For high-risk deployments where tool calls can cause irreversible damage, add a human approval gate that intercepts any tool call not previously seen in testing, regardless of registry validation.

IMPLEMENTATION TABLE

Expected Output Contract

The agent must produce a structured JSON capability summary. Validate this output against the original registry before allowing any tool invocations. Each field below maps to a required element in the agent's discovery response.

Field or ElementType or FormatRequiredValidation Rule

available_tools

Array of objects

Must be a non-empty array. Each element must have a tool_name and capability_summary field.

available_tools[].tool_name

String

Must exactly match a registered tool name from the active registry. Case-sensitive match required.

available_tools[].capability_summary

String

Must be a non-empty string between 10 and 200 characters. Cannot contain hallucinated capabilities not present in the tool's registered schema.

available_tools[].parameters

Array of strings

Must list only parameter names that exist in the tool's registered input schema. Empty array allowed if tool takes no parameters.

available_tools[].confidence

String enum

Must be one of: confirmed, inferred, uncertain. confirmed requires exact registry match. inferred requires documented basis. uncertain requires explicit caveat in capability_summary.

unavailable_capabilities

Array of strings

Must list capabilities the agent was asked about but cannot perform. Each entry must reference a specific capability, not a vague category. Empty array allowed.

registry_version

String

Must match the version identifier of the active tool registry. Used to detect stale discovery responses.

discovery_timestamp

ISO 8601 string

Must be a valid ISO 8601 timestamp within 5 minutes of the current system time. Stale timestamps trigger re-discovery.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when agents discover tools at runtime and how to prevent capability hallucination, stale registries, and silent failures.

01

Capability Hallucination

What to watch: Agent claims it can perform actions not present in the tool registry, often by inferring capabilities from tool names or general world knowledge. Guardrail: Include explicit anti-hallucination instructions in the system prompt that constrain the agent to only claim capabilities explicitly listed in the provided tool manifest, with mandatory refusal language for unregistered actions.

02

Stale Registry Blindness

What to watch: Agent operates against a cached tool registry while the live server has added, removed, or modified endpoints, leading to failed calls or missed capabilities. Guardrail: Implement a registry freshness check at session start that compares timestamps or capability fingerprints against the live server, and force a refresh when drift exceeds a configured threshold.

03

Schema Mismatch Cascades

What to watch: Tool parameter schemas change between registration and invocation, causing silent argument errors that the agent interprets as tool unavailability rather than schema drift. Guardrail: Validate argument schemas against the current tool contract before each call, and surface schema mismatch errors to the agent with explicit remediation instructions rather than generic failure messages.

04

Namespace Collision Confusion

What to watch: Multiple tools share identical or similar names across different servers or vendors, causing the agent to select the wrong tool or merge capabilities from incompatible sources. Guardrail: Require fully qualified tool references with namespace prefixes in the discovery manifest, and add disambiguation logic that compares parameter schemas when collisions are detected.

05

Over-Permission from Sparse Descriptions

What to watch: Agent infers broader capabilities than intended from vague or incomplete tool descriptions, leading to unsafe tool usage or data exposure. Guardrail: Enrich sparse tool descriptions with explicit constraints, required permissions, and negative capability statements during registration, and flag tools with low description confidence scores for human review before agent access.

06

Silent Tool Removal Drift

What to watch: A previously available tool is removed from the server but the agent continues attempting calls, wasting resources and degrading user trust through repeated failures. Guardrail: Implement a health check loop that verifies tool endpoint availability at session start and periodically during long-running sessions, with automatic registry pruning and agent notification when tools become unreachable.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of known tool registries before deploying any changes to this system prompt. Each check should be automated in your CI pipeline.

CriterionPass StandardFailure SignalTest Method

Schema Completeness

All required fields (name, description, input_schema) are present for every tool in the output

Missing required field in any tool entry

JSON Schema validation against the expected output contract; assert zero validation errors

No Hallucinated Tools

Every tool name in the output matches a tool name in the golden registry exactly

Tool name present in output but absent from golden registry

Set comparison: output tool names must be a subset of golden tool names; assert symmetric difference is empty

No Hallucinated Parameters

Every parameter in every tool's input_schema matches a parameter in the golden registry for that tool

Parameter present in output but absent from golden registry for the same tool

Per-tool parameter set comparison; assert no extra parameters beyond golden set

Parameter Type Accuracy

Every parameter type in the output matches the golden registry type exactly

Type mismatch for any parameter (e.g., string vs integer)

Deep equality check on parameter types per tool; assert zero mismatches

Required Parameter Flagging

All parameters marked required in the golden registry are marked required in the output

Required parameter in golden registry is missing or marked optional in output

Per-tool required-parameter set comparison; assert golden required set is subset of output required set

Description Grounding

Every tool description in the output contains only claims derivable from the golden registry description

Description contains capability claim not present in golden registry

Semantic entailment check using a second LLM judge; assert no ungrounded claims

Confidence Score Validity

Confidence scores are present, between 0.0 and 1.0, and scores below 0.9 correlate with actual missing or ambiguous golden data

Confidence score missing, out of range, or high confidence on a tool with incomplete golden data

Range check on all scores; spot-check low-confidence entries against golden data completeness

Refusal for Unknown Tools

When the input contains no recognizable tool references, the output contains an explicit refusal and claims zero capabilities

Output invents tools or capabilities when input has no valid tool references

Test with empty or garbage input; assert output contains refusal language and empty tool list

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add a structured discovery step that queries a live registry endpoint. Require the agent to parse the response into an internal capability map before any task execution. Include schema validation of the registry response, retry logic for failed discovery, and a staleness check against a last_updated timestamp.

Prompt snippet

code
At session start, call `list_tools` to retrieve your current tool registry. Validate that the response contains `tools[]` with `name`, `description`, `parameters_schema`, and `endpoint` fields. If validation fails or the registry timestamp is older than [MAX_STALENESS_SECONDS], retry up to [RETRY_COUNT] times before reporting degraded status.

After successful discovery, build an internal capability map. You may ONLY use tools present in this map. If a user requests a capability not in your map, respond: "I don't have access to [CAPABILITY]. My available capabilities are: [CAPABILITY_SUMMARY]."

Watch for

  • Registry endpoint downtime causing session-start failures
  • Partial registry responses where some tools are missing
  • Schema changes in the registry response breaking your parser
  • Race conditions if tools are updated mid-session
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.