#29Plan → execute → synthesizeMedium

Plan → execute → synthesize

Background

The v0.4 agent orchestrates three phases: plan the query into sub-questions, execute each one (collecting a finding), then synthesize all findings into a final answer.

query → planner → [sq1, sq2, …] → execute each → {sq: finding} → synthesizer → answer

Problem statement

Implement plan_execute_synthesize(query, planner, executor, synthesizer).

Input

  • query — the original research question.
  • planner — callable query -> list[str] of sub-questions.
  • executor — callable sub_question -> str (a finding).
  • synthesizer — callable (query, findings_dict) -> str.

Output

Returns the synthesizer's final answer. Internally:

  1. subqs = planner(query).
  2. findings = {sq: executor(sq) for sq in subqs} (in plan order).
  3. return synthesizer(query, findings).

Examples

Example 1

planner     = (q -> ["a", "b"])
executor    = (sq -> f"answer-{sq}")
synthesizer = (q, findings -> findings)
plan_execute_synthesize("Q", planner, executor, synthesizer)
# -> {"a": "answer-a", "b": "answer-b"}

Constraints

  • Execute every sub-question, in plan order, building {sub_question: finding}.
  • Pass the original query and the findings dict to synthesizer.
  • Return whatever synthesizer returns.

Notes

  • Coverage is structural: every planned sub-question is executed. The executors are independent — which is exactly what makes parallelism possible next lesson.
Python
Loading...

▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.

  • Reference example: findings cover every sub-question in order
  • Sample: synthesizer receives the original query and findings
  • Example: an empty plan yields empty findings