Communicating With an Agent

Claude Code Agents: Fundamentals

Chapter 3 · Communicating With an Agent

Chapter 1 warned that a subagent starts cold, with no memory of your prior conversation, and promised this chapter would cover the actual skill of briefing one well. This chapter delivers on that — how to write a brief an agent can actually act on, how to choose between running it in the foreground or the background, and how to read what it hands back without over-trusting it.

What a Good Brief Actually Contains

A brief that only states the goal ("fix the bug") gives an agent starting from nothing to work with. A brief that actually succeeds includes:

  • What you're trying to accomplish, stated plainly, and why it matters
  • What you already know — file paths, specific line numbers, what you've already tried or ruled out — so the agent doesn't waste its own effort rediscovering ground you've already covered
  • Constraints — what NOT to do, any approach already rejected, anything that must stay unchanged
  • What form the result should take — a short summary, a specific list, a completed edit — so you get back something you can actually use directly

A useful habit: write the brief as though you're handing the task to a genuinely capable colleague who has never seen this codebase before — because that's functionally exactly what's happening.

Name exact files and line numbers, not vague descriptions
"The auth file" forces an agent to spend part of its own effort just locating what you meant. "src/auth/login.ts, around line 42" removes that ambiguity entirely, and lets the agent spend its effort on the actual task instead of on figuring out where to even start.

Foreground vs. Background Invocation

An agent can run in the background — continuing independently while you keep working or talking about something else, with its result arriving later as a notification — or in the foreground, which pauses the conversation until the agent finishes and returns its result immediately. Background is the natural default for anything exploratory or open-ended, since it doesn't block you from doing anything else in the meantime. Foreground makes sense specifically when you genuinely need the agent's result before you can take the very next step — a research question whose answer determines what you do next, for instance, rather than something you could just as easily review once it's ready.

AspectBackgroundForeground
While it runsYou can keep working on other thingsThe conversation waits for it to finish
When its result arrivesLater, as a notificationImmediately, before anything else continues
Best suited forExploratory or independent workA result you need before your very next step

What Comes Back: The Agent's Final Report

You don't see an agent's own internal reasoning or every tool call it made along the way — only the final report it returns once its task is finished. That report is a summary written by the agent itself, describing what it did.

Trust, but verify — a summary describes intent, not a guarantee
An agent's own final report describes what it intended to do and believes it did — it is not automatically proof that the work is correct or complete. Before treating an agent's work as finished, check the actual result directly (the real diff, the real file, the real output) rather than accepting the summary at face value. This matters more, not less, the more consequential the task was.

Don't Race Ahead of a Background Agent

Once a background agent is launched, its results are genuinely unknown until its completion notification actually arrives — in a later turn, not the current one. Continuing to describe, predict, or act as though you already know what it will find is a mistake worth actively avoiding: if a background agent hasn't reported back yet, the honest answer is that it's still running, not a guess dressed up as a result.

Continuing a Conversation With an Agent

An agent that has already finished a task isn't necessarily gone for good — sending it a follow-up message resumes that same agent with its own full context from the earlier run intact, which is different from launching a brand-new agent of the same type, which starts cold again with no memory of what came before. Choosing to resume an existing agent versus starting fresh depends on whether the follow-up genuinely builds on what that agent already did, or is really a new, unrelated task.

Hands-On Exercises

Exercise 1

Rewrite the brief "fix the login bug" into a genuinely well-formed brief, following this chapter's own list of what a good brief contains.

📄 View solution
Exercise 2

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.

📄 View solution
Exercise 3

An agent's final report says "successfully updated all references to the renamed function." Explain, using this chapter's own warning box, what you should do before accepting that this task is actually finished.

📄 View solution

Chapter 3 Quick Reference

  • A good brief states the goal, known context (exact files/lines), constraints, and the expected form of the result
  • Background runs independently, result arrives later — the default for exploratory work
  • Foreground blocks the conversation until finished — use only when you need the result before your very next step
  • An agent's final report describes what it believes it did — verify the actual result before treating a task as complete
  • Never predict or fabricate a background agent's results before its notification actually arrives
  • A follow-up message can resume an existing agent with its own context intact — a new agent of the same type starts cold again