Free self-study · No account needed · Progress stays in this browser. Back it up before clearing site data or changing devices.

← Week 13: Multi-Agent Architecture

Week 13 / Lesson 1

Choosing an agent team structure

Select a team arrangement only when its division of work helps the task.

Section 1.1 1 of 7

Overview

Focus

Select a team arrangement only when its division of work helps the task.

Your route through the lesson

  • 1.2 Manager and worker arrangements
  • 1.3 Supervisors, specialists, and sequential pipelines
  • 1.4 Parallel tasks and coordination overhead
  • 1.5 Put it into practice
  • 1.6 Guided comparison
  • 1.7 A tightly coupled task that resists parallel work

All required teaching is included here. Review selections are saved. Choose a correct answer for every question to continue; retries are unlimited. Study time and personal notes are optional.

Section 1.2 2 of 7

Manager and worker arrangements

Focus

Choose a manager and worker arrangement by locating decisions and evidence.

A manager divides a request, assigns bounded work, and decides whether the combined result meets the original goal. A worker receives inputs and returns an artifact. These are responsibilities, not different kinds of model. One process can fill both roles. Giving three copies of the same prompt three impressive job titles does not create useful specialization.

Consider checking three independent invoices. A single assistant can inspect each invoice and combine the results. A manager can instead assign one invoice to each worker, then check that all three invoice identifiers appear exactly once. The team gains an opportunity to overlap waiting, but adds assignment messages, result collection, and a final coverage check. Missing coverage remains the manager's responsibility.

Measure the same fixed tasks under both arrangements. Count successful invoices, all model calls including retries, elapsed time from request to final result, and coordination messages. A team scoring three of three while using nine calls has different economics from a single assistant scoring three of three with four calls. Those measurements establish a comparison on the tested tasks, not a general law that teams improve intelligence.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. A manager assigns invoices A, B, C; workers return A, A, C. What check is missing?
2. Two arrangements both solve 8 of 10 cases. Team uses 18 calls; single uses 9. What follows?
3. One model plans and executes in the same process. Can it have manager and worker responsibilities?

Section 1.3 3 of 7

Supervisors, specialists, and sequential pipelines

Focus

Distinguish supervisory checks, specialist knowledge, and ordered pipeline stages.

A supervisor routes work or checks progress against a contract. A specialist contributes a particular method, such as validating arithmetic or interpreting a schema. A sequential pipeline orders stages because later stages require earlier outputs. These dimensions can coexist: a supervisor may oversee a pipeline whose stages are specialists.

For an invoice workflow, extraction produces line items, calculation produces a subtotal, and verification compares that subtotal with the source. Calculation cannot responsibly start from an extraction that has not completed. Verification should inspect the original line items and independently compute the sum; merely asking the calculator whether it feels confident adds little evidence. A supervisor can reject an extraction missing currency before forwarding it.

The useful boundary is an explicit artifact: invoice identifier, input version, line items in cents, and unresolved fields. A specialist should return missing evidence rather than invent it. If the document omits tax jurisdiction, no number of handoffs supplies that fact. Routing to a person or requesting a narrower supported result is a valid terminal outcome. Increasing role count without a distinct method or authority boundary increases coordination work without establishing a benefit.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Extraction must produce line items before calculation. Which arrangement represents this dependency?
2. A verifier independently sums original line items. What makes its role useful?
3. A document omits tax jurisdiction. What should a bounded specialist return?

Section 1.4 4 of 7

Parallel tasks and coordination overhead

Focus

Estimate parallel work using dependency time and measured coordination overhead.

Independent work can overlap; dependent work cannot. If three independent lookups each wait two seconds, sequential waiting takes approximately six seconds. Perfect overlap takes approximately two seconds before coordination. If dispatch and integration add one second, the team takes approximately three seconds. The critical path is the longest chain of dependent stages, including required integration, rather than the sum of every worker's duration.

Python's standard library module concurrent.futures manages submitted functions. ThreadPoolExecutor creates a bounded pool of threads; a thread is a flow of execution sharing the process memory. Its map method applies a function to each input and returns results in input order. The with statement closes the pool after its work finishes. These threads are useful for this waiting demonstration; they do not establish faster processor-heavy Python computation.

The supplied lab measures both paths with time.perf_counter, a clock for elapsed durations. It deliberately sleeps for short intervals to represent waiting and checks equal numeric outputs. Actual timing varies with scheduling and machine load. Treat a smaller elapsed value as a local observation. The fixture proves overlap and result collection; no language model participates. Python executor documentation explains the pool interface.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Three independent two-second tasks overlap; integration takes one second. Ideal total?
2. A two-second extraction precedes a three-second calculation. Can both finish in three seconds by adding threads?
3. A sleep-based thread fixture is faster than sequential waiting. What did it demonstrate?

