PUBLIC BETA OFFER

Save 50% off on an Eligible Learning PlanValid for 1-month plan, 3-month plan, 12-month plan · Code LPXBETA50 · Ends Dec 6, 2026

Apply few-shot prompting to improve output consistency and quality

Use contrasting demonstrations to clarify decisions, schemas, and truthful uncertainty.

Build few-shot prompts from verified input/output pairs that preserve secondary concerns, missingness, approximation, and citation relationships. Routing, null-handling, and extraction examples lead into compatible example retrieval and evaluation on held-out cases.

Knowledge domain
Prompt Engineering & Structured Output
Topics & tags
Published
Author
LearningPathX Editorial TeamContent version 1.0
Resources

Apply few-shot prompting to improve output consistency and quality

Learning objectives

Select examples that clarify a decision boundary and an output contract, preserve uncertainty in extraction, and evaluate generalization on cases that were not demonstrations. Use retrieval when a large example collection cannot fit into one prompt.

Teach a rule through contrasting examples

Few-shot prompting supplies a small number of demonstrations in the prompt. It changes the immediate context; it is not a weight update or a guarantee that the model has learned a general rule. Examples help when detailed prose still leaves format, routing, or judgment ambiguous.

Define the task and rules first. Then show representative input/output pairs that conform to those rules. Include a normal case, a plausible alternative that should receive a different decision, and an uncertainty or missing-information case where relevant. Start with a small diverse set and expand only to address observed failures. There is no universally sufficient minimum number of examples.

Keep every demonstration consistent with the schema and policy. An example with extra fields, an invented value, or an incorrect label can teach the wrong behavior more concretely than the accompanying instruction teaches the right behavior.

Demonstrate ambiguous routing without losing concerns

Assume a teaching support policy prioritizes restoring account access when it blocks investigation of another issue. With no access blocker, a charge dispute routes to billing and a request to compare plans routes to sales guidance. This illustrative demonstration uses a concise decision explanation, not a request to expose private reasoning:

{
  "input": "My bill is higher than usual and I cannot log in to view it.",
  "output": {
    "primary_route": "account_access", "intent": "restore_access", "action": "route_to_access_support", "usage": "Restore access first, then retain and revisit billing_dispute.",
    "other_concerns": ["billing_dispute"],
    "decision_basis": "The stated access problem blocks viewing the bill; preserve the billing issue for follow-up.",
    "alternative_not_selected_first": "billing"
  }
}

Two contrasting demonstrations use the same output fields:

{
  "input": "I can sign in and view my bill, but I dispute this month's charge.",
  "output": {
    "primary_route": "billing", "intent": "dispute_charge", "action": "route_to_billing", "usage": "Investigate the stated charge under actual authorized access.",
    "other_concerns": [],
    "decision_basis": "The customer can access the account and disputes a charge; no access blocker is stated.",
    "alternative_not_selected_first": "account_access"
  }
}
{
  "input": "I want to compare plans before deciding whether to upgrade.",
  "output": {
    "primary_route": "sales_guidance", "intent": "compare_plans", "action": "route_to_sales_guidance", "usage": "Offer supported plan information without committing an upgrade.",
    "other_concerns": [],
    "decision_basis": "The request concerns plan suitability, with no disputed charge or access failure stated.",
    "alternative_not_selected_first": "billing"
  }
}

Do not generalize that every multi-issue ticket always belongs to technical support. The policy and dependency determine priority, and the secondary concern must remain visible.

For ambiguous tool selection, provide a case that needs extraction, one that needs summarization, and one where the available evidence cannot verify a claim. Explain the short decision basis and the rejected plausible alternative. If two tool descriptions overlap so much that their boundaries remain unclear, repair the interface definitions rather than adding endless examples.

Make the output contract visible

A code-review demonstration should contain every field the consumer expects. For this teaching contract, the caller can supply None; normalization must preserve it as None and lowercase a supplied string. Assume no caller guard exists. This unguarded implementation violates that contract:

def normalize_email(email):
    return email.lower()

For the teaching location src/parser.py:42, a corresponding expected finding is:

{
  "location": "src/parser.py:42",
  "issue": "A permitted null email is dereferenced by email.lower().",
  "severity": "important",
  "suggested_fix": "Handle a null email before calling string methods and retain the valid-email path."
}

Contrast that defect with an implementation that handles the same allowed inputs:

def normalize_email(email):
    if email is None:
        return None
    return email.lower()

For input None, the first version raises an exception and the second returns None. For "[email protected]", the guarded version returns "[email protected]". The expected review result for the guarded version is no finding under this null-handling rule. These are expected teaching outcomes, not a live model review. The pair demonstrates the criterion instead of teaching the reviewer to flag every use of a string method.

Explain the premises that make a pattern correct. For branch coverage, an existing test of a successful request does not demonstrate the rejection branch. Show a rejected-input case with its expected result, and inspect the actual tests before asserting a coverage gap. Few-shot examples guide judgment; they do not replace reading the code or executing tests.

Extract varied formats while preserving meaning

Examples should vary document layout as well as wording. A methodology can appear under a heading or inside a paragraph. Citations can be inline or listed in a bibliography. Teach the extractor to connect a claim's citation marker to the matching entry, and to distinguish a reference list from evidence that a particular method was used.

For this teaching extraction, retain a numeric weight only when the input states one, normalize the unit label to lb, and preserve whether it is approximate:

Source text Expected weight Expected unit Expected approximate
Weight: 5 lb 5 "lb" false
The box weighs approx 5lbs 5 "lb" true
Weight not recorded null null null

The second row changes spelling, not the measurement or its precision. It must not silently become an exact five kilograms. The third row demonstrates honest missingness instead of copying a value from another example.

Use the same output contract across layouts. Add source location or a short supporting quote when the consumer needs traceability. If a required value is present in an unusual location but the extractor returns null, add a verified example of that layout and retest. If the source genuinely lacks the value, a demonstration must not force a guess.

Handle document structure explicitly

Consider two small source variants:

Source variant Expected extraction
Method: random sampling. Result [7]. References: [7] Study A. Method is random sampling; the result's cited reference is Study A.
We selected participants using random sampling. No references supplied. Method is random sampling; cited reference is missing.

These examples show that an embedded method can be extracted without a dedicated methodology heading. They also show that the presence of a bibliography entry alone does not prove that it supports every claim. Preserve the link actually stated and mark a missing or ambiguous link unresolved.

Retrieve examples when the collection grows

When inputs vary too widely for a small static set, retrieve relevant verified examples from a larger collection. Similarity search is one possible selection method. Keep task compatibility, policy version, and output schema compatibility as selection criteria; lexical or vector similarity alone does not make an example appropriate. The source conceptual sketch is query_vector=embed(user_document) then vector_db.search(query_vector, top_k=3), construct_prompt(similar_examples,user_document) and claude.generate(prompt). Those names are placeholders, not verified supported APIs or an observed retrieval/generation result; top_k=3 is one sketch choice, not a correctness threshold. Inspect selected examples and their actual policy/schema compatibility before injecting them.

Deduplicate retrieved examples and avoid filling the context with near-identical cases. Keep user documents separate from trusted instructions and verified demonstration labels. Retrieval adds a possible failure point: the wrong examples can reinforce a wrong decision. Evaluate the selection stage as well as the final response.

Evaluate generalization and repair failures

Reserve held-out inputs, including new phrasings and layouts, that are not copies of the demonstrations. Check decision accuracy, required fields, unsupported values, and handling of uncertainty. Compare a baseline with the revised prompt using the same evaluation set and labeling rules. Do not treat illustrative accuracy gains from a different task as a promised improvement here. The source troubleshooting recommends comparing claimed success with actual logs/build outputs and cites reported false-confidence, deception and sycophancy symptoms. Treat those as issue-reported observations, without inferring verified intent or current universal model behavior; use the real results to assess the stated code claim.

An output token limit can truncate a response rather than make it concise; detect incomplete outputs. A low temperature can reduce variation but cannot verify facts. Keep a valid empty result, a missing field, and an extraction failure distinguishable in the required schema instead of replacing every outcome with free-form text.

