Think first How do you control which prompt each LLM task gets, what goes into it, and which version runs?
Why it matters: Questions describe a prompt setup and ask which file, attribute, variable or mode controls what the LLM receives.
In NeMo Guardrails every LLM call does one specific task, and each task has its own prompt. You customize those prompts in YAML, fill them with Jinja2 variables at render time, and keep several versions with modes.
Reported, thanks
Step 2 of 10
Term
Meaning
Task prompt
The prompt sent for one LLM task; each LLM call performs exactly one specific task.
Jinja2
The template language prompts use to substitute variables when they are rendered.
prompting_mode
Top-level setting that a prompt's mode must match; with no match, the standard prompt is used.
Prompt context variable
A custom template variable you register with LLMRails.register_prompt_context().
GA prompt optimizer
A NeMo Agent Toolkit tool that evolves prompts with a genetic algorithm.
Reported, thanks
Step 3 of 10
Every LLM call performs one specific task. The prompts key lets you customize the prompts used for these various LLM tasks. Inside an action, you can render a custom task prompt with LLMTaskManager.
Reported, thanks
Step 4 of 10
Define prompts under the prompts key. That key can sit in the main config.yml or in a separate prompts.yml file. To load prompts from outside the config, set the PROMPTS_DIR environment variable to a directory of .yml prompt files.
Exam trap A PROMPTS_DIR folder is not read for any file type: it must contain .yml files with prompt definitions.
Reported, thanks
Step 5 of 10
A prompt uses content or messages, never both. The two attributes are mutually exclusive. The max_length attribute caps the prompt length in characters and defaults to 16000.
Three prompt attributes compared
Attribute
What it sets
Rule to remember
content
The prompt as one string
Cannot be combined with messages
max_length
Longest allowed prompt, in characters
Defaults to 16000
mode
Which version of a task's prompt this is
Must match the top-level prompting_mode
Exam trap Setting both content and messages on one prompt is not a way to add context: the two attributes are mutually exclusive.
Reported, thanks
Step 6 of 10
Templates fill in variables with Jinja2. Register your own variable with LLMRails.register_prompt_context(). If you pass a function, its value is computed again for each rendering. Filters such as first_turns(n) keep only the first n turns of a Colang history.
Exam trap A function registered as prompt context is not evaluated once and cached; it runs again every time the prompt is rendered.
Reported, thanks
Step 7 of 10
Modes give one task and model several prompt versions. For example, you can keep a compact prompt for lower latency next to the standard one. The prompt's mode must match the top-level prompting_mode. If no prompt matches, the standard prompt is used.
Exam trap A prompting_mode with no matching prompt does not stop the app; the standard prompt is used instead.
Reported, thanks
Step 8 of 10
The user_intent parser strips a prefix; max_tokens caps the output. The user_intent output parser removes a "User intent:" prefix when present. Self-check and content safety actions fall back to 1024max_tokens if unset. Reasoning models need it set explicitly so the reasoning trace and the verdict both fit.
Exam trap Leaving max_tokens unset for a reasoning model is risky: the 1024 fallback may not fit both its reasoning and its verdict.
Reported, thanks
Step 9 of 10
The GA optimizer evolves prompts with a genetic algorithm. It belongs to NeMo Agent Toolkit. When it finishes, it writes the final optimized_prompts.json and ga_history_prompts.csv files.
Reported, thanks
Step 10 of 10
Each LLM call performs one task, so you customize prompts task by task.
Prompts go under prompts in config.yml or prompts.yml, or in .yml files under PROMPTS_DIR.
content and messages are mutually exclusive, and max_length defaults to 16000 characters.
With no prompt matching prompting_mode, the standard prompt is used.
Think first How would you send text, images, audio or video to a model served by NIM, and what decides which inputs work?
Why it matters: Questions describe a multimodal request or a NIM setup and ask which endpoint, content part or container image fits.
NIM serves multimodal models through OpenAI-compatible Chat Completions requests whose content mixes text and media. What works depends on the model and the engine: a text-only model cannot take media, and video needs vLLM.
Reported, thanks
Step 2 of 9
Term
Meaning
Content array
The list in a Chat Completions request that mixes text and media items.
audio_url
Content part for audio input, an extension to the Chat Completions schema both engines accept.
Profile prefix
The vllm- or sglang- start of a profile name, naming the one engine an image embeds.
Data URL
An inline image as base64 in image_url.url, such as data:image/jpeg;base64,..., with a matching MIME type.
Reported, thanks
Step 3 of 9
Send media in an OpenAI-compatible Chat Completions request. The message content array mixes text and media items. POST /v1/chat/completions keeps multi-turn history and supports streaming and tool calling.
Reported, thanks
Step 4 of 9
Inline images go in image_url.url as a base64 data URL. Use the MIME type of the file, for example image/png for a PNG. Audio uses the audio_url part, and both engines also accept OpenAI's input_audio part. Media URLs must be reachable from the NIM container.
Exam trap A media URL that only your own machine can reach will not work. The NIM container itself must be able to reach it.
Reported, thanks
Step 5 of 9
Video needs a vLLM image; image and audio work on both. Each NIM image embeds one engine, vLLM or SGLang, shown by the vllm- or sglang- profile prefix. SGLang images lack the video decoder that video_url requests need.
Input support by NIM engine
Feature
vLLM image
SGLang image
Image input
Yes
Yes
Audio input
Yes
Yes
Video input (video_url)
Yes
No, it lacks the video decoder
Exam trap An SGLang image cannot serve video_url requests because it has no video decoder. Use a vLLM image for video.
Reported, thanks
Step 6 of 9
A text-only model cannot take image, audio or video input. Serving it through NIM does not change that. The NIM Support Matrix groups models into LLMs, VLMs and Model-Free NIM.
Exam trap NIM does not give a text-only model the ability to read images or audio. The model itself must handle that input.
Reported, thanks
Step 7 of 9
NIM also offers an Anthropic-compatible /v1/messages endpoint. Requests pass through the nginx proxy with bodies left unchanged. NIM does not check x-api-key, so any non-empty key satisfies Anthropic SDK clients.
Reported, thanks
Step 8 of 9
The toolkit's oci provider uses OCI SDK authentication. Its region defaults to us-chicago-1. The current release does not enable the OpenAI Responses API for it.
Reported, thanks
Step 9 of 9
Multimodal requests use OpenAI-compatible Chat Completions with a mixed content array.
Video input needs a vLLM image; image and audio work on both vLLM and SGLang.
A text-only model cannot process image, audio or video, even on NIM.
Media URLs must be reachable from the NIM container.
Think first How do you turn your own code into a tool an agent can call, and share it with other agents or clients?
Why it matters: Questions describe a custom tool or API call and ask how to register, configure, invoke or expose it.
In NeMo Agent Toolkit, tools and agents are both functions: reusable pieces that call APIs, search or calculate. You register a function so configuration files can use it, and you can publish it to MCP clients.
Reported, thanks
Step 2 of 10
Term
Meaning
Function
A reusable component that does one job, such as a web search, an API call or a calculation.
FunctionBaseConfig
The base class that every function's configuration object inherits from.
Function group
Related functions that share one configuration object and runtime context.
FunctionRef
A str-like annotation marking a configuration field as a reference to another function.
MCP server worker
The default worker that publishes workflow functions as MCP tools.
Reported, thanks
Step 3 of 10
Tools and agents are both functions. So one agent can serve as a tool for another, which is how multi-agent workflows are built. A function can run a web search, call an API or do a calculation.
Reported, thanks
Step 4 of 10
Register with @nat.plugin_api.register_function. A configuration file can use a function only after it is registered. Its configuration object inherits from FunctionBaseConfig and needs a name attribute, which identifies the function in the configuration file.
Exam trap Writing the function in Python is not enough for configuration files. It must be registered with the decorator first.
Reported, thanks
Step 5 of 10
A function takes exactly one input argument. Input and output types can be anything. Their schemas are Pydantic BaseModel classes that validate data at runtime. Pass a multi-argument callable to from_fn() and it is wrapped in a single-argument lambda.
Exam trapfrom_fn() does not reject a multi-argument callable. It wraps it in a lambda that takes one argument and passes it on.
Reported, thanks
Step 6 of 10
Every function call is asynchronous. Use ainvoke() for a single output and astream() for streaming output. Picking the wrong method for the function's output type results in an error.
The two ways to invoke a function
Method
Use for
Errors when
ainvoke()
A single output
The function only has a streaming output
astream()
Streaming output
The function only has a single output
Exam trapainvoke() is not a universal fallback. Calling it on a streaming-only function results in an error.
Reported, thanks
Step 7 of 10
Groups share one configuration and runtime context. That lets related functions reuse connections, caches and other resources. Each function gets a full name with a double underscore, such as math__add. Pick functions with include or exclude, never both.
Exam trapinclude and exclude cannot both be set on one group. They are mutually exclusive, so use one or the other.
Reported, thanks
Step 8 of 10
Annotate function names with FunctionRef. It behaves like str but marks the value as a reference to another function. That lets the toolkit make sure the referenced function is registered first.
Reported, thanks
Step 9 of 10
The default MCP server worker publishes functions as tools. Your workflow functions then appear as MCP tools. For custom behavior, inherit from MCPFrontEndPluginWorker and put the worker's fully qualified class name in runner_class.
Reported, thanks
Step 10 of 10
Agents and tools are both functions, so an agent can be another agent's tool.
Register functions with @nat.plugin_api.register_function so configuration files can use them.
A function takes one input argument, and every call is asynchronous.
Grouped functions are named group__function; include and exclude are mutually exclusive.
Think first How should an agent decide when a failed outbound call is worth retrying, and how long to wait before trying again?
Why it matters: Questions describe a failing call and ask which retry setting, default or error type explains the behavior.
Retries are governed by a policy, not by guesswork. The policy sets how many attempts, how long to wait, and which methods are safe to repeat. Errors that survive the retries reach the caller with a record of what was tried.
Reported, thanks
Step 2 of 10
Term
Meaning
RetryPolicy
The NeMo Guardrails settings for attempts, delays, retryable methods and Retry-After handling.
Exponential backoff
The fallback wait strategy when a server's Retry-After value cannot be used.
RetryMixin
A NeMo Agent Toolkit Pydantic mixin that adds retry settings to a component's config.
retry_count
How many retries completed before an error or response came back to the caller.
Clamping
A RetryPolicy option, off unless explicitly enabled, that lifts the rule that Retry-After counts only within max_retry_after.
Reported, thanks
Step 3 of 10
max_attempts counts the first request too. A value that looks like the number of retries is really the total number of tries. The first call uses up one of them.
Exam trap Reading max_attempts as retries on top of the first call overstates how often the request is sent.
Reported, thanks
Step 4 of 10
Waits start at 0.5 seconds and are capped at 8.0 seconds. These are the RetryPolicy defaults for initial_delay and max_delay.
Reported, thanks
Step 5 of 10
POST is left out of the safe default set on purpose. Method names are also normalized to uppercase.
Exam trap Do not assume every failed request is retried by default. POST is deliberately excluded from the safe default methods.
Reported, thanks
Step 6 of 10
A Retry-After value counts only inside max_retry_after, unless clamping is on. An invalid or out-of-policy value is dropped, and the client falls back to exponential backoff. Vendor override headers count only when you turn on honor_retry_override_header.
How RetryPolicy treats server wait hints
Hint
Default handling
Changed by
Retry-After within max_retry_after
Honored
Not needed
Retry-After outside max_retry_after
Not honored
Explicitly enabling clamping
Vendor retry-override header
Ignored
Enabling honor_retry_override_header
Reported, thanks
Step 7 of 10
HTTPClientError is the base class for outbound HTTP failures.HTTPConnectionError means a connection could not be opened or kept. HTTPTimeoutError means the request went past its total timeout. Each error carries retry_count, so you can see how hard the client tried.
Reported, thanks
Step 8 of 10
RetryMixin adds retry fields to a NeMo Agent Toolkit config. Use do_auto_retry to switch automatic retries on or off. List the HTTP status codes that should trigger a retry in retry_on_status_codes.
Reported, thanks
Step 9 of 10
Successful responses also report retry_count. RetryingHTTPClient puts the count in the response extensions. Transport errors expose their completed count before they are raised again.
Reported, thanks
Step 10 of 10
max_attempts includes the initial request, so it is a total, not a retry count.
RetryPolicy defaults: initial_delay of 0.5 seconds and max_delay of 8.0 seconds.
POST is not retried by default because it is missing from the safe method set.
An unusable Retry-After value means the client uses exponential backoff instead.
Think first When you stream an agent's answer, how do you keep it fast without letting unsafe text slip through?
Why it matters: Questions describe a streaming setup and ask which output rail setting balances speed against safety.
NeMo Guardrails streams with stream_async() and checks output in chunks of tokens. The chunk settings and stream_first decide how soon users see text, and whether they can see text a rail later blocks.
Reported, thanks
Step 2 of 9
Term
Meaning
stream_async()
The NeMo Guardrails method that streams responses; basic streaming needs no configuration.
chunk_size
Tokens per chunk that output rails process; the default is 200.
context_size
Tokens carried from one chunk into the next for continuity; the default is 50.
stream_first
Whether the client gets each chunk before output rails check it; the default is True.
Reported, thanks
Step 3 of 9
Basic streaming works with stream_async() alone. No configuration is needed. The old top-level streaming: True field is deprecated; call stream_async() directly instead.
Reported, thanks
Step 4 of 9
Output rails need rails.output.streaming.enabled set to True. The setting defaults to False. With output rails configured, enable it explicitly so they process tokens in chunked mode.
Exam trap Calling stream_async() alone is not enough once output rails are configured. Until enabled is True, you cannot use stream_async() with output rails.
Reported, thanks
Step 5 of 9
Tokens are buffered until chunk_size is reached. The last context_size tokens of each chunk are prepended to the next chunk's context. Rails can then judge a sentence that spans two chunks as a whole.
Output rail streaming settings and their defaults
Setting
Default
What it controls
enabled
False
Needs True before output rails can stream
chunk_size
200
Tokens in each chunk the output rails process
context_size
50
Tokens carried over from one chunk to the next
stream_first
True
Client gets tokens before rails check the chunk
Reported, thanks
Step 6 of 9
Smaller chunks reach users sooner; larger ones run rails less. Choose by what matters more for your users: seeing text early, or fewer rail executions per response.
Smaller and larger chunk_size compared
Feature
Smaller chunk_size
Larger chunk_size
Rail executions
More
Fewer
Time to first output
Faster
Slower
Reported, thanks
Step 7 of 9
stream_first decides who sees a chunk first. With the default True, users get text sooner. With False, rails check every chunk before the client sees it.
stream_first set to True and to False
Feature
True (default)
False
Time-to-first-token
Faster
Higher by the rail time per chunk
Blocked content
User may already have received it
User never sees it
Exam trap With stream_first True, a block does not take text back. The user already has those tokens when the stream ends with a JSON error.
Reported, thanks
Step 8 of 9
A block ends the stream with a JSON error object. If any output rail blocks content, the stream yields a JSON object with an error key and stops at once.
Reported, thanks
Step 9 of 9
Call stream_async() directly; the deprecated top-level streaming: True field is not needed.
Set rails.output.streaming.enabled to True to stream with output rails.
chunk_size defaults to 200 tokens and context_size to 50.
stream_first True is faster, but users may see text a rail later blocks.
Think first How would you judge whether an agent took a sensible path to its answer, and then improve the way it plans?
Why it matters: Questions describe an agent evaluation and ask which evaluator, judge setting or planner refinement fits it.
You evaluate an agent by running its workflow on curated test data and scoring the results. The trajectory evaluator judges the path the agent took. Repeated runs and plan refinement then help you improve its decisions.
Reported, thanks
Step 2 of 9
Term
Meaning
Trajectory
The path an agent takes, read from the intermediate steps its workflow generated.
Judge LLM
A model that scores the workflow's trajectory or output, taking the available tools into account.
Intermediate steps
Steps the workflow records; workflow_output.json keeps LLM_END and TOOL_END by default.
Tunable RAG Evaluator
An evaluator that scores answers against an expected answer description, not a ground truth.
Reported, thanks
Step 3 of 9
The trajectory evaluator judges the agent's path. It reads the intermediate steps the workflow generated. A judge LLM scores that path while considering the tools available during execution. The evaluator builds on LangChain/LangGraph agent trajectory evaluation.
Exam trap The trajectory evaluator does not look only at the final answer. It scores the path, using the workflow's intermediate steps.
Reported, thanks
Step 4 of 9
Trajectory scores run from 0 to 1. A score of 1.0 means a perfect trajectory. Give the trajectory judge LLM a max_tokens of 1024 so it has enough context to evaluate.
Reported, thanks
Step 5 of 9
Ragas prompts are fixed; Tunable RAG uses an answer description. The Ragas metrics' judge prompt cannot be changed, and their judge LLM should use 8 tokens. The Tunable RAG Evaluator scores against an expected answer description instead of a ground-truth answer.
Exam trap You cannot edit the Ragas judge prompt. If you need your own prompt, switch to the Tunable RAG Evaluator or a custom evaluator.
Reported, thanks
Step 6 of 9
langsmith_judge needs a judge with structured output. Its judge LLM must support JSON schema mode. Check that your chosen judge model offers it before you run the evaluation.
Reported, thanks
Step 7 of 9
--reps repeats an evaluation several times. Repeated runs let you average the score and see how much outputs vary. By default, workflow_output.json keeps only LLM_END and TOOL_END intermediate steps.
Exam trap By default, workflow_output.json does not keep every intermediate step. It keeps only LLM_END and TOOL_END.
Reported, thanks
Step 8 of 9
IterativePlanRefinementEditor reworks a plan with the same LLM. This experimental planner writes an initial plan, then improves it several times. Each planning item is refined in parallel, 3 times by default.
Reported, thanks
Step 9 of 9
The trajectory evaluator scores the agent's path from its intermediate steps, from 0 to 1.
Set the trajectory judge LLM's max_tokens to 1024.
Ragas judge prompts are not configurable; use the Tunable RAG Evaluator or a custom evaluator instead.
--reps lets you average scores across runs and measure variation.
Each topic's Check tested it on its own; this mixes them.
Mixed quiz
Take the Domain 2 quiz
11 questions mixed from every topic in this domain, each answer explained. Mixing topics is harder than one at a time, and it is what the exam does. No account needed; with a free account your answers also build your estimated exam score.
Free to start: the study notes and plan, quizzes, flashcards and the first mock exam, no card needed. A free account keeps your place and saves your quiz scores.