Skip to content

Summary: How an agent fetches its own data

For education only. This teaches multi-agent architecture using stock analysis as the example; it is not investment, financial, or trading advice.

An agent gathers for itself: given a small set of tools, it decides what to fetch, loops until it has enough, and stops on its own. This lesson opens the code of the open-source TradingAgents framework (anchored to one frozen snapshot, marked 7e9e7b8) and reads the market analyst to make that concrete. This summary is the scan-in-five-minutes version of the full lesson.

  • A tool lets a model act, not just answer. On its own a model only produces text. A tool is a function it may ask to call (fetch price history, pull news, read a balance sheet); the system runs the function and hands back the result, so the model can reach into the world.
  • The analyst gets a narrow toolbox. The market analyst is given exactly two tools (get_stock_data, get_indicators). Those tools are attached to the model with bind_tools, which is what lets the model ask to call them. Few, well-described tools keep the agent focused.
  • It runs a loop and sets its own pace. After the model responds, the system checks one thing: did it ask for a tool? If yes, the tool runs and the result loops back to the analyst, which decides again. There is no fixed number of steps; the agent keeps pulling data until it judges it has enough.
  • The stop condition is structural. When the model makes no tool calls and just writes prose, that prose is the report. “No tool call” is the agent’s way of saying “I am done.” The report is saved into shared state as the analyst’s one durable output.
  • A clean desk for the next analyst. When an analyst finishes, its working notes (the raw tool chatter) are wiped, leaving only the finished report. Each specialist works fresh and hands forward a tidy summary, not its scratch paper.

When you ask an AI to “go research X and report back,” you are really making two design choices: what it is allowed to reach for (its tools) and what counts as finished (its stop condition). An agent that fetches its own data is more capable than one you spoon-feed, and less predictable, and those two choices are where your control lives. Give a role a small, sharply described toolbox and an explicit stop, and its freedom works for you instead of against you.