Inferensys

Prompt

Required vs Optional Field Decision Prompt

A practical prompt playbook for using Required vs Optional Field Decision Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Required vs Optional Field Decision Prompt.

This playbook is for API designers and platform engineers who are authoring tool schemas and need to decide which parameters must be required versus optional with safe defaults. The core job is to produce a field-by-field classification rationale and a schema that minimizes argument generation errors in production. You should use this prompt when you have a tool definition with multiple parameters and you need a systematic, documented decision for each field's required/optional status before the schema is published to a model.

The ideal user is someone who understands the tool's business logic but needs help applying consistent rules for required fields, default values, and missing-argument behavior. Required context includes the tool's purpose, the full parameter list with types, the operational constraints (e.g., idempotency requirements, side effects, permission scopes), and any existing user-facing documentation. Without this context, the prompt will produce generic classifications that don't account for the tool's real failure modes.

Do not use this prompt when the tool schema is still in early exploration, when parameter semantics are undefined, or when you need runtime argument validation logic rather than schema design decisions. This prompt is also inappropriate for tools that have no optional parameters or for schemas where all fields are already locked by an external contract. In those cases, use the Parameter Schema Design Prompt Template or the Tool Call Validation and Pre-Execution Guardrails playbook instead.

The output of this prompt is a structured classification document, not executable code. You will need to translate the rationale into your actual JSON Schema, OpenAPI definition, or model-specific tool format. Before shipping, validate the schema against the test cases this prompt produces for missing-argument behavior and over-eager defaulting. If the tool has write side effects, require human review of the final schema before deployment.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Required vs Optional Field Decision Prompt works well, where it fails, and the operational preconditions for safe use.

01

Good Fit: Greenfield API Design

Use when: designing a new tool or API endpoint where you control the schema from scratch. The prompt excels at reasoning about safe defaults and user experience trade-offs before any code is written. Guardrail: always pair the output with a manual review of business-critical fields that carry compliance or financial weight.

02

Bad Fit: Legacy Schema Migration

Avoid when: retrofitting an existing API with thousands of live consumers. The prompt may recommend breaking changes that are technically correct but operationally dangerous. Guardrail: use the prompt only for a new internal tool version, then run a separate diff-and-migration-impact prompt before deprecating any field.

03

Required Input: Complete Parameter Catalog

Risk: the prompt cannot classify fields it does not know about. If you omit parameters, the model will not flag them as missing. Guardrail: provide an exhaustive list of every parameter, its current type, and its current required/optional status. Validate the output against your source catalog before accepting any classification.

04

Required Input: Downstream Consumer Context

Risk: the model may mark a field as optional with a sensible default, but a downstream system may break if that field is absent. Guardrail: include a brief description of each consumer system and its tolerance for missing fields. If a consumer is intolerant, instruct the prompt to treat that field as effectively required.

05

Operational Risk: Over-Eager Defaulting

Risk: the model may assign a default value that is safe in 90% of cases but silently destructive in the remaining 10% (e.g., a default timeout_ms: 5000 that kills long-running legitimate requests). Guardrail: require the prompt to output a default_risk annotation for every optional field, flagging any default that could cause data loss, timeout, or incorrect state.

06

Operational Risk: Missing Test Cases

Risk: a classification decision may look correct on paper but fail when the tool is called with missing arguments in production. Guardrail: the prompt output must include explicit test cases for each optional field: one with the field present, one with it absent, and one with an edge-case value. Run these tests in a sandbox before deployment.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for classifying API parameters as required or optional with safe defaults.

This template is designed to be copied directly into your prompt management system or codebase. It instructs the model to analyze a set of API parameters and produce a structured classification rationale, a recommended schema, and a set of test cases. The prompt uses square-bracket placeholders for all dynamic inputs, making it safe to template and reuse across different API endpoints and services. Before using it, ensure you have a clear list of parameters, their current types, and the business context for the operation they perform.

text
You are an API design analyst. Your task is to review a list of parameters for a given API operation and classify each as REQUIRED or OPTIONAL. For optional parameters, you must also propose a safe default value.

