The Practitioner's LLM Curriculum All weeks · Week 10
Week 10 · 9 hours · 8 sections · content reviewed 2026-08-09

Multimodal and Code Agents

Build production multimodal systems and code agents. Understand the cost shape that makes images and video 5-10× more expensive than text, when to reach for VLMs vs OCR pipelines, what makes code agents work in 2026, and how to read SWE-bench scores honestly.

Why this week is positioned where it is. Weeks 5-7 built RAG and agent systems. Week 8 gave eval discipline. Week 9 covered inference cost. Multimodal and code agents inherit all of those concerns and amplify them. Multimodal makes the cost equation 5-10× harsher. Code agents are agents (Week 7) running against real-world systems with real failure modes. Both are at the production frontier in 2026 — the techniques work, but the engineering is unforgiving.


1. Multimodal foundations

The 2026 multimodal landscape has converged on a few architectural patterns:

Late-fusion (most common). A vision encoder (CLIP, SigLIP, or a custom ViT) converts the image to a sequence of "visual tokens" that get prepended to the text input. The LLM treats them as part of the input prompt. Used in Claude Vision, early GPT-4V, most open-source VLMs (LLaVA, InternVL, Qwen-VL).

Unified / native multimodal. The model is trained from scratch on interleaved text and other modalities. The architecture treats all modalities as token streams. GPT-5 (and GPT-4o before it), Gemini, and Anthropic's newer Claude models use variants of this. Higher quality on multimodal reasoning; harder to develop.

Side-channel adapters. Add modality-specific projection layers to a frozen LLM. Faster to develop, lower quality ceiling. Used in some research models and rare in production.

Vision token costs. A typical image becomes 1,000–2,000 tokens depending on resolution and model. The provider tokenizers vary:

The rule of thumb: one image is roughly 1,000 tokens of input cost. This number drives the economics.

Resolution tradeoffs. Lower resolution = cheaper, faster, but loses fine detail (small text, distant features, dense charts). Higher resolution = better OCR-like extraction but expensive. The right resolution depends on your task: receipts often need high; "is this a cat or a dog?" works at low.

Audio token costs. ~600 tokens per minute for typical conversational audio in models that accept audio directly. Whisper produces text from audio at ~$0.006/minute and is still the cost leader for transcription-only workloads.

Video token costs. Sampling at 1 fps and treating each frame as an image: ~60,000 tokens per minute. At Sonnet pricing, that's $0.18 per minute of video input. Past 10 minutes of video, your costs become serious.


2. The economics of multimodal

The cost-economics step from text-only to multimodal is brutal and underestimated.

A reference comparison at Sonnet 5 prices ($3/M input, $15/M output):

The per-request multipliers compound at scale. A team that adds vision to their existing chat product without changing the model just 5-10×ed their cost.

Why this happens. Vision tokens are cheap to generate (the encoder is small) but expensive to process — they consume the same per-token attention compute as text tokens, and there are more of them. The LLM doesn't know they're "images" — they're just a longer prompt.

The optimization toolkit for multimodal is narrower than text:

Multimodal output is rarely the bottleneck. Most multimodal workloads have small text outputs. Output cost is a small fraction.


3. Image understanding in production

The four most common production multimodal workloads:

Document understanding. Receipts, invoices, contracts, legal documents. The dominant production workload in 2026. Two architectures compete:

The 2026 sweet spot for high-volume document processing: tier-based routing. OCR for the 90% of standard pages; VLM for the 10% that confuses OCR (handwriting, complex layouts, charts within documents).

Screenshot / UI understanding. "Help me fill out this form," "What's wrong with this UI?", browser agents that act on visual state. VLM-only territory — no OCR pipeline gives you "understanding of layout and intent." Cost matters less because requests are interactive (lower volume).

Charts and graphs. Extracting data from charts. Genuinely hard. VLMs are the best path; quality varies dramatically by chart complexity. Pre-extracting with chart-specific models (DePlot, ChartQA-style) helps when applicable.

Photo / scene understanding. Product photos, real-world images, security footage. VLMs handle most of this well. Specialized models still win for very narrow tasks (face recognition, vehicle classification).

The OCR-vs-VLM decision tree:

  1. Is the input mostly text in known formats (invoices, forms with consistent layouts)? → OCR.
  2. Does the task require understanding layout, charts, or non-text visuals? → VLM.
  3. Is volume > 100k pages/month? → OCR + LLM tier-routing or fine-tuned specialized model.
  4. Is volume < 10k pages/month and quality is critical? → VLM directly.
  5. Mixed → tier-based routing with VLM as fallback.
