Skip to content

Chapter 4 of 6

Application Behavior

LLM applications often span many turns or sessions, which makes conversation memory important. Conversation memory stores relevant user or task context across turns or sessions, enabling continuity without forcing users to repeat themselves. A common mistake is saving sensitive or irrelevant data without a retention policy, which creates both privacy and noise problems.

To keep probabilistic model output safe, applications add guardrails, which are rules, validation steps, or workflow constraints that prevent unsafe or low-quality output. Guardrails add reliability around probabilistic model behavior, but they should not be treated as a substitute for testing and monitoring. Related to safety is human escalation, which routes uncertain or high-impact cases to a person, preventing automation from making risky decisions alone. Letting the model act autonomously in sensitive workflows is a common mistake that guardrails and escalation rules are designed to prevent.

For cost and user experience, applications use model routing, sending tasks to different models based on cost, latency, difficulty, or capability. A common mistake is sending every task to the largest model by default, which inflates costs without proportional benefit. When conversations grow long, context compression summarizes or filters older information to fit within the model context window, preserving useful continuity while controlling cost and latency; compressing away details needed for accurate decisions is a common mistake. Finally, every application needs a fallback response, which is what the app says or does when the model or tool fails. Fallbacks keep the product graceful under outages, rate limits, or uncertainty, and showing raw errors to users without guidance is a common mistake.

All chapters
  1. 1Foundations of LLM Applications
  2. 2Retrieval and Knowledge
  3. 3Prompts and Output
  4. 4Application Behavior
  5. 5Safety and Security
  6. 6Operations

Drill it

Reading is not remembering. These come from the Llm Application Design deck:

Q

What is an LLM application?

An LLM application combines a language model with product logic, data, tools, prompts, and user experience to solve a specific workflow.

Q

What is retrieval-augmented generation (RAG)?

RAG retrieves relevant external documents and adds them to model context so answers can use fresh or private knowledge.

Q

Why is grounding important in LLM apps?

Grounding ties model output to provided sources, records, or tool results, reducing hallucinations and making answers easier to verify.

Q

What is prompt injection?

Prompt injection is an attack where untrusted content tries to override instructions, reveal secrets, or force unintended actions.