19.1 · AI in the dev workflow
| Tool | Mode | Best at |
|---|---|---|
| GitHub Copilot | IDE completion + chat + agent | Inline suggestions; deep IDE integration. |
| Cursor | AI-first editor | Multi-file edits; repo-aware chat. |
| Claude Code | Terminal agent | Plan / explore / edit across repos with MCP + sub-agents. |
| Continue / Cline / Aider | OSS CLI/IDE agents | Bring-your-own-model; local options. |
| Sourcegraph Cody | Enterprise code search + AI | Repo-graph context. |
| Codeium / Tabnine / Windsurf | Self-host / VPC | Privacy-sensitive enterprises. |
| CodeRabbit / Greptile / Korbit | AI code review | PR-level review bot. |
| v0 / Bolt / Lovable | Generative app scaffolding | Full UI from a prompt. |
19.2 · Reviewing AI-generated code
- Hallucinated APIs — verify imports exist.
- Silent
try/exceptswallow — easy to ship; hard to debug. - Fabricated dependencies — typo-squatting risk.
- Commented-out failing tests instead of fixing them.
- Over-engineering — push for the simplest change.
19.3 · The LLM app stack
User / agent→
AI gateway (LiteLLM / Portkey / Kong AI)→
Model providers (Claude / GPT / Gemini / Llama)
Vector DB (pgvector / Qdrant)
Document store
MCP servers (tools / resources)
Eval & observability (LangFuse / OpenLLMetry)
19.4 · LLM application patterns
| Pattern | When |
|---|---|
| Prompt only | One-shot generation; classification. |
| Few-shot | Pattern from 2–5 examples. |
| RAG | Answer over a fresh / private knowledge base. |
| Function calling / tools | The model must take actions or fetch data. |
| Agent (ReAct loop) | Multi-step planning + tool use. |
| Multi-agent | Specialist teams (researcher + writer + critic). |
| Reasoning model | Hard math / code / planning — let the model think longer. |
| Fine-tune (LoRA) | Style / behaviour shift the prompt can't achieve. |
19.5 · RAG essentials
Docs→
Chunk + embed→
Vector DB→
Query → retrieve → rerank→
LLM answer + citations
- Default: hybrid (BM25 + vector) with reciprocal-rank fusion.
- Re-ranker (Cohere / Voyage / BGE) for top-k precision.
- Advanced: CRAG, RAPTOR, GraphRAG, ColPali for multimodal PDFs.
- Evaluate with Ragas / TruLens / DeepEval — context recall / precision / faithfulness / answer relevance.
19.6 · Agents — the loop
Goal→
Think→
Act (tool)→
Observe→
Reflect→
Done?
Frontier patterns: computer-use agents, browser agents, voice agents, multi-agent teams, agent-to-agent (A2A) handoffs. Frameworks: LangGraph, CrewAI, Claude Agent SDK, OpenAI Agents SDK, AutoGen.
19.7 · MCP & A2A
- MCP (Model Context Protocol): standard JSON-RPC interface for exposing tools, resources, prompts to LLM hosts. Becoming universal for AI integrations.
- A2A (Agent-to-Agent): protocol for agents from different vendors to advertise capabilities, exchange tasks, stream updates.
19.8 · AI gateways
| Gateway | Notes |
|---|---|
| LiteLLM | OSS proxy translating 100+ provider APIs into OpenAI's format. |
| Portkey | Managed gateway with fallback, semantic cache, observability. |
| Kong AI Gateway | Enterprise; AI plugins on Kong. |
| OpenRouter | Pay-per-token aggregator; great for prototyping. |
19.9 · LLM observability
- OpenLLMetry + OTel GenAI semantic conventions — vendor-neutral.
- LangFuse, LangSmith, Arize Phoenix, Helicone — managed.
- Capture per call: prompt hash, tokens in/out, latency, cost, tool calls, user, tenant.
- Tag with eval scores; build trace-replay tooling for incidents.
19.10 · Cost & latency
- Prompt caching — keep stable prefix at the top → 50–90% prefill savings.
- Model cascade — try small/cheap first; fall back to frontier on low confidence.
- Batching — provider batch API for ~50% discount on offline jobs.
- Streaming — perceived latency drops dramatically.
- Per-tenant budgets & token caps at the gateway.
19.11 · Safety & evals
- Frozen eval suite (20–200 tasks); LLM-as-judge + rubric.
- OWASP LLM Top-10 (2025) — prompt injection, sensitive info disclosure, excessive agency.
- Guardrails: NeMo Guardrails, Guardrails AI, LLM Guard, Llama Guard.
- Compliance: NIST AI RMF + 600-1 GenAI Profile, EU AI Act, ISO/IEC 42001 (full coverage in the AI Codex).
19.12 · Self-check
Q1 · The single highest-leverage cost optimisation for LLM apps?
Switching providers monthly
Prompt caching with stable prefixes
Bigger model
Higher temperature