Courses · The Ambush Method

Pick your exam.

Every guide follows the same method: short daily sessions, the traps each topic sets, and exam-style questions with an explanation for every option.

  • 100% free · no paywalls, subscriptions or ads
  • 30–60 min a day
  • Exam-style questions
  • Taught in English

Databricks Prompt Engineering for the GenAI Exam: Format, Steer, Augment

Databricks prompt engineering featured image: ask for a JSON format or enforce it with response_format, plus few-shot and system prompt traps for the GenAI Engineer exam

Here’s a pattern I see a lot in people preparing for the Generative AI Engineer Associate. They’ve been writing prompts for ChatGPT for two years, so they skip the prompting topics and go straight to Vector Search and agents. Then the exam hands them a scenario where the model “usually” returns valid JSON, and four answers that all sound reasonable, and they pick the one that just asks more firmly. Databricks prompt engineering on this exam isn’t about clever phrasing. It’s about knowing when wording is enough and when it isn’t, and the exam is built to catch the people who never made that distinction.

This post covers the three prompting skills the exam names directly: forcing a format, steering an output from a baseline, and augmenting a prompt with what the user actually typed. Each one comes with its own trap, and each trap is designed to be the answer you pick if you’re going on instinct.

If you’re just getting started, my Databricks Generative AI Engineer Associate study guide has the full exam map. This post zooms into the prompting lines of it.

Where prompt engineering sits in the exam guide

The official exam guide lists three prompting objectives, spread over two sections:

  • Section 1, Design Applications (14%): “Design a prompt that elicits a specifically formatted response.”
  • Section 3, Application Development (30%): “Create a prompt that adjusts an LLM’s response from a baseline to a desired output.”
  • Section 3 again: “Augment a prompt with additional context from a user’s input based on key fields, terms, and intents.”

Section 3 is the heaviest part of the exam, so two of these three land in the section that carries the most weight. And none of them asks you to recite a definition. They hand you a situation and ask for the right move. That’s why I treat this topic as a set of decisions, not a set of tricks.

Databricks prompt engineering starts with one idea: a prompt is a contract

Before the three skills, one shift in how you think about a prompt. A prompt isn’t a polite request you hope the model honors. It’s a specification the model executes, loosely, by predicting likely next tokens. Anything you leave vague is a blank the model fills with a default.

A prompt has a few parts, and each does one job:

  • The system message holds standing behavior: persona, tone, rules that must always apply.
  • The user message holds the actual ask for this turn.
  • Assistant turns can carry worked examples, an input paired with the exact output you want.
  • Inside those, you have the instruction, the context, the examples and the output spec.

The exam won’t ask you to label these parts on their own. It uses them as the reason one answer is right. A classic tell: a rule that must hold on every turn is being repeated inside every user message. The cleaner fix is to put it in the system message once.

Think of the rest of this post as a short ladder on top of that anatomy: format, then behavior, then context. You climb only as far as the task forces you.

Skill 1: Forcing the format (ask vs. enforce)

Picture an extractor whose output goes straight into an importer that reads one JSON record per document. If any record is malformed, the importer rejects the whole batch. In testing, the model returns clean JSON almost every time. Almost is the problem.

The instinct is to strengthen the wording: “Return only valid JSON.” That helps. It makes JSON a more likely continuation. It does not make anything else impossible, and on the one odd input in a thousand, the model can still open with “Here’s the extracted data:” and break the parser.

Asking well: prompt-craft for format

Asking is still a real skill, and it’s what the objective’s wording points at. The moves that work best:

  • State the shape as an exclusion: “Return only a JSON object, no prose, no markdown fences.”
  • Show the shape: put the exact fields and types, or a filled example, in the prompt. Models copy a visible pattern more reliably than they follow a description.
  • Add one or two example turns (few-shot) with the exact output you want.
  • Fence the input with delimiters so the model can tell your instructions from the material.

All four narrow the odds. None of them closes the door.

Enforcing: structured outputs with response_format

