AI for Investing
What an AI investing agent is made of
An AI agent is not magic. It is four components, and every pattern is a different way of arranging the same four.
The four components
The model is the LLM. It reads the question, decides what to do, reads the results, and writes the response. It does not know anything about your portfolio or today's prices. That is not its job. Its job is to pick the tools and make sense of what they return. Start with the cheap, fast models and move up only if you need to.
Tools are functions the model can call, its connection to the real world. A tool has three parts the model reads: a name, a signature (a ticker in, a price out), and a natural-language description of what it does and when to use it. That description matters more than it looks, because the model chooses which tool to call from your description. A vague one leads to wrong choices. Write it as if telling a new colleague when to use the function.
Instructions are the system prompt, the standing text that sets behaviour: you are a portfolio analysis assistant; always use tools for data and never make up prices; show your steps; when uncertain, say so. A common mistake is putting logic in them that belongs in a tool. "Calculate the Sharpe ratio" should not be an instruction. It should be a tool. Instructions are the recipe card; they do not do the cooking.
Memory is the conversation history. Without it, every question starts fresh: ask "what is my portfolio worth?", then "what if I sold half the NVDA?", and an agent without memory does not know which portfolio you mean. With it, the second answer is the useful one. Underneath, memory can be as simple as the list of messages so far, which the model sees in full each time.
Three kinds of tools
Not all tools are equal, and the difference is the whole risk picture. Market-data tools read: prices, company info, historical returns, with no side effects, so call one ten times and nothing changes. Calculation tools compute: Sharpe ratio, Value at Risk, a portfolio optimisation, with data in and results out and nothing touched outside. Both are safe to let the agent call freely; the worst case is wasted API calls. Action tools do things: place an order, send a client alert, rebalance a portfolio. They change the world, and calling twice means two orders. An agent that can place orders can lose money.
Read-only and pure computation: let the agent call it. Anything that changes the world: a human looks first.
Two habits make tools work. One tool, one job: five focused tools beat one do-everything tool, because the agent combines them as needed. And return structure, not prose: if the agent needs the result in a calculation, give it fields, not a paragraph.
How they work together
Ask "what is Apple's current P/E ratio?" and the sequence runs like this. Instructions, memory, and the question are assembled into one prompt. The model reads it, sees the tools available, and calls the fundamentals tool for Apple. Real data comes back. The model writes the answer, and the exchange goes into memory. Then the follow-up, "is that high for the sector?", and memory supplies the context, the model calls the same tool for two peers, and answers that at 28.5 Apple's P/E is moderate for tech, higher than Alphabet, lower than Microsoft.
That loop - read, decide, act, read the result, repeat - is the core of every agent, and the four patterns are variations on it. It is also how you debug one: wrong answers, check the tools; wrong tool picked, check the descriptions; forgetting context, check the memory; erratic, check the instructions.
Keep going
Next, the four patterns that arrange these components. Start at AI for investing for the whole picture, or get the full book, AI Agents for Investing, which builds the tools and the agent in code. I am publishing more in the coming weeks. Subscribe to get it.