From: aidotengineer
OpenAI anticipates that 2025 will be the “year of Agents,” marking a significant shift where generative AI transitions from being merely an assistant to becoming a co-worker [00:08:04]. Through collaborations with customers and internal teams developing agentic products, OpenAI has identified key patterns and anti-patterns in agent development [00:08:48].
Defining an AI Agent
An AI agent is an application composed of a model that receives instructions (typically via a prompt) and has access to tools for information retrieval and interaction with external systems [00:09:04]. This entire process is encapsulated within an execution loop, whose termination is controlled by the model itself [00:09:16].
In each execution cycle, the agent:
- Receives natural language instructions [00:09:28].
- Determines whether to issue tool calls [00:09:29].
- Runs those tools [00:09:33].
- Synthesizes a response using the tool’s return values [00:09:34].
- Provides an answer to the user [00:09:39].
- May terminate the execution loop if its objective is met [00:09:43].
Best Practices for Building AI Agents
OpenAI’s experience has yielded four primary lessons for developing AI agents:
1. Start with Primitives, Abstract Minimally
When designing an AI agent, you can either start with raw API calls (primitives) or use a pre-built framework [00:10:07]. While frameworks offer a quick start and easy proof-of-concept [00:10:23], they often obscure how the system behaves or what underlying primitives are used, leading to deferred design decisions before understanding constraints [00:10:37]. Without knowing your constraints, optimizing the solution becomes difficult [00:10:48].
A more effective approach is to:
- Begin by building with primitives [00:10:53].
- Understand how the task decomposes [00:10:56].
- Identify failure points and areas needing improvement [00:10:58].
- Only introduce abstraction when you find yourself reinventing the wheel (e.g., re-implementing embedding strategies or model graders) [00:11:05].
The focus should be on understanding data, failure points, and constraints, rather than on choosing the “right” framework [00:11:28]. The goal is to start simple, optimize as needed, and abstract only when it enhances the system [00:11:35].
2. Start Simple, Scale Incrementally
Teams often prematurely jump into designing complex multi-agent systems, which can create many unknowns and limit insights [00:11:48]. A recommended approach is to:
- Start with a single agent purpose-built for a specific task [00:12:08].
- Deploy it into production with a limited user set [00:12:16].
- Observe its performance to identify real bottlenecks, such as hallucinations, low adoption due to latency, or inaccuracy from poor retrieval [00:12:21].
- Incrementally improve the system based on identified underperformance and user needs [00:12:35].
Complexity should only increase as more intense failure cases and constraints are discovered [00:12:44]; the ultimate goal is a functional system, not a complicated one [00:12:51].
3. Leverage Networks of Agents and Handoffs for Complexity
For more complex tasks, a network of agents combined with handoffs can be highly effective [00:13:07].
- Network of Agents: A collaborative system where multiple specialized agents work in concert to resolve complex requests or perform interrelated tasks [00:13:17]. These specialized agents handle sub-flows within a larger agentic workflow [00:13:31].
- Handoffs: The process by which one agent transfers control of an active conversation to another agent [00:13:39]. This is analogous to a phone call transfer but allows the entire conversation history to be preserved, enabling the new agent to seamlessly continue the interaction [00:13:53].
This approach ensures the right tools are brought to the right job [00:14:12]. For example, in a customer service flow, a cheaper, faster model like GPT-4o Mini can perform initial triage, while a more capable model like GPT-4o manages the main conversation, and a reasoning-optimized model handles accuracy-sensitive tasks like refund eligibility checks [00:14:16]. Handoffs, by maintaining context while swapping models, prompts, and tool definitions, provide sufficient flexibility for a wide range of scenarios [00:14:39].
4. Implement Guardrails in Parallel
Guardrails are mechanisms that enforce safety, security, and reliability within an application, preventing misuse and maintaining system integrity [00:14:55].
Key recommendations for guardrails:
- Keep model instructions simple and focused on the target task to ensure maximum interoperability and predictable accuracy/performance improvements [00:15:12].
- Do not make guardrails part of your main prompts [00:15:25]. Instead, run them in parallel [00:15:29]. The availability of faster and cheaper models (e.g., GPT-4o Mini) makes this parallel execution more accessible [00:15:33].
- For high-stakes tool calls or user responses (e.g., issuing refunds, displaying personal account information), defer execution until all guardrails have returned their results [00:15:42].
For instance, an input guardrail can prevent prompt injection, while output guardrails validate the agent’s response [00:15:57]. By keeping prompts focused on the “happy path” and using guardrails for edge cases, systems become more robust [00:16:19].
These lessons form the foundation for effective and scalable AI agent development, addressing many challenges and solutions in building AI agents and providing strategies for effective AI implementation [00:16:09].