QuickCheck

You're building a product to extract structured data from supplier invoices: PDFs, mostly text-based, 95% English, occasional handwritten notes, processing volume of 1M invoices/month. Cost matters significantly. What's the right architecture?

  • Send each page directly to Claude with vision; let the VLM do everything.

  • Use a dedicated OCR (AWS Textract / Google Document AI), then pass extracted text + layout structure to a text-only LLM for understanding. Use a VLM only for the ~5% of pages that confuse the OCR (handwriting, unusual layouts).

  • Use the VLM for the 5% with handwriting; ignore the rest.

  • Train a custom layout-aware model from scratch.

Correct. At 1M pages/month, the per-page cost matters enormously. Pure VLM costs roughly $0.005-0.015/page (1500+ image tokens). Modern OCR services run $0.0015/page for the first tier. The OCR-then-LLM architecture is 5-10× cheaper at this volume. The 5% edge cases that confuse OCR (handwriting, chart-heavy pages, unusual layouts) genuinely benefit from VLM treatment — but only those. Tier-based routing at 95/5 yields ~$0.003 average vs ~$0.012 for pure VLM. Annual savings: ~$108k. Training a custom model (option 4) is the right answer past 10M pages/month, not at 1M. Pure VLM (option 1) is the prototyping path; tier-routing is the production path.


4. Audio and speech

The 2026 audio stack:

Whisper (still the standard). OpenAI's open-source model. Transcribes audio to text. Multilingual. ~$0.006/minute on hosted APIs; free if you self-host. Very mature. Used as the speech-to-text layer for almost everything.

Voicebox / TTS systems. Voice generation. Eleven Labs, OpenAI TTS, Resemble, Coqui. Voice cloning concerns are real and getting tighter regulation in 2026.

Audio-in models. GPT-5 audio, Gemini Live, Anthropic Claude with audio. Accept audio directly without transcription. Better than transcribe-then-LLM for prosody, emotion, multiple speakers. ~$0.024/minute for input audio at typical pricing.

Real-time voice. OpenAI Realtime API, Gemini Live. Sub-second latency end-to-end. The frontier of conversational AI. Cost: 5-10× higher than batch transcription.

The architecture decision:

Pick by use case: customer support recordings → transcribe; voice assistants → audio-direct.

Production audio gotchas:


5. Video — the cost frontier

Video is the most expensive multimodal modality, by a lot.

The naive approach: frame sampling. Extract frames at 1 fps, send each to a VLM. Costs scale linearly with video length and inversely with sampling rate.

Realistic costs for video workloads:

For most video applications, this is too expensive at scale.

The production toolkit for video:

The 2026 reality: video is mostly a research and high-end-product workload. Mass-market video understanding is constrained by cost. Workflows that ship in production usually have audio-first architectures with sparse frame sampling.


6. Code agents — the production frontier

Code agents are agents (Week 7) operating against real codebases with real tooling. The 2026 leading systems — Claude Code, Cursor, Windsurf, Devin, GitHub Copilot's agent mode — share a common architecture pattern.

The canonical loop:

  1. Read the user's task description.
  2. Explore the codebase: read relevant files, understand the structure.
  3. Plan the change.
  4. Make edits.
  5. Run tests.
  6. Iterate on failures.
  7. Submit / commit.

The tools that matter:

Sandbox is non-negotiable. Code agents that run arbitrary bash commands need an isolated environment. Production code agents use Docker containers or dedicated VMs, never the user's actual machine for arbitrary commands. Security and reproducibility both demand this.

Long context matters more here than anywhere else. A real codebase is millions of tokens. Agents need:

The "pause and ask" pattern. Production code agents in 2026 ask before destructive actions: deleting files, running migrations, force-pushing. The trust model is "agent suggests, human approves, agent executes." Fully autonomous agents on production codebases remain rare.

What separates good code agents from bad:

  1. Tool design. Clean, typed tools with helpful error messages. The Week 7 lessons apply double here.
  2. Prompting. System prompts that encode senior-engineer practices: read before editing, run tests after every change, prefer minimal diffs.
  3. Context management. Aggressive trimming. Summary of older turns. File contents loaded lazily.
  4. Grounding. Always read the actual code before reasoning about it. Don't reason from memory of similar code.
  5. Verification loop. After every meaningful change, run tests. If fail, iterate. Don't claim success without verification.

7. SWE-bench and reading code benchmarks honestly

SWE-bench is the dominant code-agent benchmark. The construction:

SWE-bench Verified (2024) is a curated subset of ~500 tasks where humans confirmed the test cases are correct and unambiguous. The honest benchmark.

2026 leaderboard reality:

How to read these numbers honestly:

Don't pick a code agent based on SWE-bench score alone. Pick based on:

  1. Performance on your code (build a small private eval set — Week 8).
  2. Cost per task at your traffic level.
  3. Tool ecosystem fit (does it work with your CI? IDE? language?).
  4. Failure modes (graceful retries vs catastrophic edits).
  5. Trust model (asks before destructive actions vs YOLO mode).
QuickCheck

Code agent X scores 73% on SWE-bench Verified. Code agent Y scores 68%. You're choosing between them for a production code-review automation system on your team's TypeScript monorepo. What's the right interpretation?

  • X is clearly better; choose X.

  • The 5pp gap is within benchmark noise; choose based on price and integration.

  • SWE-bench Verified measures Python issue-resolution, which is a different distribution from TypeScript code review; the benchmark is weak signal for your task.

  • Run both on a private eval set built from your team's actual code-review history before deciding.

Correct. Both options 3 and 4 are reasonable, but option 4 is the practitioner-correct answer. SWE-bench Verified measures a specific task type (issue resolution on Python repos); code review on TypeScript is a different distribution. The 5pp gap on the public benchmark may not transfer at all. The right discipline (Week 8): build your own eval. 30-50 historical code-review cases, run each agent on them, measure something close to what you actually care about (correctness of suggestions, false-positive rate, useful-feedback rate). Public benchmarks are a useful prior — they tell you which agents are in the candidate set. They are weak evidence for performance on your task. Skipping the private eval and choosing on SWE-bench score is a common, expensive mistake.


8. Production patterns

The 2026 production patterns that have stabilized:

For multimodal:

For code agents:

The combined pattern: multimodal code agents. UI-aware code agents that can take screenshots of broken pages, read error messages from images, generate code based on Figma designs. Frontier in 2026; production in 2027 probably. Browser-using agents are the current rough state of the art (Claude with Computer Use, OpenAI Operator).

The cost discipline reminder. Both multimodal and code agents amplify the cost equation from Week 9. A code agent that takes 20 turns at 50k tokens each at Opus pricing costs $25/task. The same task with Sonnet and tighter context: $5. The same with Haiku for routing and Sonnet for hard parts: $1.50. The optimization order from Week 9 matters more here, not less.


Build this week

Pick at least two:

  1. Build a document understanding pipeline. Take a stack of 100 invoices (or any structured docs). Build OCR-then-LLM and pure-VLM versions. Compare cost, accuracy, latency. Make the architecture decision with data.

  2. Implement frame sampling for a video task. Take a 5-minute video. Try 1 fps, 0.25 fps, scene-detection-based sampling, and audio-first-then-frames. Compare cost and quality of the resulting analysis.

  3. Set up a code agent against a real (small) project. Use Claude Code or build a minimal version with the tool stack. Pick 5 GitHub issues from your own backlog. Measure: how many resolved? Cost per resolution? Where did it get stuck?

  4. Build a private SWE-bench-style eval. 20 cases from your own codebase or historical bug fixes. Run two code agents (or two prompt variants) and compare. This is your Week 8 discipline applied to code.

  5. Read three real code-agent traces. Find published Claude Code or Cursor session traces (or run your own). Categorize the failure modes. What separates good runs from wandering ones?


Read this


Interview prompts

  1. Walk through how you'd design a production document understanding pipeline at 1M docs/month.
  2. When does the cost equation favor pure-VLM vs OCR-then-LLM?
  3. Why is video so much more expensive than images, and what are the optimization levers?
  4. Describe the canonical code-agent loop. What tools are essential?
  5. What's the role of the sandbox in code agents, and what happens without one?
  6. How would you read a published SWE-bench score? What does it tell you, what doesn't it?
  7. What separates a production code agent from a benchmark-passing one?
  8. How do you manage context in long-running code agent sessions?
  9. When should you use audio-direct models vs Whisper-then-LLM?
  10. What's the trust progression for deploying a code agent — and where would you stop?

What "done" looks like

By the end of this week you should be able to:

If you can do those, you're ready for Week 11 — symbolic reasoning and reliability — where we cover the techniques (verifiers, tool use, retrieval-grounding, formal methods integrations) that make LLM systems reliable enough for high-stakes deployment. Multimodal and code agents both need these techniques; the next two weeks make them rigorous.