Section 1.5 5 of 7

Put it into practice

Focus

Run one controlled baseline and team comparison and interpret its reported evidence.

Download week13.py, save it as week13.py in an exercise folder, and run python week13.py --lesson 1. No package installation, account, network connection, or model download is required. The small processor-only run uses three waits of 0.02 seconds and should finish within seconds. The script creates and removes a temporary folder automatically. Its functions are trusted fixtures; it does not execute agent-generated code.

Before reading the output, understand the fixed input. The pairs (2, 3), (4, 5), and (7, 1) have sums 5, 9, and 8. Both arrangements must return those three results in that order. Python assert raises an exception if an invariant is false; a traceback identifies the failing assertion. json.dumps converts the measurement dictionary into printable structured text. The report includes measured durations, three baseline calls, three worker calls, and two declared coordination messages. Calls here mean simulated task invocations.

The single practice is to run this supplied comparison and use its output to choose an arrangement for these fixtures. Keep success, duration, and coordination separate. The correct conclusion can favor the simpler arrangement if timing differences are negligible for the intended workload.

Download this week’s Python lab ↓

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. The Week 13 fixture returns [5,9,8] from both arrangements. What invariant passed?
2. A comparison reports team_seconds=0.03 and baseline_seconds=0.06. How should it be reported?
3. Which command runs only the team-structure portion of the saved weekly script?

Section 1.6 6 of 7

Guided comparison

Focus

Explain the completed comparison without confusing simulated calls with model quality.

The worked comparison has a simple correctness baseline: sum each pair and preserve input order. Sequential execution yields 5, 9, 8. The pool returns the same sequence even if a later pair finishes first, because map exposes results in input order. This property differs from collecting whichever future finishes first, which would require carrying task identifiers to restore coverage.

Suppose an observed run takes 0.061 seconds sequentially and 0.023 seconds with the pool. The elapsed reduction is 0.038 seconds. Both paths invoke the worker three times, so worker work has not disappeared. The team also incurs the explicit dispatch and integration accounting. Those message counts illustrate coordination categories; they are not measured language-model messages or priced tokens.

The observed advantage comes from overlapping harmless waits. A failed assertion would invalidate the success claim even if the team were very fast. An exception from a worker must be surfaced when its result is collected. A complete report therefore states equal fixture success, measured times, invocation counts, and the absence of a model integration. Replacing the fixed worker with a real model later requires a fresh evaluation of task outcomes, retries, costs, and safety boundaries.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Team time falls by 0.038 seconds while both paths invoke three workers. What changed?
2. A worker raises an exception before the final sum is collected. Which report is valid?
3. A team reports only its fastest successful task time. What is absent?

Section 1.7 7 of 7

A tightly coupled task that resists parallel work

Focus

Apply the structure decision to a task whose outputs depend on shared decisions.

A tightly coupled task resists division when each part needs decisions still being made elsewhere. Consider changing an event schema and its parser. Worker A renames timestamp to created_at while worker B writes validation against the old timestamp field. Both pieces can look sensible in isolation, yet their combination fails. Their uncertainty is shared, so overlapping edits create integration work rather than independent progress.

A better worked arrangement first freezes the schema contract: created_at is a whole number of seconds, version 2, and missing timestamps are rejected. A single owner publishes that contract. Parser and validator work can then proceed independently against the same version, followed by an integration check. If the schema cannot be frozen because requirements remain unresolved, sequential design and implementation may be cheaper.

This example transfers the comparison beyond invoice lookups. The decision variable is independence of inputs and ownership, not how many available agents exist. Four workers waiting for a changing contract are not four independent tasks. Measure rework messages and rejected versions as coordination cost. A baseline remains useful: one agent may complete a small coupled change with fewer handoffs while achieving the same checked behavior.

// Quick review

Check your understanding.

Choose an answer for immediate feedback. Retry freely; a correct answer for every question unlocks the next section.

1. Parser expects timestamp; validator expects created_at. What should be settled first?
2. Four workers all wait for an unresolved schema. How many independent implementations are ready?
3. A small coupled change takes one agent four calls and a team twelve with equal success. Reasonable choice?

Your personal notes

Optional, ungraded, and saved only in this browser. Export a backup from the Academy homepage to keep them.

References and further reading
Ask your own AI assistant

Copy this prompt into an assistant you already use. Nothing is sent automatically, and your personal notes are not included.

Next lesson: Handing off work through durable artifacts →