## INPUT PARAMETERS
[PARAMETER_LIST]

## BUSINESS CONTEXT
[OPERATION_CONTEXT]

## CONSTRAINTS
- A parameter should be REQUIRED if the operation cannot complete meaningfully or safely without it.
- A parameter should be OPTIONAL if a safe, sensible default exists that preserves the operation's intent.
- Defaults must never trigger a destructive action, send a notification, or mutate state in a way the user did not explicitly request.
- Prefer defaults that result in a no-op or the most common, least-privileged behavior.

## OUTPUT_SCHEMA
Return a valid JSON object with the following structure:
{
  "classifications": [
    {
      "parameter_name": "string",
      "classification": "REQUIRED | OPTIONAL",
      "rationale": "string",
      "proposed_default": "any | null",
      "risk_notes": "string | null"
    }
  ],
  "test_cases": [
    {
      "scenario": "string (e.g., 'All optional fields omitted')",
      "provided_args": {},
      "expected_behavior": "string",
      "failure_mode": "string"
    }
  ]
}

## RISK_LEVEL
[RISK_LEVEL]

If RISK_LEVEL is "HIGH", flag any parameter whose misclassification could cause data loss, a security incident, or a compliance violation. For these parameters, add a `requires_human_review: true` field to the classification object.

To adapt this template, replace the placeholders with your specific data. [PARAMETER_LIST] should be a structured list, such as a markdown table or JSON array, containing each parameter's name, current type, and a brief description. [OPERATION_CONTEXT] is a natural language description of what the API does and who uses it. [RISK_LEVEL] should be set to "LOW", "MEDIUM", or "HIGH" to control the strictness of the review. For high-risk operations, the generated output will flag items for human review, which you must enforce in your deployment pipeline before the schema is finalized. The next step is to take the generated test cases and turn them into automated integration tests in your harness.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the Required vs Optional Field Decision Prompt needs to produce a reliable field classification and schema. Provide these variables when calling the prompt.

PlaceholderPurposeExampleValidation Notes

[TOOL_NAME]

Identifies the tool or function being analyzed

create_customer_record

Must be a non-empty string matching the tool's canonical name

[TOOL_PURPOSE]

Describes what the tool does and its primary use case

Creates a new customer profile in the CRM after lead qualification

Must be a complete sentence; avoid single-word descriptions

[PARAMETER_LIST]

Full list of all parameters with their current types and descriptions

[{"name": "email", "type": "string", "description": "Customer email address"}]

Must be valid JSON array; each object requires name, type, and description fields

[SIDE_EFFECTS]

Describes what happens when this tool executes successfully

Writes a new record to the customers table and triggers a welcome email

Must explicitly state whether the tool is read-only or write; null allowed if unknown

[FAILURE_MODES]

Known ways this tool can fail or produce errors

Duplicate email rejection, invalid domain format, rate limit exceeded

Must be a non-empty array of strings; use null only if genuinely unknown

[AUTH_CONTEXT]

Describes the permission scope and user context for tool execution

Requires customer:write scope; executes as the authenticated user

Must specify required scopes or permissions; null allowed for unauthenticated tools

[CONSTRAINTS]

Business rules, regulatory requirements, or system limits

Email must be unique per tenant; phone number required for enterprise tier

Must be a non-empty array of strings; each constraint must be a complete rule statement

[EXISTING_DEFAULTS]

Current default values already assigned to optional parameters

{"tier": "standard", "send_welcome_email": true}

Must be valid JSON object mapping parameter names to their current defaults; null if no defaults exist

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Required vs Optional Field Decision Prompt into an API design workflow or CI pipeline.

This prompt is designed to be called programmatically, not just used in a chat interface. The primary integration point is a function that takes a raw API endpoint specification (OpenAPI fragment, JSON Schema, or a structured list of parameters) and returns a classification rationale plus an updated schema. The harness should validate the output against a strict JSON Schema before accepting it, because a malformed classification can silently break downstream code generation or documentation. Treat the model output as a proposal that requires deterministic validation, not as a final artifact.

