Carlos Tapia

Agentic design patterns

Twelve patterns around the model call

5 act before the LLM is called, 4 after it, before its output takes effect, and 3 across turns. 7 of the twelve have a published measurement.

Before the LLM · 5

LLM call

After the LLM · 4

Across turns · 3

Before the LLM

Bounded observation

The model sees a window of the file and a summarised search, not the whole thing.

Evidence

SWE-agent, table 3: a 100-line window scores 18.0% against 12.7% for the full file; summarised search 18.0% against 12.0% iterative. SWE-bench points the same way: raising the BM25 context from 13k to 50k tokens lifts recall from 29.58 to 51.06 and drops resolution from 1.96% to 1.22% (Claude 2).

SWE-agent, arXiv 2405.15793 ↗ · SWE-bench, arXiv 2310.06770 ↗

Related: Filtered payload between roles · Check on edit, not at the end

Before the LLM

Role separation

One call reasons about the change, a second one writes the edit.

Evidence

Aider, code-editing benchmark, same model in both roles: Claude 3.5 Sonnet 77.4% → 80.5%, GPT-4o 71.4% → 75.2%. On the polyglot leaderboard (June 2025) the split does not always win: o3 (high) alone 81.3%, o3 (high) + GPT-4.1 as editor 78.2%, at lower cost.

Aider architect/editor ↗ · Aider polyglot leaderboard

Related: Filtered payload between roles · Dispatch separated from decision

Before the LLM

Filtered payload between roles

A sub-agent hands back its result, not its transcript.

Evidence

LangChain's default: “the sub-agent's final message is returned as the tool result.” Anthropic describes its research sub-agents as “intelligent filters” that condense what reaches the lead agent. No measurement isolates the effect.

LangChain docs ↗ · Anthropic, multi-agent research system

Related: Role separation · Reviewer without shared context · Bounded observation

Before the LLM

Dispatch separated from decision

Who works next is decided by rules (owner, priority, dependencies), not by a model call.

Evidence

No published benchmark compares deterministic dispatch of scoped tasks against LLM routing. The nearest work (arXiv 2606.28925) routes natural-language prompts, a different problem. The argument is cost: a routing call per step buys nothing when the scope is already known.

No published measurement

Related: Role separation · Bounded spend · Progress ledger · One writer, many readers

After the LLM

Deterministic gate before execution

The model proposes a tool call; a read-only check of the call and the current state can veto it before the write executes.

Evidence

Four pre-execution gates on τ²-bench airline (gpt-4o-mini, pass^1): 29.6% → 42.0%, +12.4 points (74 → 105 of 250, P = 0.0012); a 15-seed replication gives +12.3. It targets what the paper calls silent policy violations: the tool accepts a well-formed call and neither the tool nor the agent's report shows anything wrong.

Reason Less, Verify More ↗ · KDD 2026 workshop (KDD-ETAAI)

Related: Check on edit, not at the end · One writer, many readers

After the LLM

Check on edit, not at the end

Each edit is validated as it is written, not once the agent believes it is done.

Evidence

SWE-agent, table 3: editor with linting 18.0% against 15.0% without. With the check on, 51.7% of trajectories have at least one failed edit, and after the first failure the chance of eventually succeeding drops from 90.5% to 57.2% (§5.2, full SWE-bench, GPT-4 Turbo).

SWE-agent, arXiv 2405.15793 ↗

Related: Deterministic gate before execution · Reproduction test before the fix · Bounded observation

After the LLM

Reproduction test before the fix

A test that reproduces the bug decides which fix is kept.

Evidence

Agentless (SWE-bench Lite, GPT-4o), selecting among candidate patches: majority vote 25.67% → with regression tests 27.00% → with a reproduction test 32.00%. At Google, giving the reproduction test to the repair agent as input: 74% against 57% plausible fixes (17 against 13 of 23 bugs).

Agentless, arXiv 2407.01489 ↗ · Google, arXiv 2502.01821 ↗

Related: Check on edit, not at the end · Reviewer without shared context

After the LLM

Reviewer without shared context

The output is reviewed in a fresh session that never saw how it was produced.

Evidence

Cross-Context Review (30 artifacts, 150 injected errors): a fresh-session review reaches F1 28.6% against 21.7% for a second review in the same session (Holm-adjusted p = 0.004). It is not significantly ahead of a context-aware sub-agent review (23.8%) or a single same-session review (27.1%). One author.

Cross-Context Review, arXiv 2603.12123 ↗

Related: Filtered payload between roles · Reproduction test before the fix

Across turns

Progress ledger

A record of whether the team is advancing, with a stall counter that triggers a replan.

Evidence

Magentic-One (§4.1): each iteration the orchestrator answers five questions (done? looping? progressing? who next? what instruction?) and keeps a stall counter; above 2 it replans. The open question is what feeds the counter: the model's judgement, as in the paper, or deterministic signals. Not measured in isolation.

Magentic-One, arXiv 2411.04468 ↗

Related: First-class human interruption · Dispatch separated from decision · Bounded spend