CLAUDE CODE AGENTS: FUNDAMENTALS - Chapter 3, Exercise 2 Foreground or Background When the Very Next Step Depends on the Result ==================================================================================== QUESTION: You need a research agent's findings before you can decide your very next step in a task. Explain whether you should launch it in the foreground or the background, and why, using this chapter's own comparison. SOLUTION / EXPLANATION: This chapter's own comparison is direct on exactly this situation: foreground is the right choice specifically when you genuinely need the agent's result before you can take your very next step - which is exactly what's described here. Launching this research agent in the background would let you keep working on something else while it runs, but that only helps if there's a meaningful, independent next step available to work on in the meantime. Since the scenario states the very next step in this task depends entirely on what the research agent finds, there's nothing productive to do on this particular task until that result comes back - continuing to talk or act as though you already know the answer, before the agent has actually reported back, is precisely the mistake this chapter warns against under "Don't Race Ahead of a Background Agent." Running the agent in the foreground instead means the conversation naturally pauses until the agent finishes and returns its findings immediately - at which point you have the actual information needed to decide the next step, with no risk of guessing or proceeding on an assumption instead of a real result. So the correct choice is foreground, specifically because this chapter frames that choice around whether the result is needed before your very next step - not around how long the task might take or how important it is in the abstract. -------------------------------------------------------------------------- WHY THIS WORKS AS AN ANSWER: It applies the chapter's own stated criterion (whether the result is needed before the next step) directly to the scenario, rather than reasoning from task importance or duration, and explicitly connects the background alternative to the specific risk (racing ahead of results) the chapter names elsewhere.