Separate count advice, style evidence and product facts

The original ambiguous-case objective asks for 2–4 targeted demonstrations; the source also suggests 3–5 starter examples while explicitly denying a fixed optimum. Those are contextual recommendations, not API minimums. The three routing cases above have different purposes and boundaries; add cases only for real failures or uncovered conditions.

An invented style-transfer demonstration uses two approved input/output pairs. For the facts “Atlas: CSV export; request a demo,” the approved output is:

Subject: Meet Atlas

Atlas adds CSV export. Request a demo to see the workflow.

For “Beacon: saved filters; contact the team,” the approved output is:

Subject: Meet Beacon

Beacon adds saved filters. Contact the team to learn more.

These pairs teach a short subject, one factual feature sentence and one supplied call to action, not transferable pricing or availability. The new illustrative brief supplies “AcmeAI is an AI-powered CRM with contact summaries; request a demo”; price and availability are not supplied. Its expected draft is:

Subject: Meet AcmeAI

AcmeAI is an AI-powered CRM with contact summaries. Request a demo to learn more.

The accompanying internal factual note is “Price and availability are unprovided; obtain approved values before adding them.” Do not borrow another email's facts or send this draft without actual authorization.

Demonstrate tool and branch decisions

Assume the available conceptual tools are extract_fields(text) for supplied factual fields, summarize_text(text) for concise restatement and verify_claim(claim,source_id) for a supported identified source. For “Give the incident ID from 'Incident R7; cause unconfirmed',” expected extract_fields arguments are {"text":"Incident R7; cause unconfirmed"} and expected output is {"incident_id":"R7","cause":null}. A summary is the plausible alternative but not the requested field transformation. For “Condense that incident statement,” expected summarize_text output is “Incident R7 has no confirmed cause”; extraction is unnecessary. For “Prove the database caused R7” with no accessible supporting source, the expected action is an explicit unresolved evidence request, not a guessed verifier result. These are selection/expected-result examples, not executed calls. An absolute path can identify a file when relevant; it does not authorize access outside the allowed workspace. For a separate invented file-inspection case restricted to /workspace/review, {"file_path":"/workspace/review/src/parser.py"} identifies the intended absolute target; {"file_path":"src/parser.py"} can resolve differently after changing directories and fails that teaching absolute-target contract. The source workbench story motivates checking actual path/argument mistakes; the absolute form still needs real target resolution and permission and does not establish a flawless or executed tool call.

For a branch-gap teaching module, assume parse_count(x) returns {"status":"ok","value":x} when x is an integer >= 0 and otherwise returns {"status":"invalid","value":null}; booleans are not integers under this declared contract. The only existing test asserts parse_count(3)=={"status":"ok","value":3}. That assertion exercises the ordinary accepted path but not the invalid guard. New expected tests are input 0→ok/value0 (boundary), -1→invalid/null (below boundary), "3"→invalid/null (unexpected type) and true→invalid/null (boolean exception). These concrete fixtures show the gap under the displayed existing assertion; they do not prove complete coverage or passing execution in a real project. Explicit None and 1.5 also have expected invalid/null results. Omitting x entirely is different: the displayed Python signature raises a missing-argument TypeError before its body executes. A caller that needs a structured record must catch/map that error under its own declared contract; the function itself does not return an invalid record for an absent argument.

A complete illustrative module and its existing assertion are:

def parse_count(x):
    # Accept nonnegative integers, excluding booleans.
    if type(x) is int and x >= 0:
        return {"status": "ok", "value": x}
    return {"status": "invalid", "value": None}

# Existing assertion:
assert parse_count(3) == {"status": "ok", "value": 3}

# Additional expected assertions, not executed here:
assert parse_count(0) == {"status": "ok", "value": 0}
assert parse_count(-1) == {"status": "invalid", "value": None}
assert parse_count("3") == {"status": "invalid", "value": None}
assert parse_count(True) == {"status": "invalid", "value": None}

