One tool beats two: how combining fetch and extraction fixed my agent's context overflow

OkShirt9372 · reddit · 2026-10-06

A developer building a lead-gen agent with the OpenAI Agents SDK and ZenRows hit a hard limit: fetching and extraction as separate agent tools pushed a 540K-character directory page into the model context and overflowed it.

The fix was merging steps into single tools:

The four underlying functions remain independently testable; large intermediates stay in Python, a failed enrichment retries a single lead, and one bad URL no longer kills the run. 429s trigger retry instructions while 403s tell the agent to stop retrying, and the agent follows a fixed discover → qualify → sort → return sequence.

On a Clutch page the pipeline extracted 78 companies and scored the top 10 in under 20 seconds each; the reasoning proved more useful than the scores by flagging missing evidence (e.g., case studies without named clients). The author closes by asking: for multi-step agents, where should the line between model orchestration and deterministic code sit?

Original post →

More from coding & agent

coding & agent channel →