Stop Making Agents Do Complex Logic: Keep It in Code
sapnesh · reddit · 2026-08-06
A developer points out that many AI agent tools are just 1:1 API wrappers, causing models to take the blame for poor tool design.
The author argues that providing granular endpoints like search, create, and update forces the agent to handle branching logic, pushing deterministic if/else decisions into the least deterministic part of the system. A single upsert tool is far more reliable.
Recommended best practices for production agents:
- Pass known context (like user ID) directly instead of making the agent fetch it.
- Return only the fields the agent needs, not the entire API response.
- Validate inputs within the tool code before hitting the external API.
- Return structured errors rather than generic 500s.
- Only expose tools that are relevant to the current workflow.
For customer-facing agents taking real actions, developers should prefer fewer, task-specific tools over broad, provider-shaped endpoints.
More from coding & agent
- Podcast Preview: Designing Verifiable AI Data Agents with Hamel Husain — hugobowne · 2026-08-06
- Liquid AI Launches LFM2.5-2.6B: An On-Device Agentic Model — JosephJacks_ · 2026-08-06
- Multi-Agent Orchestration Beats Expanding Context Windows for Long Context — bingxu_ · 2026-08-06
- Autonomous Agent Incidents Force a Rethink of Security Threat Models — chrisrohlf · 2026-08-06
- Autonomous Agents Break Traditional Threat Models, Security Expert Warns — chrisrohlf · 2026-08-06
- Unpacking ChatGPT Work: The Agentic Architecture Behind 10M Users in 3 Weeks — iamrobotbear · 2026-08-06