The original assertion takes the true branch. The new below-boundary/type cases take the false branch, and zero distinguishes >=0 from a changed >0 guard at example_count.py:3. No passing Python test or live model judgment is claimed.

For the email rule above, None and a normal string demonstrate allowed null versus text. A new held-out variation "[email protected]" should normalize to "[email protected]". An unguarded .lower() implementation may be acceptable when the caller contract excludes null and an actual guard enforces that premise; a None call is then outside the permitted input contract rather than evidence that a permitted input fails; do not flag every .lower() by syntax. Verify those premises before classifying real code.

The three complete routing output records above include intent, action and actual next-use instructions alongside the decision basis and plausible alternative. Account-access handling retains billing for follow-up, billing handling investigates a stated charge, and sales guidance does not commit an upgrade. These are expected handling records: selecting a route does not execute a transfer or grant account-data access.

Keep a moderation policy consistent

Under the original illustrative amusement-forum policy, unrelated content, harmful content and advertisements/self-promotion are BLOCK; on-topic discussion and criticism are ALLOW. “I'm selling weight-loss products; buy from my link” has expected {"category":"BLOCK","reason":"Unrelated advertising"}. “I dislike my local park's operations and service” has expected {"category":"ALLOW","reason":"On-topic criticism without a listed blocking condition"}. The source input “Introducing my new band - Coaster Shredders. Check us out on YouTube!!” has expected {"category":"BLOCK","reason":"Self-promotion under the stated blanket policy"} under this same rule. A later suggestion to allow benign promotion conflicts with that rule unless an authorized policy explicitly introduces a precise exception and all examples are revised together. Do not silently learn an exception from a different label. If policy/context is genuinely ambiguous, use the declared escalation route rather than force a confident label. Undefined prompt/model placeholders are not an executed classifier.

Use complete tool argument examples without manufacturing facts

The following is a complete conceptual custom-tool input contract. Whether a real API accepts input_examples must be checked for that interface. Its structural schema requires title, allows the shown optional fields and forbids unknown properties. An additional declared application rule requires escalation for critical priority. Examples illustrate that rule; they do not enforce it by themselves. Contact information is included only when supplied, even on a critical ticket. All names/IDs/dates below are fictional extraction fixtures, not calculated deadlines. The original source leaves input_schema as a comment placeholder, { /* same schema as above */ }, which is not valid JSON or a complete schema. The contract below is an authored complete teaching replacement. Its three input examples retain the original source fixture fields/values, including critical phone, supplied date and sla_hours; those are source demonstration values, not verified people, contacts or a calculated deadline.

{
  "name": "create_ticket",
  "description": "Prepare a ticket from supplied facts. Do not invent contact data. Critical priority requires the stated escalation fields; validate this application rule before any authorized creation.",
  "input_schema": {
    "type": "object",
    "properties": {
      "title": {"type":"string"},
      "priority": {"type":"string","enum":["normal","critical"]},
      "labels": {"type":"array","items":{"type":"string"}},
      "reporter": {
        "type":"object",
        "properties": {
          "id":{"type":"string"},
          "name":{"type":"string"},
          "contact":{"type":"object","properties":{"email":{"type":"string"},"phone":{"type":"string"}},"additionalProperties":false}
        },
        "additionalProperties":false
      },
      "due_date":{"type":"string","description":"Supplied YYYY-MM-DD date, not a computed deadline."},
      "escalation":{"type":"object","properties":{"level":{"type":"integer","minimum":1},"notify_manager":{"type":"boolean"},"sla_hours":{"type":"integer","minimum":1}},"required":["level","notify_manager"],"additionalProperties":false}
    },
    "required":["title"],
    "additionalProperties":false
  },
  "input_examples": [
    {"title":"Update API documentation"},
    {"title":"Add dark mode support","labels":["feature-request","ui"],"reporter":{"id":"USR-67890","name":"Alex Chen"}},
    {"title":"Login page returns 500 error","priority":"critical","labels":["bug","authentication","production"],"reporter":{"id":"USR-12345","name":"Jane Smith","contact":{"email":"[email protected]","phone":"+1-555-0123"}},"due_date":"2024-11-06","escalation":{"level":2,"notify_manager":true,"sla_hours":4}}
  ]
}

The application rejects critical input with no escalation as {"status":"invalid","field":"escalation","reason":"Required by the declared critical-priority rule"}. Missing contact stays omitted; if policy needs it, request the fact or preserve a blocked preparation state. USR-XXXXX, kebab-case labels and YYYY-MM-DD are teaching conventions. A string schema alone does not validate date syntax, compute a due date, verify identity or authorize creation. Apply the real supported validators and policy separately. For the displayed escalation object, level=1 and level=2 meet its integer minimum; 0, -1, true, null, 1.5 and "2" do not. Missing level or notify_manager fails the required-member check; a nonboolean notify_manager is invalid. Omitting optional escalation is structurally allowed for a noncritical ticket, but critical priority with no escalation fails the separately declared application rule. These are expected schema/application checks, not a real created ticket. Here sla_hours:4 is a supplied illustrative service-window value in hours, not a computed due date or a general four-hour policy. In this declared optional positive-integer field, 4 and 1 are valid, while 0, negative, boolean, null, fractional or numeric-string values are invalid if supplied. Omitting it is structurally allowed by this teaching schema; any real mandatory SLA requirement needs its own stated application rule. No contact, date or escalation value may be copied into a new ticket without supporting source facts.

One additional four-field review demonstration for the branch module is {"location":"example_count.py:3","issue":"A changed >0 guard rejects the allowed zero boundary.","severity":"important","suggested_fix":"Retain the declared >=0 guard while preserving invalid-type rejection."}. The unchanged correct guard has expected {"findings":[]} under this behavioral policy. These add a second coherent finding/no-finding pair to the email example; tool input arguments are a different artifact. No dedicated few-shot CLI toggle is established by the source.

Preserve measurements and document attribution

Declare one measurement policy: retain supplied units, normalize lb spelling to lb, preserve approximation and perform no numeric conversion or rounding. The weight examples above follow that policy. For dimensions, declare length×width×height order explicitly: "Dimensions (LxWxH): 10x20x30 cm" maps to {"length":10,"width":20,"height":30,"unit":"cm","order":"LxWxH","supplied_dimensions":[10,20,30],"status":"assigned"}. If an input merely says "10x20x30 cm" without an established order, the same declared record shape has expected {"length":null,"width":null,"height":null,"unit":"cm","order":null,"supplied_dimensions":[10,20,30],"status":"axis_order_unknown"}. Preserve the supplied triple rather than infer axes from the numbers. Standard/informal "5ft 2in" and "five foot two" both map to {"feet":5,"inches":2,"approximate":false} only when that language/unit interpretation is supplied by the contract. These are expected transformations, not measured extraction outputs.

For layout transformations, use one schema {method, method_quote, cited_reference, citation_quotes, status}. Input A has logical block “Method: random sampling” and result block “Result [7]” plus bibliography block “[7] Study A”; expected output is {"method":"random sampling","method_quote":"Method: random sampling","cited_reference":"Study A","citation_quotes":["Result [7]","[7] Study A"],"status":"supported"}. Input B says “We selected participants using random sampling. No references supplied”; expected output is {"method":"random sampling","method_quote":"We selected participants using random sampling.","cited_reference":null,"citation_quotes":[],"status":"citation_missing"}. A bibliography entry with no linked result marker leaves the result-reference link unresolved. Accurate block titles and finer boundaries help locate evidence but do not prove semantic support; retain cross-block conditions/footnotes. If no supporting quote exists, retract the value or mark unknown. The source >20k quote-first recommendation is a strategy, not a universal token boundary or a reason to omit grounding in shorter texts.

For required-null diagnosis, distinguish source absent, unread/unreadable, ambiguous, present-but-missed and failed extraction. Only when a value is actually present but missed can a relevant mapping example repair that omission; actual rerun comparison is required before a success claim. No schema requirement creates a missing fact.

Preserve response states and consultation guards

