AI agent architecture: 5 questions before writing code A developer outlined a five-question framework for designing AI agent architecture before writing any code, covering task division between agents and programs, execution environment, available data, desired outcome, and result delivery. The approach is illustrated with an Instagram Direct AI sales assistant that splits responsibilities between Python, which enforces a conversation script and validates collected information, and Claude, which draws on instructions and a knowledge base to generate replies, with a human doctor confirming appointments routed to Telegram. I always start an AI system's architecture by analyzing the problem we need to solve and the data we have. That determines which platform should run the automation and which tools to use Choosing a solution means answering five questions Who does what: an AI agent, a Python program, or a combination of solutions Where the work happens: on a remote virtual private server VPS , on a computer, or somewhere else What data is available: where requests come from and which knowledge base the system can use What result we want: an appointment, an inquiry, or another action How we receive that result: where it arrives, in what form, and how often These answers define the architecture: what each component does, where it runs, which data it receives, and what it passes on. The choice of tools follows their roles in that workflow For example, my AI sales assistant for Instagram Direct uses this division of responsibilities. It needs both a natural conversation with the client and strict adherence to a script. The solution therefore combines Python code and Claude, each with a different job Python controls progress through the script: has all the required information been collected, and does the model's response stay within the defined boundaries? Claude uses its instructions and the knowledge base to determine what to say to the client The conversation script and the knowledge base have different roles in this architecture. The script defines the workflow with the client and the information that must be collected. The knowledge base supplies the content for answers. Code and the model connect those parts: a natural conversation still has to follow the defined script The other parts connect to the intended outcome as well: requests arrive through Instagram Direct, and the information collected during the conversation goes to the doctor as a card in Telegram. The appointment is created after the doctor's confirmation. A person therefore belongs in the workflow too, retaining that decision This defines the AI system architecture: responsibilities are divided between code, the model, and a person; the required data and the path to the intended result are defined. And notice that all these decisions happen before the first line of code