Enforcement is a different kind of move. On Databricks, chat models served through Foundation Model APIs support structured outputs through a response_format field on the request. It comes in two strengths: json_object when any valid JSON will do, and json_schema when a consumer needs specific fields. Here’s a small routing example with a strict schema:

response = client.chat.completions.create(
    model="databricks-gpt-oss-20b",
    messages=messages,
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "ticket_route",
            "schema": {
                "type": "object",
                "properties": {
                    "order_id": {"type": "string"},
                    "category": {"type": "string"},
                    "priority": {"type": "string"},
                },
                "required": ["order_id", "category", "priority"],
            },
            "strict": True,
        },
    },
)

With a strict schema, you’re not asking the model to match the shape. You’re constraining what it can return. The Databricks docs list the edges worth knowing: only a subset of JSON Schema is supported (no regex pattern, no anyOf, oneOf, allOf or $ref), there’s a limit of 64 keys, heavily nested schemas generate worse, and the extra work to keep the model on-schema costs tokens on every call. Some model families have their own rules too (Claude models, for example, only accept json_schema, not json_object), so check the limitations for the model you’re using. Flat and small is the schema that holds.

The format trap

The ambush looks like this: an output feeds a parser, an API or a database import, and two answers sit side by side. One adds a firmer instruction to return JSON. The other constrains the reply with a schema. The firmer instruction is the trap. It’s not wrong the way nonsense is wrong; it genuinely improves things and it passes a demo. But when the requirement is “every response must parse,” only enforcement answers the question that was asked.

Two other distractors show up around format. Temperature 0 makes output repeatable, but a reply wrapped in a sentence will be wrapped the same way every time. And raising max_tokens fixes truncation, not shape. My rule: read the stem for who consumes the output. If a person reads it, better wording may be enough. If code reads it, enforce the shape.

Skill 2: Steering from a baseline

The second objective is about the output that parses fine and is still not what you wanted. Too long. Too casual. Wrong persona. The trap here isn’t a technique, it’s a habit: rewriting the whole prompt every time something is off, and breaking the parts that already worked.

The method is two steps:

  • Name the gap. Not “it’s bad,” but “it’s three paragraphs and should be three sentences, and the tone is casual where it should be formal.”
  • Change the smallest thing that closes that gap, and nothing else, so you know what helped.

The ladder: zero-shot, few-shot, chain-of-thought

The tools sit in order of cost, and that order is worth memorizing:

  • Zero-shot instruction. State the constraint in words: “In three sentences or fewer, in a formal tone.” Most length, tone and persona gaps close right here.
  • Few-shot examples. When words don’t land a style, show one or two finished answers in that style. They cost tokens on every call, so they earn their place only after an instruction has failed.
  • Chain-of-thought. Ask the model to reason step by step before answering. It’s for one kind of gap: wrong answers on multi-step reasoning. It does nothing for tone or length, and it adds tokens and latency.

Climb only as far as the gap forces. Persona belongs in the system message, not repeated in every user turn. And if the output isn’t wrong so much as different every run, that’s temperature, a randomness knob, not a quality knob. Lowering it while you iterate makes it easier to tell whether a change did anything.

On Databricks, the natural place for this loop is the AI Playground, where you can try prompts against models side by side. The discipline that matters there is changing one variable at a time.

The steering trap

A scenario shows an output that’s close, with one specific thing off, and offers a small targeted fix next to something bigger: rewrite the prompt from scratch, switch to a larger model, turn on chain-of-thought, fine-tune. The bigger move is the ambush, because it looks like it’s taking the problem more seriously. It isn’t. A larger model writes just as long if nothing told it otherwise. Pick the smallest change that matches the named gap, and distrust the answer that does the most.

Skill 3: Augmenting with the user’s input

The third objective is the one people misread most. “Augment a prompt with additional context from a user’s input” sounds like “include the user’s message.” It means the opposite: extract what matters from it.

Picture a customer writing ninety words about a return: the order number, a wrong size, a crushed box, years of loyalty, and, near the end, “I do NOT want another pair, I just want my money back.” The model needs three things from that: the order, the problem and the request. Pasting the whole paragraph in buries them in noise, pays for that noise on every call, and leaves stray phrases (like “another pair”) that a careless model might act on.