For a declared print_entities payload {"entities":[]}, a valid matching tool block with an empty entities list is successful empty data. No block or a wrong-name block is no_matching_call; null/nonobject/missing-array payload is invalid_payload; a populated array is data to validate against source. An empty object is malformed under this schema, although it could be valid under a different explicitly declared schema. Do not use a payload truthiness test to conflate these outcomes. A successful empty tool response could be {"status":"completed","entities":[]}; a denied/unread source needs {"status":"error","code":"ACCESS_DENIED","entities":null,"next_step":"request authorized source access"}, never a successful “No results found” substitute. Those are custom expected fixtures rather than universal tool-result envelopes. The source text-only empty-result example is {"type":"text","text":"No results found."}. Use it only for a genuinely completed empty operation when that actual tool contract permits a text content block; it must not hide transport/authentication/parse failures or replace a required structured error. The original extraction snippet initializes json_entities=None, stores the first matching print_entities block’s input and uses if json_entities. Empty {} or [] is false just like no stored call, whereas {"entities":[]} is a nonempty object and therefore true despite zero entities. Identity, cardinality, shape, error state and actual source data must be checked separately as in the fixtures below.

For this teaching extraction contract, exactly one matching tool block is required. Complete response fixtures and expected parser outcomes are:

Response fixture Expected parser outcome
{"content":[{"type":"tool_use","name":"print_entities","input":{"entities":["R7"]}}]} {"status":"data","entities":["R7"]}; still verify R7 against source
{"content":[{"type":"tool_use","name":"print_entities","input":{"entities":[]}}]} {"status":"empty","entities":[]}
{"content":[{"type":"text","text":"No call"}]} {"status":"no_matching_call","entities":null}
{"content":[{"type":"tool_use","name":"other_tool","input":{"entities":[]}}]} {"status":"no_matching_call","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":{}}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":null}]} {"status":"invalid_payload","entities":null}

Locate blocks by actual type/name, distinguish zero/multiple matches from the one-block contract, validate the object and array shape, and then inspect array length without treating the whole object truthiness as data presence. Multiple matching blocks remain an explicit contract error rather than silently selecting one. The source contents must still support every accepted entity.

The source advisor nudge uses NUDGE_TURN=2, a zero-based check turn==NUDGE_TURN-1 and no previous advisor call, before that assistant turn. Append the reminder as a separate user message after tool results only when genuine uncertainty/complexity warrants consultation and no restraint instruction conflicts. Simple tasks may finish before a later/gated nudge; earlier consultation skips it. If existing restraint language conflicts, skip the nudge entirely. A reminder neither invokes an advisor nor grants authority.

PDF-first ordering, readable pages, chunking and caching depend on the actual API/parser. Preserve page/source identity, necessary surrounding context and unread/illegible gaps. Caching repeated input is processing reuse, not retrieval, current-fact verification or proof every page was read. Inspect actual response/stop/truncation state and recover authorized targeted content; a token cap can omit required fields and lower randomness cannot validate them. Specifically, the source gives temperature 0.2 versus 0.8 as parameter suggestions and names max_tokens as an output cap; neither is a universal default/optimum or a complete-output guarantee. Its 25,000-token tool-response default is a supporting-client threshold, not characters or every API’s limit. A clipped tool result calls for actual narrower authorized retrieval with retained coverage, not a fabricated empty tail.

Finally, reported 72%→90% complex-parameter handling and 71%→93% routing describe separate source examples, changes of 18 and 22 percentage points. Dataset, trial counts and full evaluation protocol remain unknown here; do not pool them, present them as local extraction gains or guarantee retrieval relevance. Select compatible verified examples from a controlled policy/schema dataset, handle empty/conflicting retrieval explicitly and evaluate the selection stage plus held-out outputs. A 20+-intent hierarchy is contextual design advice, not a mandatory threshold. In the source-described option, a tree groups intents under parent categories and a cascade uses targeted classifiers at successive levels; different parent paths get different focused prompts, keeping each prompt and its examples manageable instead of one unwieldy all-intent prompt. Choose this design only when the actual taxonomy and evaluation justify it.

Separate instructions, demonstrations and the target

The supplied source recommends clear sections and XML tags for few-shot prompt organization. This complete teaching prompt packages the same two approved-style examples and the same target facts already shown above:

<announcement_prompt>
  <task_instructions>Draft one announcement using only target_facts. Learn structure and tone from approved_examples, without copying their product facts. Do not invent price or availability, and do not send the draft.</task_instructions>
  <approved_examples>
    <example>
      <facts>Atlas: CSV export; request a demo.</facts>
      <approved_output><![CDATA[Subject: Meet Atlas

Atlas adds CSV export. Request a demo to see the workflow.]]></approved_output>
    </example>
    <example>
      <facts>Beacon: saved filters; contact the team.</facts>
      <approved_output><![CDATA[Subject: Meet Beacon

Beacon adds saved filters. Contact the team to learn more.]]></approved_output>
    </example>
  </approved_examples>
  <target_facts>AcmeAI is an AI-powered CRM with contact summaries; request a demo. Price and availability are not supplied.</target_facts>
</announcement_prompt>

The expected target output remains exactly:

Subject: Meet AcmeAI

AcmeAI is an AI-powered CRM with contact summaries. Request a demo to learn more.

The target supplies the CRM/contact-summary claim and call to action; the demonstrations supply only the short subject/body style. Price and availability remain unprovided. These XML section names are an authored organization example, not an API schema or a guarantee against prompt injection. Keep untrusted target content at its actual instruction priority; tagging does not authorize publishing or sending.

Check complete ticket preparation contrasts

For the earlier custom teaching schema and critical-priority rule, the complete fixture inputs contain supplied fictional source_facts and proposed_arguments. Valid preparation preserves those facts and is not ticket creation. Missing optional contact stays omitted even on a critical ticket when the required escalation was supplied; absent escalation cannot be invented. These independent expected cases do not claim actual people, dates, authorization or tool execution:

[
  {
    "case_id": "minimal",
    "input": {
      "source_facts": {
        "title": "Update API documentation"
      },
      "proposed_arguments": {
        "title": "Update API documentation"
      }
    },
    "expected": {
      "status": "valid_preparation",
      "candidate_arguments": {
        "title": "Update API documentation"
      },
      "execution_status": "not_executed"
    }
  },
  {
    "case_id": "critical_complete",
    "input": {
      "source_facts": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "labels": [
          "bug",
          "authentication",
          "production"
        ],
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith",
          "contact": {
            "email": "[email protected]",
            "phone": "+1-555-0123"
          }
        },
        "due_date": "2024-11-06",
        "escalation": {
          "level": 2,
          "notify_manager": true,
          "sla_hours": 4
        }
      },
      "proposed_arguments": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "labels": [
          "bug",
          "authentication",
          "production"
        ],
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith",
          "contact": {
            "email": "[email protected]",
            "phone": "+1-555-0123"
          }
        },
        "due_date": "2024-11-06",
        "escalation": {
          "level": 2,
          "notify_manager": true,
          "sla_hours": 4
        }
      }
    },
    "expected": {
      "status": "valid_preparation",
      "candidate_arguments": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "labels": [
          "bug",
          "authentication",
          "production"
        ],
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith",
          "contact": {
            "email": "[email protected]",
            "phone": "+1-555-0123"
          }
        },
        "due_date": "2024-11-06",
        "escalation": {
          "level": 2,
          "notify_manager": true,
          "sla_hours": 4
        }
      },
      "execution_status": "not_executed"
    }
  },
  {
    "case_id": "critical_without_escalation",
    "input": {
      "source_facts": {
        "title": "Login page returns 500 error",
        "priority": "critical"
      },
      "proposed_arguments": {
        "title": "Login page returns 500 error",
        "priority": "critical"
      }
    },
    "expected": {
      "status": "invalid",
      "field": "escalation",
      "reason": "Required by the declared critical-priority rule",
      "candidate_arguments": null,
      "execution_status": "not_executed"
    }
  },
  {
    "case_id": "critical_contact_absent",
    "input": {
      "source_facts": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith"
        },
        "escalation": {
          "level": 2,
          "notify_manager": true
        }
      },
      "proposed_arguments": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith"
        },
        "escalation": {
          "level": 2,
          "notify_manager": true
        }
      }
    },
    "expected": {
      "status": "valid_preparation",
      "candidate_arguments": {
        "title": "Login page returns 500 error",
        "priority": "critical",
        "reporter": {
          "id": "USR-12345",
          "name": "Jane Smith"
        },
        "escalation": {
          "level": 2,
          "notify_manager": true
        }
      },
      "execution_status": "not_executed"
    }
  },
  {
    "case_id": "required_title_absent",
    "input": {
      "source_facts": {},
      "proposed_arguments": {}
    },
    "expected": {
      "status": "invalid",
      "field": "title",
      "reason": "Required title is absent.",
      "candidate_arguments": null,
      "execution_status": "not_executed"
    }
  },
  {
    "case_id": "invalid_reporter_structure",
    "input": {
      "source_facts": {
        "title": "Review the incident",
        "reporter": []
      },
      "proposed_arguments": {
        "title": "Review the incident",
        "reporter": []
      }
    },
    "expected": {
      "status": "invalid",
      "field": "reporter",
      "reason": "Expected an object, not an array.",
      "candidate_arguments": null,
      "execution_status": "not_executed"
    }
  }
]

