This prompt is for agent developers who need a model to construct well-formed function call arguments reliably. It uses worked examples to teach correct tool selection, argument typing, optional parameter handling, and error-recovery patterns. Use this when abstract tool descriptions produce inconsistent argument structures, when the model hallucinates parameter names, or when you need to demonstrate the exact JSON schema for each tool call. This prompt belongs in the agent control loop after tool schemas are defined but before execution. It assumes you already have a validated tool registry and need the model to populate call signatures correctly.
Prompt
Tool Call Argument Formatting Demonstration Prompt

When to Use This Prompt
Learn when to deploy the tool call argument formatting demonstration prompt and when to choose a simpler approach.
Deploy this prompt when you observe specific failure modes: the model selects the wrong tool from a multi-tool registry, omits required parameters, invents parameter names not present in the schema, or passes arguments with incorrect types (e.g., a string where an integer is required). It is also appropriate when optional parameters are consistently mishandled—either included when they should be omitted or omitted when the task context clearly requires them. The demonstration format works best when you have 3-8 representative examples covering the most common tool call patterns in your application. Each example should show the full input context, the correct tool selection, and the exact argument payload. Include at least one example where no tool should be called and one where an error-recovery pattern is demonstrated, such as requesting clarification when required information is missing.
Do not use this prompt when a simple schema description in the system message already produces reliable results. If your model consistently generates correct function calls from JSON Schema definitions alone, adding demonstrations adds token cost without benefit. Similarly, avoid this approach when your tool registry changes frequently—maintaining synchronized examples across tool updates creates a maintenance burden that may outweigh the reliability gain. For high-risk domains such as financial transactions or healthcare actions, always pair this prompt with a validation harness that checks argument schemas before execution, and require human approval for write operations. After deploying, monitor for argument hallucination rate and tool selection accuracy as your primary eval metrics.
Use Case Fit
Where the Tool Call Argument Formatting Demonstration Prompt works well and where it introduces risk. Use this to decide if a demonstration-based approach fits your agent architecture.
Good Fit: Multi-Tool Agent Orchestration
Use when: your agent must select among 3+ tools with overlapping or similar-sounding capabilities. Why: few-shot demonstrations teach the model to discriminate between tools by showing correct selection patterns alongside near-miss examples, reducing incorrect tool choice in production.
Good Fit: Complex Argument Schemas
Use when: tool arguments involve nested objects, enums, or conditional required fields that are hard to describe in prose. Why: worked examples of correctly populated schemas outperform verbose field descriptions for teaching structural constraints like 'if type is refund, include payment_id'. Guardrail: validate outputs against the JSON Schema before execution.
Bad Fit: Single Fixed Tool
Avoid when: your agent always calls the same function with a predictable signature. Why: demonstration overhead adds tokens without benefit when the model already knows the tool. A concise system instruction with the JSON Schema is cheaper and easier to maintain.
Bad Fit: Rapidly Changing Tool APIs
Avoid when: your tool signatures change weekly and you cannot regenerate examples automatically. Why: stale demonstrations teach the model to produce arguments that fail validation, causing silent errors or retry storms. Guardrail: implement example drift detection that compares demonstration arguments against the live schema on every deploy.
Required Input: Validated Tool Schemas
Risk: demonstrations that contain argument errors teach the model to reproduce those errors. Guardrail: every demonstration must pass automated validation against the target function's JSON Schema before inclusion. Never hand-write examples without running them through a schema validator.
Operational Risk: Hallucinated Parameters
Risk: the model may invent plausible-sounding parameters that do not exist in the tool schema, especially when demonstrations show rich argument structures. Guardrail: implement a post-generation argument filter that strips any key not present in the tool's declared parameters and logs the removal for review.
Copy-Ready Prompt Template
A copy-ready system prompt that teaches models to construct well-formed tool call arguments through annotated input-output demonstrations, with built-in validation hooks.
This template teaches the model to select the correct tool and populate its arguments accurately by showing worked examples rather than relying solely on abstract tool descriptions. The demonstration block pairs user requests with annotated tool calls, highlighting argument types, optional parameter handling, and error-recovery patterns. Replace the square-bracket placeholders with your actual tool definitions, examples, and validation rules before use.
codeYou are an agent that selects and calls tools based on user requests. You have access to the following tools: [TOOLS] When a user makes a request, you must: 1. Select the most appropriate tool from the available list. 2. Construct a valid function call with correctly typed arguments. 3. Handle optional parameters appropriately—omit them when not needed, include them when specified. 4. If the request is ambiguous or missing required parameters, ask a clarifying question instead of guessing. 5. If no tool matches the request, respond with a plain-text explanation of what you cannot do. Here are examples of correct tool call formatting: [EXAMPLES] Now, respond to the following user request by selecting the correct tool and constructing the appropriate arguments. Output only the function call in valid JSON format matching the tool's parameter schema. User request: [INPUT]
Adaptation notes: Replace [TOOLS] with your actual function definitions in JSON Schema format, including parameter names, types, required fields, and descriptions. Populate [EXAMPLES] with 3-5 annotated input-output pairs showing correct tool selection, argument typing, optional parameter handling, and at least one error-recovery case where the model asks for clarification. The examples should use a consistent delimiter pattern (e.g., ### Example N ### with clear User: and Assistant: role markers) to prevent parsing ambiguity. Before deploying, validate that the prompt produces schema-conformant outputs by running it against a test harness that checks argument types, required field presence, and hallucinated parameter detection. For high-stakes production use, add a post-generation validation layer that rejects calls with unknown parameters or type mismatches before execution.
Prompt Variables
Inputs the prompt needs to work reliably. Validate each before assembly.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TOOL_DEFINITIONS] | JSON schema of available tools, including function names, descriptions, and parameter schemas | {"tools": [{"type": "function", "function": {"name": "search_knowledge_base", "description": "Search internal docs", "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]}}}]} | Parse as JSON; confirm each tool has name, description, and parameters object; reject if any required field missing |
[USER_QUERY] | The natural language request that should trigger a tool call or direct response | Find the latest product roadmap for Q3 and summarize the key milestones | Non-empty string; check for injection patterns like tool call syntax embedded in user text; log if query length exceeds 2000 chars |
[POSITIVE_EXAMPLES] | Correct tool call argument formatting examples showing proper tool selection and parameter typing | User: What is our refund policy? Assistant: {"tool": "search_knowledge_base", "arguments": {"query": "refund policy"}} | Parse each example as valid JSON tool call; confirm tool name matches [TOOL_DEFINITIONS]; confirm all required parameters present; confirm parameter types match schema |
[NEGATIVE_EXAMPLES] | Incorrect tool call examples showing wrong tool selection, missing required params, or hallucinated parameters | User: What is our refund policy? Assistant: {"tool": "delete_database", "arguments": {}} | Parse each example; confirm it violates schema intentionally; verify negative example does not match any positive example pattern; check that refusal or correction follows |
[OPTIONAL_PARAMETER_EXAMPLES] | Demonstrations showing correct handling of optional parameters, including when to include vs omit them | User: Search docs for onboarding, limit to 5 results Assistant: {"tool": "search_knowledge_base", "arguments": {"query": "onboarding", "limit": 5}} | Confirm optional parameters are only included when user explicitly requests them; verify type matches schema; check that omitted optional params do not cause validation errors |
[ERROR_RECOVERY_EXAMPLES] | Demonstrations showing how to recover from invalid tool calls, missing arguments, or schema violations | User: Find pricing Assistant: {"tool": "search_knowledge_base", "arguments": {}} System: Error: missing required parameter 'query' Assistant: {"tool": "search_knowledge_base", "arguments": {"query": "pricing"}} | Confirm error recovery example includes: invalid call, error message, corrected call; verify corrected call passes schema validation; check that recovery does not hallucinate new parameters |
[OUTPUT_SCHEMA] | Expected JSON structure for tool call arguments, including required fields, types, and constraints | {"tool": "string", "arguments": "object"} | Validate that output matches this schema; check for extra top-level fields; confirm arguments object matches the specific tool's parameter schema from [TOOL_DEFINITIONS] |
[CONSTRAINTS] | Rules for tool selection, argument construction, and when to respond without calling a tool | Only call tools listed in [TOOL_DEFINITIONS]; never invent parameters; if no tool matches, respond with clarification question | Check that constraints are non-empty; verify constraints reference [TOOL_DEFINITIONS] explicitly; confirm refusal conditions are specified |
Implementation Harness Notes
How to wire the tool call argument formatting prompt into an agent control loop with validation, retry, and logging.
This prompt is not a standalone artifact; it is a component inside an agent's tool-use control loop. The prompt's job is to teach the model how to select the correct tool and format its arguments by providing worked examples of valid calls, optional parameter handling, and error-recovery patterns. The surrounding harness must validate the model's output against the actual tool schemas, retry on failure, and log every attempt for debugging and evaluation. Without this harness, even a well-crafted demonstration prompt will silently produce hallucinated parameter names, type mismatches, or calls to non-existent tools in production.
To integrate this prompt, wrap it in a function that assembles the full model request: system instructions, the demonstration prompt with [TOOLS] and [EXAMPLES] placeholders populated from your live tool registry, and the current user [INPUT]. After receiving the model's response, parse the proposed tool call and validate it against the JSON Schema for the selected tool. Check that all required parameters are present, no extra parameters are hallucinated, and all types match. If validation fails, construct a retry prompt that includes the original request, the invalid output, and the specific validation error message. Limit retries to a fixed number (typically 2-3) before escalating to a human or falling back to a safe default. Log every attempt—including the raw model output, validation result, and retry count—to your observability platform for trace analysis and prompt debugging.
For high-stakes tool calls such as database writes, financial transactions, or customer-facing actions, insert a human approval step after successful validation but before execution. Present the validated tool call arguments in a review UI with a clear summary of the action and its parameters. Do not execute the tool until approval is received. For lower-risk read-only operations, you can skip the approval gate but should still log the call for audit purposes. Avoid wiring this prompt directly to tool execution without validation; the demonstration format teaches the model the pattern, but it does not guarantee correctness on every invocation.
Expected Output Contract
Validate the model's response against this contract before passing arguments to any downstream tool or function. Any deviation should trigger a retry or repair workflow.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
tool_name | string | Must exactly match one of the available tool names provided in the system prompt. Case-sensitive. | |
arguments | object | Must be a valid JSON object. Parse check required. No trailing commas, no unquoted keys. | |
arguments.[PARAMETER_NAME] | per tool schema | per tool schema | Each key must correspond to a parameter defined in the selected tool's schema. No hallucinated parameters allowed. |
arguments.[PARAMETER_NAME] type | per tool schema | per tool schema | Value type must match the schema definition (string, number, boolean, object, array, null). Type coercion is a failure. |
arguments.required_params | per tool schema | All parameters marked as required in the tool schema must be present and non-null. Missing required params is a hard failure. | |
arguments.optional_params | per tool schema | Optional parameters may be omitted or null. Null is allowed only if the schema permits it. Unexpected nulls on required fields are a failure. | |
reasoning | string or null | If present, must be a string. Not passed to the tool. Used only for traceability. Null is acceptable. |
Common Failure Modes
When using demonstrations to teach tool call argument formatting, these failure modes appear most often in production. Each card identifies a specific risk and a concrete guardrail you can implement before deployment.
Argument Hallucination from Missing Examples
What to watch: The model invents parameter names, types, or enum values that don't exist in your tool schema when the demonstrations don't cover all argument combinations. This is especially common with optional parameters that appear in some examples but not others. Guardrail: Validate all generated arguments against the tool's JSON Schema before execution. Reject calls with unknown parameters and include a schema-annotated negative example showing the rejection pattern.
Tool Selection Drift Under Ambiguous Inputs
What to watch: When user requests could map to multiple tools, the model defaults to the tool that appears most frequently in demonstrations rather than the semantically correct one. Example frequency overrides intent matching. Guardrail: Include at least one demonstration showing ambiguous input with explicit tool selection reasoning. Add a pre-execution check that compares the selected tool against a lightweight intent classifier or keyword guard.
Optional Parameter Omission or Over-Inclusion
What to watch: The model either skips required optional parameters when they're contextually necessary or fills every optional field with placeholder values, bloating payloads and triggering downstream validation errors. Guardrail: Provide demonstrations that show both paths: one where optional parameters are omitted and one where they're populated with real values. Add a post-generation check that flags placeholder strings like 'string' or 'null' in typed fields.
Type Coercion and Format Drift
What to watch: The model outputs integers as strings, dates in wrong formats, or booleans as 'yes'/'no' strings, especially when demonstrations use inconsistent formatting. A single malformed example poisons the entire pattern. Guardrail: Enforce strict type checking in your argument validation harness. Include at least one demonstration showing a type error being caught and corrected. Run schema conformance tests across all demonstrations before deployment.
Error Recovery Pattern Collapse
What to watch: When a tool call fails, the model either retries with the same malformed arguments or abandons the tool entirely instead of attempting a corrected call. Demonstrations that only show success paths don't teach recovery behavior. Guardrail: Include explicit error-recovery demonstrations showing: failed call, error message, corrected call, success. Test recovery by injecting deliberate schema violations and measuring whether the model produces a corrected retry or gives up.
Demonstration-Example Overfitting
What to watch: The model memorizes specific argument values from demonstrations and reuses them for unrelated inputs. For example, always setting 'priority' to 'high' because most demonstrations used that value, regardless of the actual request. Guardrail: Vary argument values across demonstrations to show the full range. Add a diversity check that scans your example set for value distribution skew. Include a counterexample showing incorrect value reuse and its correction.
Evaluation Rubric
Run these checks on a golden dataset of 50+ user requests that require tool calls. Each row tests a specific failure mode common in tool-call argument formatting.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Tool Selection Accuracy | Correct tool name selected for >= 95% of requests in golden set | Wrong tool name or hallucinated tool not in [TOOL_LIST] | Exact string match against expected tool name per test case |
Required Argument Completeness | All required arguments present for selected tool in >= 98% of calls | Missing required field in arguments object | Schema validation against tool definition; flag any missing required keys |
Argument Type Conformance | All argument values match declared types (string, number, boolean, array, object) in >= 97% of calls | String where number expected, array where object expected, or null for non-nullable field | TypeScript-style runtime type check against expected schema per argument |
No Hallucinated Parameters | Zero arguments present that are not defined in the target tool schema | Extra key in arguments object not in tool definition | Set difference between actual argument keys and allowed parameter names |
Optional Parameter Handling | Optional parameters omitted when no value provided, included correctly when value present in >= 95% of cases | Optional param included with null or empty string when should be absent, or missing when value available in [INPUT] | Check presence/absence against expected optional param behavior per test case |
Enum Value Adherence | All enum-constrained arguments use only allowed values in >= 99% of calls | Value outside defined enum list or case-mismatched variant | Exact match against allowed enum values from tool schema |
Error Recovery Argument Formatting | When prior call failed, retry arguments correct format and address error message in >= 90% of recovery scenarios | Retry repeats same malformed arguments or introduces new format error | Simulated error injection tests with expected correction pattern per error type |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with 2-3 clean tool-call examples in a single [EXAMPLES] block. Use inline comments to annotate argument types and optional parameters. Skip formal schema validation in the prompt itself—rely on post-hoc JSON parse checks. Keep the system instruction minimal: "You are an agent that selects tools and formats arguments. Follow the examples."
Watch for
- Model inventing parameter names not shown in examples
- Optional parameters being treated as required
- Argument type coercion (string to number, boolean to string) without warning

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us