Статья ещё не опубликована на языке Russian. Показана версия на English.
Agent Execution Patterns: ReAct, Plan-and-Execute, and Bounded Tool Loops
Опубликовано
2 мин на чтение
Not every agent needs the same control loop. Choosing the right orchestration topology determines whether an agent finishes in 2 seconds with 98 percent reliability or burns 15 tool calls chasing its own tail.
Comparing Core Agent Patterns
| Pattern | Control Flow | Latency & Cost | Best Fit |
|---|---|---|---|
| Single-Turn Tool Call | 1 model call -> execute tools -> 1 synthesis call | Fastest, cheapest | Support lookups, order checks, calendar queries |
| Bounded ReAct Loop | Interleaved reason -> act -> observe (cap 3-6 steps) | Moderate | Investigative analytics, multi-source diagnosis |
| Plan-and-Execute | Planner creates explicit DAG/list -> workers execute steps | Higher setup, predictable execution | Multi-step campaign setup, report synthesis |
| Router + Specialist Sub-Agents | Dispatcher delegates to narrow domain toolsets | Low tool confusion | Broad workspace assistants spanning many domains |
Why Parallel Tool Calling Matters
When a user asks "Compare my last 30 days of campaign spend with replied conversations," a sequential loop doubles wall-clock latency by waiting for tool A before requesting tool B. Encourage the model to emit independent read-only tool calls in parallel, and execute them concurrently with Promise.allSettled so one partial failure does not discard successful tool results.
ts
export async function executeToolBatch(
calls: ToolCall[],
executor: (call: ToolCall) => Promise<unknown>
): Promise<ToolResultMessage[]> {
const settled = await Promise.allSettled(calls.map(call => executor(call)));
return settled.map((result, idx) => ({
toolCallId: calls[idx].id,
ok: result.status === "fulfilled",
payload:
result.status === "fulfilled"
? result.value
: { error: String(result.reason), retryable: false },
}));
}
Preventing Premature Loops
- Hide irrelevant tools dynamically: passing 35 tools into every turn confuses selection and inflates input tokens; expose only tools permitted for the current user role and connected integrations.
- Synthesize gracefully on budget exhaustion: if the step cap is hit, make one final tool-free LLM call summarizing what was already gathered instead of throwing a raw 500 error.
Next: craft tool interfaces that models call accurately on the first try in Designing Reliable LLM Tool Schemas.
Было ли это полезно?