Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Scaling AI Systems

Free · sign in to start and track progress

1 · Throughput under limits

  • 1Rate limits and quotas
  • 2Concurrency and flow control
  • 3Retries, backoff and overload
  • 4Backpressure, load shedding and batching

2 · Latency, resilience and capacity

  • 5Latency engineering for agents

    Exercise answers

    • Answer: Instrument and speed up a real agent turn
    • Answer: When is speculation worth it?
  • 6Response caching and failover
  • 7Load testing and capacity planning
CapstoneMonth-end readiness for an agent fleetReference implementation

Module 2 · Latency, resilience and capacity · Lesson 5

Latency engineering for agents

Where an agent turn's seconds go (queueing, time to first token, thinking, generation and tools), how to set a latency budget per step, and the levers that move each term, from streaming and parallel tool calls to cache pre-warming, prefetching and speculation.

75 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvGet an OpenRouter keyLocal models with Ollama

By the end of this lesson you can

  • Decompose the latency of a model call and of an agent turn into queueing, TTFT, thinking, generation and tool time
  • Measure TTFT, time to first visible text and output speed from a stream, and report percentiles rather than means
  • Set a latency budget per agent step from a user-facing target and identify which term dominates
  • Apply streaming, parallel tool calls, cache pre-warming, prefetching and output control, and compute what each saves
  • Decide when speculative execution or hedged requests are worth their cost in tokens and rate-limit capacity

On this page

  • Intuition: a restaurant order
  • Anatomy of one model call
  • Anatomy of an agent turn
  • Worked example: the covenant question
  • Setting a latency budget per step
  • Streaming and perceived latency
  • Parallel tool calls
  • Doing work earlier: pre-warming and prefetching
  • Guessing: speculation and hedging
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: a restaurant order
  2. 02Anatomy of one model call
  3. 03Anatomy of an agent turn
  4. 04Setting a latency budget per step
  5. 05Streaming and perceived latency
  6. 06Parallel tool calls
  7. 07Doing work earlier: pre-warming and prefetching
  8. 08Guessing: speculation and hedging
  9. 09Misconceptions and limits
  10. 10Connections
  11. 11Summary

Sources & further reading

  • DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model ServingPaper · Zhong et al. · 2024OSDI 2024. Defines serving quality as goodput under separate TTFT and time-per-output-token targets, and shows why the two phases compete. Read the introduction and background for the metrics this lesson uses.
  • An LLM Compiler for Parallel Function CallingPaper · Kim et al. · 2023ICML 2024. Plans a dependency graph of tool calls and runs independent ones in parallel; the evaluation shows the latency gain over sequential ReAct-style loops.
  • Speculative Actions: A Lossless Framework for Faster Agentic SystemsPaper · Ye, Ahuja, Liargkovas, Lu, Kaffes, Peng · 2025A faster model guesses the agent's next action and runs it in parallel, keeping the result only if the guess was right. Reports up to 55% next-action accuracy and up to 20% lower latency, with a cost-latency analysis of how many branches to launch.
  • The Tail at ScaleLab research · Jeffrey Dean, Luiz André Barroso · Google · 2013Communications of the ACM. Why rare slow responses dominate at scale, and tail-tolerant techniques such as hedged requests. Read it for the fan-out argument and the cost discussion.
  • How we built our multi-agent research systemLab research · Hadfield, Zhang, Lien, Scholz, Fox, Ford · Anthropic · 2025The "Parallel tool calling transforms speed and performance" principle, with parallel subagents and parallel tools cutting research time by up to 90% for complex queries.
  • Reducing latency (Claude API docs)Docs · AnthropicAnthropic's latency guidance: TTFT, choosing a faster model and effort level, shorter prompts and outputs, and streaming.
  • Parallel tool use (Claude API docs)Docs · AnthropicExecution semantics (you choose concurrent or sequential), returning all results in one user message, the prompt that encourages parallel calls, and disabling it.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 11 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks