К содержанию
Статья ещё не опубликована на языке 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

PatternControl FlowLatency & CostBest Fit
Single-Turn Tool Call1 model call -> execute tools -> 1 synthesis callFastest, cheapestSupport lookups, order checks, calendar queries
Bounded ReAct LoopInterleaved reason -> act -> observe (cap 3-6 steps)ModerateInvestigative analytics, multi-source diagnosis
Plan-and-ExecutePlanner creates explicit DAG/list -> workers execute stepsHigher setup, predictable executionMulti-step campaign setup, report synthesis
Router + Specialist Sub-AgentsDispatcher delegates to narrow domain toolsetsLow tool confusionBroad 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

  1. 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.
  2. 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.

Было ли это полезно?