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:
- discoverleads = fetch page → extract companies → return compact Lead records, so the model sees records, not raw pages
- qualifylead = enrich one lead → score it → return reasoning, keeping bulky website excerpts out of context
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?
More from coding & agent
- 'DOCX Will Be Replaced by Markdown Within 5 Years' Sparks Pushback from Formats Veteran — bytebot · 2026-10-06
- A browser tab refresh bug kept a server at 100% CPU for 4 days—load scaled with tabs squared — Ok_Negotiation_2587 · 2026-10-06
- Loop-engineering: 8 unattended agent loop patterns to run your repo while you sleep — JafarNajafov · 2026-10-06
- PowerPoint generation with Claude Projects context and Claude Code: near-zero manual edits — NirantK · 2026-10-06
- Pi Durable: An experimental harness for long-running agents — asankhs · 2026-10-06
- JojoScript: An open-source scripting language designed for LLMs to write data pipelines — panagos_stathis · 2026-10-06