# Ai Foundations
All Ai Foundations notes →1. Prompt Engineering Fundamentals
Covers the core levers of prompt construction — instruction clarity, few-shot exemplars, system vs. user role separation, and sampling controls — as the baseline skill every downstream agentic technique builds on.
2. Prompt Design Patterns
Catalogs reusable prompt patterns — chain-of-thought, ReAct, self-consistency, and role/persona framing — with guidance on when each pattern earns its added token cost over a plain instruction.
3. Structured Outputs
Covers forcing an LLM into a validated schema — JSON mode, function-calling-style schemas, and grammar-constrained decoding — and the failure modes, like schema drift and hallucinated fields, that break naive implementations.
4. Function Calling
Covers how models select and populate function signatures from natural language, the request/response contract between model and application, and common pitfalls like parameter hallucination and ambiguous selection.
5. Tool Calling
Extends function calling into multi-tool agent design — tool registries, tool-choice strategies, parallel vs. sequential invocation — and how tool descriptions themselves become part of the prompt-engineering surface.
6. Streaming Responses
Covers server-sent events and token-streaming architectures for LLM responses, the UX and backpressure tradeoffs versus batch responses, and how streaming interacts with structured-output and function-calling validation.
7. Model Selection & Routing
Covers building a model router that picks among providers and tiers by task complexity, latency SLA, and cost — the pattern that replaces always calling the biggest model once traffic reaches production scale.
8. Hallucination Management
Covers the mechanisms behind LLM hallucination — parametric knowledge gaps, exposure bias, overconfident sampling — and mitigation strategies like grounding via RAG, citation requirements, and confidence-calibrated refusal.
9. AI Failure Modes
Surveys production failure modes beyond hallucination — prompt injection, context poisoning, tool-call loops, silent schema violations, and cascading errors in multi-agent chains — as the taxonomy a staff engineer defends against.
10. Building Reliable LLM Applications
Covers the engineering practices that turn a probabilistic model call into a reliable system component — retries with validation, evals as CI gates, circuit breakers, and observability for non-deterministic outputs.