Fields, terms, intent

The objective names three things to pull, and they fail differently:

  • Fields are concrete values: order number, date, amount, destination.
  • Terms are domain words that route the request: “refund” versus “exchange,” “cancel” versus “reschedule.”
  • Intent is what the user actually wants. It’s often stated once, in passing, sometimes as a negation. Miss it and you process a tidy version of the wrong request.

Extract first, then assemble

The cleanest pattern is two calls. The first has one narrow job: read the raw message and return the fields, terms and intent as JSON, enforced with the same response_format from Skill 1. The second call does the real work from a template filled with those values:

TEMPLATE = """Order: {order_id}
Problem: {problem}
Customer wants: {intent}

Write a short, formal reply that confirms the next step."""

prompt = TEMPLATE.format(**extracted)  # extracted = the JSON object from call one

A nice side effect: the extracted object is something you can log, test and check, which you can’t do with a decision the model makes silently inside one big call.

This is also the bridge to RAG. Filling a template slot with the user’s extracted context is the same move retrieval makes, just with fetched documents in the slot instead. If you’ve read my RAG on Databricks post, that’s the same assembly with a search step in front. And it marks a limit: extraction can only pull out what the user actually said. If the order number was never in the message, no prompt will conjure it. That needs a real data source.

The augmentation trap

Users type long, messy messages, and the question asks how to build a prompt that acts on them. “Include the full message and tell the model to use the relevant parts” sounds thorough. It’s the trap. So are “use a bigger model” and “raise the context window”: none of them adds structure. The answer extracts the specific fields, terms and intent into a template. The skill being tested is knowing what to leave out.

How I’d study this in 30-60 minutes a day

This is one of the cheapest topics on the exam to lock down, which is why skipping it hurts. Here’s how I’d spend a few short sessions:

  • Day 1: Learn the anatomy and the ask-versus-enforce line. Open the structured outputs docs and read the limitations list once.
  • Day 2: In the AI Playground, take one prompt with a length or tone problem and fix it with one change at a time. Notice how often a single instruction is enough.
  • Day 3: Take three messy messages of your own and write down the fields, terms and intent for each. Then sketch the template they fill.
  • Day 4: Practice spotting the three traps in scenario wording: “feeds another system,” “close but one thing off,” “long, unstructured user messages.”

If you’d like that practice in a guided format, my free Generative AI Engineer Associate course walks through these scenarios one ambush at a time, with no dumps involved.

FAQ

Is prompt engineering a big part of the Databricks Generative AI Engineer Associate exam?

Three objectives name prompts directly: one in Design Applications (14%) and two in Application Development (30%). Prompting also shows up indirectly in RAG, guardrails and agent questions, so it pays off well beyond those three lines.

What’s the difference between json_object and json_schema in response_format?

json_object guarantees valid JSON, but the model decides the fields. json_schema pins the reply to the fields and types you define. Use the schema when a specific consumer needs specific fields.

Does temperature 0 guarantee the right format?

No. Temperature 0 makes the output repeatable, not correct. A reply wrapped in an extra sentence will just be wrapped the same way every time. To guarantee shape, use structured outputs.

When should I use chain-of-thought?

When the model gets multi-step reasoning wrong by jumping to a conclusion. For tone, length or format gaps, a direct instruction or one example is cheaper and actually targets the problem.

Should I pass the whole user message into the prompt?

Usually not. Extract the fields, terms and intent that matter and fill them into a template. That’s what the exam means by augmenting a prompt with the user’s input.

Ready for the next step?

Prompting is the cheapest lever you have: no retrieval, no fine-tuning, just a contract the model can’t misread. Once these three moves feel automatic, the rest of the exam gets easier, because RAG, guardrails and agents all build on them. My guide to passing without dumps explains how I approach the whole exam, and the free Databricks Generative AI Engineer Associate course is where I’d go next. It’s built around the same idea as this post: learn the traps before they learn you, in 30-60 minutes a day.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *