Setting run_in_background: true on a Task call returns a task_id immediately. The agent starts running without blocking you. You can launch more agents, do other work, or just wait.
Once you're ready to check on it, ask Claude to retrieve the output using the task_id. The agent returns its full output when done, or whatever it has produced so far if it's still running.
Background agents run within your active session, so they stop when the session ends. I find this mode most useful for long research or refactor tasks where you want to start multiple agents and check results all at once.