The implementation should follow a three-stage pipeline: pre-processing, model invocation, and post-validation. In pre-processing, extract the parameter list from the source spec and normalize it into the [PARAMETER_LIST] format the prompt expects. This means each parameter must have a name, type, current_required boolean, and a description. If the source spec lacks descriptions, flag them as missing rather than guessing. During model invocation, use a low-temperature setting (0.0–0.2) because classification tasks benefit from deterministic behavior. Set response_format to JSON mode if the provider supports it, and always include a max_tokens ceiling to prevent runaway outputs. For high-throughput API reviews, batch multiple endpoints into separate calls rather than cramming them into one prompt, which reduces hallucination risk.

Post-validation is the critical safety layer. Validate the model output against a schema that requires: (1) every input parameter appears in the output with a required boolean and a default_value (or explicit null), (2) the rationale field is present and non-empty for each parameter, (3) no new parameters are invented, and (4) required fields do not have defaults that would mask missing-input errors in production. If validation fails, retry once with the validation error message appended to the prompt as feedback. If the second attempt also fails, log the failure and route the endpoint for human review. For regulated or safety-critical APIs, always require human approval on the final classification before it reaches a production schema. Log every classification decision with the model version, timestamp, and validator result so that audit trails exist for governance reviews.

Model choice matters here. Smaller, faster models (like GPT-4o-mini or Claude Haiku) handle this classification task well when the parameter list is under 20 fields and descriptions are clear. Switch to a frontier model when the API has nested objects, polymorphic types, or parameters with complex interdependencies where a wrong default could cause data loss. Avoid using this prompt on endpoints with more than 50 parameters in a single call; split them into logical groups first. The harness should also track cost: if you are reviewing thousands of endpoints, cache results keyed by a hash of the parameter list to avoid redundant model calls when the same schema appears across multiple endpoints.

IMPLEMENTATION TABLE

Expected Output Contract

The expected JSON output contract for the Required vs Optional Field Decision Prompt. Use this schema to validate the model's response before applying the field classifications to your API schema.

Field or ElementType or FormatRequiredValidation Rule

field_classifications

array of objects

Must contain at least one object. Each object must have the keys 'parameter_name', 'classification', and 'rationale'.

field_classifications[].parameter_name

string

Must exactly match a parameter name from [TOOL_SCHEMA_INPUT]. Non-empty.

field_classifications[].classification

string

Must be one of: 'required', 'optional_with_default', 'optional_without_default'. No other values allowed.

field_classifications[].rationale

string

Must be a non-empty string explaining the classification decision. Should reference the parameter's purpose or failure mode.

field_classifications[].suggested_default

string, number, boolean, null

Required if classification is 'optional_with_default'. Must be a valid default value for the parameter's type. Null allowed only if explicitly justified.

updated_schema

object

Must be a valid JSON Schema object representing the input schema with 'required' array and 'properties' defaults updated per the classifications.

test_cases

array of objects

Must contain at least 3 test cases. Each object must have 'scenario', 'provided_args', and 'expected_behavior' keys.

test_cases[].scenario

string

Non-empty string describing the test scenario, e.g., 'Missing required field' or 'All optional fields omitted'.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when models decide required vs. optional fields and how to guard against it.

01

Over-Eager Defaulting

What to watch: The model supplies a 'safe' default for a missing required field instead of asking for it, masking missing data. Guardrail: Add an explicit instruction: 'If a required field is missing, return a clarification request. Never invent values for required fields.' Validate output with a schema check that rejects non-null defaults for required fields.

02

Required Field Hallucination

What to watch: The model treats an optional field as required and refuses to proceed or fabricates a value when the user omits it. Guardrail: Include a 'requiredness rationale' in the prompt that explicitly lists which fields are optional and states: 'Do not require or ask for optional fields.' Test with sparse inputs missing each optional field.

03

Schema Drift Under Ambiguity

What to watch: When the user's request is vague, the model guesses which fields are required based on conversational context rather than the schema, leading to inconsistent enforcement. Guardrail: Anchor the prompt with a static, inline schema block. Add: 'Use only the schema below to determine required fields. Ignore conversational cues about importance.'

04

Silent Null Bypass

What to watch: The model passes null or an empty string for a required field to satisfy the call format, causing a downstream validation error or a silent write with missing data. Guardrail: Implement a pre-execution validation layer that rejects tool calls with null or empty required fields before they reach the API. Log the rejection for review.

05

Context Window Truncation of Schema

What to watch: In long conversations, the tool schema scrolls out of the context window, and the model reverts to guessing which fields are required based on name alone. Guardrail: For stateful sessions, re-inject the full tool schema (or a compressed required-field summary) in the last message before the tool call. Monitor for schema omission in traces.

06

Misinterpreting 'Optional' as 'Ignore'

What to watch: The model skips an optional field that provides critical context, degrading the quality of the tool's output without technically failing. Guardrail: Annotate optional fields with their operational impact: 'Optional but recommended for accuracy.' Add an eval that measures output quality when optional context is omitted vs. included.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the model's field classification and schema output before integrating it into your API design workflow. Each criterion targets a specific failure mode in required vs. optional field decisions.

CriterionPass StandardFailure SignalTest Method

Required Field Justification

Every field marked as required includes a concrete rationale tied to API contract integrity, data integrity, or downstream processing needs.

Required fields are justified with vague language like 'important' or 'should be present' without a specific failure scenario.

Parse the rationale text for each required field. Check for the presence of a concrete consequence of omission (e.g., 'write will fail', 'record becomes unqueryable').

Optional Field Default Safety

Every optional field with a default value includes a statement confirming the default is side-effect-free and does not mask a required semantic.

A default value is provided that silently writes data, triggers a notification, or changes state in a way that differs from the field being absent.

For each default value, trace the described behavior. Flag any default that performs an action beyond setting a passive data field.

Missing-Argument Test Case Coverage

The output includes at least one test case per required field demonstrating the expected behavior when the field is omitted from a tool call.

Test cases only cover the happy path with all fields present, or only cover a subset of required fields.

Count the number of required fields and the number of missing-argument test cases. Fail if the counts do not match.

Over-Eager Defaulting Detection

The schema explicitly identifies fields where a default value could cause the model to skip necessary clarification and provides a null-default or no-default strategy.

A boolean or enum field has a default that represents a common case, but the schema does not warn that the model may incorrectly apply it when the user intent is ambiguous.

Review the schema for boolean or enum fields with defaults. Check for an accompanying note about clarification risk. Fail if a default exists without a warning.

Schema Validity

The generated JSON Schema passes a standard schema validator and all required fields are listed in the 'required' array.

The schema fails JSON Schema validation, or a field described as required in the rationale is missing from the 'required' array.

Run the output schema through a JSON Schema validator (e.g., ajv). Check for consistency between the rationale list and the 'required' array.

Model Adherence to Classification

When prompted with a missing required field, the model refuses to call the tool and requests the missing information instead of guessing or calling with a placeholder.

The model calls the tool with a hallucinated value, an empty string, or a generic placeholder like 'unknown' for a required field.

Run a test prompt with a required field omitted. Assert that the model response does not contain a tool call and instead asks the user for the missing field.

Business Rule Flagging

Fields constrained by business rules (e.g., date ranges, dependency on another field's value) are identified and the rule is documented in the field description.

A cross-field validation rule exists but is not documented in the schema, leaving the model unaware of the constraint.

Review the original API documentation for cross-field rules. Check if each rule appears in the description of at least one of the involved fields.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a simplified output schema. Drop the [TEST_CASES] block and ask for a plain markdown table with columns: Field Name, Current State, Recommendation, Rationale. Remove the safe-defaults requirement and focus only on classification.

Prompt snippet

code
Classify each parameter in [TOOL_SCHEMA] as REQUIRED or OPTIONAL.
Return a table with columns: Field | Classification | Rationale.

Watch for

  • The model marking everything optional to avoid commitment
  • No distinction between "required for correctness" and "required for safety"
  • Missing rationale when the field is borderline
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.