Fallback
A fallback is an alternative behavior, result, resource, or processing path selected when a preferred option fails, is unavailable, or cannot handle a situation.
The Art of Code
A fallback is an alternative behavior or result selected when the preferred operation is unavailable or unsuccessful.
- How it is used
- Preserves application operation through degraded outcomes when technical dependencies fail.
- How deep it goes
- Explains retry, circuit breakers, cached responses, and graceful degradation, while deferring implementation details to resilience libraries.
- Examples
- Uses remote timeouts, cached responses, actionable errors, reduced image quality, and temporary read-only mode.
- What you can do after
- Apply it via resilience policies by selecting an acceptable degraded result when a dependency remains unavailable.
Natural Language Processing in Action, Second Edition
A fallback response is a predefined chatbot reply provided when no recognized intent meets the required confidence level.
- How it is used
- Handles user messages the chatbot cannot confidently match to a programmed intent or safely answer.
- How deep it goes
- Explains a confidence-threshold rule, conversation-diagram label, and recovery choices without implementing an intent recognizer.
- Examples
- Uses a math-tutor conversation diagram and recovery options such as suggested functions or a human representative.
- What you can do after
- Operate/configure it by setting a low-confidence fallback path and giving users a clear next step.
Read how Natural Language Processing in Action, Second Edition explains fallback →
Prompt Engineering in Practice
A predefined response or processing path used when input is malformed, incomplete, invalid, or manipulated.
- How it is used
- Routes out-of-scope or conflicting requests to a specified response instead of leaving refusal wording to the assistant.
- How deep it goes
- Defines an exact trigger and response, demonstrates adversarial tests, and places fallback alongside other prompt-hardening techniques.
- Examples
- Uses a code review assistant asked to change personas and a support chatbot asked to disclose customer orders.
- What you can do after
- Operate/configure it as an exact system-prompt response for requests outside a defined task, then test whether it fires.
CSS in Depth, Second Edition
Fallback is the font-display value that permits a brief invisible-text period, then uses the fallback font until the web font loads.
- How it is used
- Balances brief invisible text against an immediate fallback font while a web font loads.
- How deep it goes
- Explains the visible loading sequence and connection-speed trade-offs, but defers deeper web-font performance treatment.
- Examples
- Uses a Google Fonts `&display=swap` URL parameter that can be changed to select `fallback`.
- What you can do after
- Operate/configure it by selecting `font-display: fallback` in `@font-face` or a Google Fonts URL.
Machine Learning System Design
A fallback is an alternative behavior or implementation used when the primary behavior or system cannot operate normally.
- How it is used
- Keeps an integrated ML system making decisions when its primary prediction fails, is unavailable, or is unsatisfactory.
- How deep it goes
- Defines the backup role and compares model and rule-based designs, then illustrates tiered switching without specifying implementation code.
- Examples
- Uses equipment-failure prediction and an inventory system with feature-based, time-series, and previous-week-sales backups.
- What you can do after
- Operate/configure it by choosing backup responses and conditions that switch predictions when drift, quality problems, or model failures occur.
Effective Conversational AI
A fallback path is a conversational handling route for input that cannot be understood or handled by the primary flow.
- How it is used
- Routes unrecognized or unsupported requests to rephrasing, search, generative AI, or human assistance.
- How deep it goes
- Compares routing choices and gives a threshold example, while leaving platform-specific agent integrations unexplored.
- Examples
- Uses a Cake Bot response threshold, inadequate retrieval results, and utility-company routing for out-of-scope requests.
- What you can do after
- Apply fallback routes by limiting repeated prompts, offering agents, or directing requests to search or another suitable handler.
React Hooks in Action: With Suspense and Concurrent Mode
A fallback is alternate user-interface content displayed while the intended content is unavailable or an error has occurred.
- How it is used
- Provides alternate UI while lazy components, data, images, or other promise-backed resources load or fail.
- How deep it goes
- Explains boundary selection, replacement behavior, and custom error handling, but treats data fetching through Suspense as experimental.
- Examples
- Uses loading calendars, messages, user avatars, and customizable error screens with reload instructions.
- What you can do after
- Build and configure loading and error states with Suspense, fallback props, and ErrorBoundary components.
Read how React Hooks in Action: With Suspense and Concurrent Mode explains fallback →
Tiny CSS Projects
An image fallback is an alternative presentation or behavior provided when an image resource fails to load.
- How it is used
- Keeps image content and image-based styling usable when resources fail or browser features are unavailable.
- How deep it goes
- Works through broken and restored image states with onerror, then explains CSS color alternatives for image backgrounds and text effects.
- Examples
- Uses a deliberately broken newspaper image, an image-filled heading, and a credit-card background with a blue fallback.
- What you can do after
- Build it from scratch using meaningful alt text for content images, onerror for decorative images, and CSS fallback colors.
Grokking AI Applications
A prompt instruction that specifies an alternative response when the model cannot complete the requested task or find the requested information.
- How it is used
- Uses fallback instructions to make prompting more reliable and prevent inaccurate or misleading responses.
- How deep it goes
- Defines the technique and demonstrates its wording, but does not develop implementation steps or model internals.
- Examples
- Uses a text-query example that returns “not found” when the requested answer is absent.
- What you can do after
- Apply it via a prompt instruction that specifies what the model should say when evidence or task completion is unavailable.
Quarkus in Action
A fallback is a fault-tolerance pattern that supplies an alternate result or behavior when an operation fails.
- How it is used
- Protects client-facing operations by returning an alternative result when a dependent service remains unavailable.
- How deep it goes
- Defines the pattern and demonstrates annotation configuration, but does not discuss imperative fallback APIs or extensive operational policy design.
- Examples
- Uses a Reservation-to-Inventory availability call that returns an empty car list after retries fail.
- What you can do after
- Apply it via MicroProfile annotations and a named fallback method in a Quarkus service.
AI Agents in Action, Second Edition
A fallback is an alternative action or implementation used when the preferred operation cannot complete successfully.
- How it is used
- Keeps agents useful when tools, models, or supporting services fail, time out, or exceed an operational budget.
- How deep it goes
- Explains fallback triggers, alternatives, retry limits, and coordination with circuit breakers, but does not specify implementation code.
- Examples
- Uses best-effort answers, smaller models, omitted images, text-only responses, delayed image links, and uncertainty-marked partial information.
- What you can do after
- Apply fallback routing to preserve useful agent behavior while limiting retries and clearly marking uncertain results.
Read how AI Agents in Action, Second Edition explains fallback →
LLMs in Production
A fallback response is a predefined response returned when processing a user request fails.
- How it is used
- Improves chatbot resilience and keeps users informed when an LLM request fails.
- How deep it goes
- Defines fallback behavior and its chat-history rationale, but does not specify a concrete error-handling implementation.
- Examples
- Uses connection failures, overwhelmed servers, and instructions to try again in a few minutes as concrete cases.
- What you can do after
- Operate/configure a chatbot that returns guidance after failed requests and maintains clean conversational history.
Build AI-Enhanced Web Apps
A user-facing fallback is an alternative interface response or recovery option presented when the intended operation fails.
- How it is used
- Provides a recoverable interface response for failed AI generations and unavailable external services.
- How deep it goes
- Explains classification, centralized messaging, request IDs, rendering, and retry, but does not enumerate every provider error.
- Examples
- Uses AIErrorTracker, continueConversation, ChatBubble, request IDs, retry controls, and predefined MCP responses.
- What you can do after
- Build it from scratch by catching provider errors, classifying them, rendering stable messages, and wiring recoverable cases to retry.
Machine Learning Platform Engineering
A fallback strategy defines an alternative provider, model, or execution path used when the preferred path fails or cannot satisfy a request.
- How it is used
- Supports high-availability LLM applications by switching providers when throttling or other failures affect the preferred service.
- How deep it goes
- Defines provider fallback and places it alongside retry, monitoring, and graceful degradation, but gives no configuration procedure.
- Examples
- Uses OpenAI or Claude as backup options for Gemini and pairs fallback with throttling retries and token monitoring.
- What you can do after
- Apply it by selecting backup providers alongside retry and monitoring controls for high-availability LLM services.
Read how Machine Learning Platform Engineering explains fallback →
Generative AI in Action
A fallback mechanism is an alternative execution or service path invoked when the preferred path fails or becomes unavailable.
- How it is used
- Maintains GenAI application availability and retrieval quality when preferred paths fail, exceed limits, or produce weak results.
- How deep it goes
- Explains trigger conditions, alternate chunking paths, feedback loops, monitoring, and cost considerations without detailing implementation code.
- Examples
- Uses alternate chunk sizes, different chunking strategies, user feedback, automatic recovery, alerts, and distributed tracing as fallback-related mechanisms.
- What you can do after
- Operate/configure retrieval and distributed GenAI systems with alternate paths, confidence triggers, recovery plans, and monitoring.
Related concepts
- routingcontrasts with · Routing is the selection of a path, destination, or processing component to direct an item, request, or flow toward an intended endpoint.
- rule-based systemuses · A rule-based system produces outputs or actions by applying explicitly specified rules or conditions to inputs or represented facts.
- Llamauses · Llama is a family of autoregressive large language models developed by Meta and released in multiple versions and sizes.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.














