Skip to content
AgenticAIWiki
  1. Learn
  2. Part 8
  3. 43. Subagents
  4. 43.5

Lesson 43.5 · 5 of 5 · 5 min read · Reviewed 24 Nov 2026

Handling partial failure

By the end, you can

  • Plan how a multi-subagent task behaves when some subagents fail.
  • Combine partial results while marking what is missing.

Run five subagentsSubagent: A separate agent instance, with its own context and instructions, that a main agent delegates a task to. and sooner or later one will fail. Decide what happens before it does.

Required or optional

For each subagent, decide whether the task can finish without it. A security review can’t skip the authentication module. A market scan can skip one optional region.

A simple policy

  1. Retry a failed subagent once or twice, if the error is retryable.
  2. If it still fails and its part is required, stop and report clearly.
  3. If its part is optional, continue, and mark the gap in the result.

Mark the gaps

The final answer should say what is missing: “Covered EU, US and APAC. LATAM data was unavailable (source timed out).” Readers and downstream code can then act on it. Add a field such as coverage to structured results so the gap can’t be lost in prose.

Watch the cost

Retries of large subagents are expensive. Put a budget on the whole run, not just on each subagent.

Key points

  • Decide up front which subagent results are required and which are optional.
  • Retry failed subagents a limited number of times, then continue with what you have if the task allows.
  • Always say which parts are missing, so nobody mistakes a partial answer for a complete one.
Hands-on labRuns in the Playground

Finish well when one subagent fails

Apply a partial-failure policy: limited retries, required versus optional parts, and a coverage field that records every gap.

You will have: A coordinator that runs region subagents with retries and returns a result with a coverage field, for one run that can finish and one that must stop.

Steps

  1. Read the region subagents: each has a required flag and a scripted list of outcomes per attempt.
  2. Retry a retryable failure up to 2 times, counting attempts against a run budget.
  3. If a required part still fails, stop and report clearly.
  4. If an optional part fails, continue and record it under coverage as missing.
  5. Print both runs' results.

Done when

  • The first run finishes with LATAM listed as missing in coverage.
  • The second run stops because the required EU part failed.
  • APAC succeeds on its retry, and the attempt count shows it.

Open in the Playground No API key needed.

Starter code (Python)
def make(outcomes):
    it = iter(outcomes)
    return lambda: next(it)

def run(regions, max_retries=2):
    coverage = {"covered": [], "missing": []}
    for name, required, fn in regions:
        # TODO: try up to 1 + max_retries times while the outcome is "timeout"
        # TODO: required failure -> stop; optional failure -> record in coverage["missing"]
        coverage["covered"].append(name)
    return {"status": "complete", "coverage": coverage}

run1 = [("EU", True, make(["ok"])), ("US", True, make(["ok"])), ("APAC", False, make(["timeout", "ok"])),
        ("LATAM", False, make(["timeout", "timeout", "timeout"]))]
print(run(run1))
Show a solution
def make(outcomes):
    it = iter(outcomes)
    return lambda: next(it)

def run(regions, max_retries=2):
    coverage = {"covered": [], "missing": []}
    attempts_used = 0
    for name, required, fn in regions:
        for attempt in range(1, max_retries + 2):
            attempts_used += 1
            outcome = fn()
            if outcome != "timeout":
                break
        if outcome == "ok":
            coverage["covered"].append(f"{name} (attempt {attempt})")
        elif required:
            return {"status": "stopped", "reason": f"required part {name} failed after {attempt} attempts", "coverage": coverage}
        else:
            coverage["missing"].append(f"{name}: source timed out")
    status = "complete" if not coverage["missing"] else "partial"
    return {"status": status, "attempts": attempts_used, "coverage": coverage}

run1 = [("EU", True, make(["ok"])), ("US", True, make(["ok"])), ("APAC", False, make(["timeout", "ok"])),
        ("LATAM", False, make(["timeout", "timeout", "timeout"]))]
run2 = [("EU", True, make(["timeout", "timeout", "timeout"])), ("US", True, make(["ok"]))]
print("run 1:", run(run1))
print("run 2:", run(run2))
Quick checkFour of five research subagents succeed; one fails after retries. Its topic is optional. What should the parent do?
How sure are you?
Pick an answer and how sure you are

Finished the chapter? Take the chapter check.