All outcomes keep execution_status not_executed. The two invalid missing-data cases and the invalid reporter structure produce no candidate for creation. A separate real policy requiring contact would instead retain a blocked preparation state and request the source fact, rather than copy a contact from another example. The supplied date and SLA in the complete critical fixture are unchanged example values, not computed deadlines.

Summary

Use contrasting, verified examples to teach a format and a decision boundary. Preserve approximation, missingness, and citation relationships across layouts. Retrieve compatible examples when needed, and judge improvement on held-out evidence rather than familiarity with the demonstrations.

Explicit review severity and parser boundaries

For these two illustrative review findings, the declared severity policy is important when the shown implementation violates an explicitly permitted input or accepted output rule in its supplied caller context. Thus dereferencing permitted null and rejecting the allowed zero boundary both qualify. A merely stylistic preference is not a finding under this policy, and code whose enforced caller contract excludes null cannot be rated important for rejecting an input that is outside that contract. This is a teaching severity convention, not a claim about production impact or a universal repository rating system. The final four-field findings remain distinct from tool argument examples and require actual code/location evidence before use in a real review.

The following additional complete fixtures use the same explicitly declared custom parser contract: response.content must be an array; exactly one item with type tool_use and name print_entities must exist; its input must be an object with an entities array of strings. A missing input property is invalid_payload, distinct from no matching call. An empty entities array is valid empty data. A matching populated array is only structurally acceptable; each entity still requires actual source support. No one of these envelopes is asserted as a universal MCP/SDK response contract.

Complete response fixture Complete expected parser outcome
{"content":[{"type":"tool_use","name":"print_entities"}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":[]}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":7}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":{"entities":null}}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":{"entities":[7]}}]} {"status":"invalid_payload","entities":null}
{"content":[{"type":"tool_use","name":"print_entities","input":{"entities":[]}},{"type":"tool_use","name":"print_entities","input":{"entities":["R7"]}}]} {"status":"multiple_matching_calls","entities":null}
{} {"status":"invalid_response","entities":null}
{"content":null} {"status":"invalid_response","entities":null}

Validate the outer response shape before counting matches. For one actual match validate property presence, object shape and every entities item before processing; do not collapse these checks into if input. No matching call, a malformed response, a malformed matching payload and multiple matching calls each retain their displayed distinct status. The original valid-empty and populated fixtures still follow the same policy. These tables are expected static fixtures, not executed Python, a live tool call, or a measured model accuracy result. In the denied/unread-source example above, request actual authorized source access; this does not authorize granting it automatically or retrying indefinitely.

PUBLIC BETA OFFER

Save 50% off on an Eligible Learning Plan

Valid for 1-month plan, 3-month plan, 12-month plan · Code LPXBETA50 · Ends Dec 6, 2026

Ready to put this into practice?

Start guided practice →