- Core components of an agent: 1. Model - an LLM that makes decisions. 2. Tools - APIs, functions, UI actions. 3. Instructions - description of behavior and constraints. Example (Python): python CopyEdit Model selection Different models fit different tasks: you don't always need the "smartest" one. Approach: - Build a prototype on the strongest model. - Then try replacing tasks with less expensive models. Principles:
- Run eval tests.
- Use the best models for critical logic. 3.
Optimize cost and latency by downgrading the model where possible. OpenAI model selection guide Defining tools. Tools are the APIs and functions an agent can call. If no API exists, use UI interactions the way a human would. Tool types:
| Type | Purpose | Examples |
| Data | Context retrieval | Search across database, PDF, and the internet |
| Actions | State change | Email, CRM update |
| Orchestration | Calling other agents as tools | writer agent, researcher agent |
Example: python CopyEdit Setting up instructions. Clear instructions are the key to success. The more specific they are, the fewer errors occur. Best practices: - Reuse existing procedures and guidelines. - Break tasks into step-by-step actions. - Define clear actions and outcomes. - Account for exceptions and edge cases (e.g., if the user did not provide data). Example of generating instructions: text CopyEdit "You are an expert at writing instructions for an LLM agent.
Turn the following knowledge base document into step-by-step instructions as a list. Make sure everything is clear and unambiguous." Orchestration. Orchestration is the structure for how a task is executed by an agent or a group of agents. Options: 1. Single agent - runs the entire process. 2. Multiple agents - split responsibilities and call each other. Single agent Manages all tools and logic.
Runs in a loop until the task is complete. python CopyEdit Agents.run(agent, [UserMessage("What's the capital of the USA?")]) You can use templates: python CopyEdit "You are a call center agent talking to {{user_first_name}}.
Their complaints are about {{user_complaint_categories}}..." When to split into multiple agents: - Complex logic (many conditions). - Tool overload. - Separation by task (search, generation, verification, etc.) Multiple agents Patterns: 1. Manager - a central agent calls subordinate agents. 2. Decentralization - agents hand off control to each other. Manager pattern python CopyEdit Decentralized pattern python CopyEdit