-
Define the agent hierarchy. Establish three roles: a Planner that decomposes the global objective into sub-goals, one or more Information Seekers that execute tool calls (search, database queries, API calls, file operations), and a Writer that synthesizes retrieved evidence into structured output. Each role gets its own system prompt and tool permissions.
-
Implement the think-act-observe loop. Structure each iteration as: (a) Planner receives full history and reasons about what sub-goals remain, (b) Planner emits a structured plan with 1-3 concrete sub-goals for this iteration, (c) Information Seekers execute the tool calls specified by the plan, (d) observations are appended to shared history, (e) loop repeats until Planner emits a Terminate action.
-
Design the Planner for batch constraint extraction. Instead of letting the planner reason one step at a time, prompt it to analyze ALL constraints from the user query upfront and produce a ranked decomposition. Use a structured output format:
{
"constraints_extracted": ["constraint1", "constraint2"],
"sub_goals": [
{"id": 1, "goal": "...", "tools_needed": ["search"], "depends_on": []},
{"id": 2, "goal": "...", "tools_needed": ["db_query"], "depends_on": [1]}
],
"estimated_rounds": 3
}
-
Add structured tool-call validation. Before executing any tool call emitted by an agent, validate it against the tool's JSON schema. Check: (a) the tool name exists, (b) all required parameters are present, (c) parameter types match, (d) enum values are valid. On validation failure, return a structured error to the agent and request a corrected call -- do not silently fail or retry blindly.
-
Implement span-aware context management. In the prompt fed to each agent, clearly delimit observation history (read-only context) from the action generation region. Use explicit markers like <context>...</context> and <action>...</action>. When building multi-turn prompts, never interleave previous action attempts with new context -- keep all context tokens contiguous and all action tokens contiguous.
-
Track planner hit rate and convergence. Instrument your loop to record: (a) number of interaction rounds, (b) number of tool calls per round, (c) number of invalid/failed tool calls, (d) whether the planner revised a previous sub-goal (backtrack). Use these metrics to detect convergence problems early.
-
Set a maximum round budget with early termination. Cap the loop at T_max rounds (the paper uses 15). Implement early termination when the Planner determines all sub-goals are satisfied. The Planner should explicitly output either {"action": "ToolCall", ...} or {"action": "Terminate", "reason": "..."}.
-
Reduce redundancy via observation deduplication. Before each planning round, deduplicate observations that convey the same information from different tool calls. Summarize long observations into key findings. This reduces context window consumption and prevents the planner from re-exploring already-resolved sub-goals.
-
Handle the writer synthesis phase. Once the Planner terminates, pass all accumulated observations to the Writer agent with a structured prompt specifying the output format. The Writer should cite which observations support each claim, enabling traceability.
-
Test with ablations. Validate your pipeline by measuring: (a) accuracy with vs. without batch planning (step 3), (b) invalid tool-call rate with vs. without schema validation (step 4), (c) round count with vs. without span-aware context (step 5). Each should independently improve performance.