Topics covered in this article:
1. What is an AI Agent?
2. How so AI agents run? (loops and iterations)
3. Tools and how agents use them
4. The Model Context Protocol (MCP)
5. Reasoning vs. non-reasoning models in query planning
6. Running Agents Privately (AI Sovereignty and Privacy)
7. Future Outlook: Biased Agents and a Network of AI Economies
8. Case Study: Autonomous Portfolio Management Agent
1. What is an AI Agent?
Figure 1: A deterministic agent is a software program whose control flow is governed by a predefined set of conditional statements (if/else logic). In contrast, a non-deterministic AI agent uses an AI model to direct the program’s control flow. This model effectively functions as the equivalent of millions, if not billions, of complex conditional statements.
An AI agent is a software program that uses an AI model as its “brain” to autonomously interact with its environment and achieve goals. Unlike a simple code script with fixed instructions, an AI agent’s control flow is governed by a model’s outputs, often a large language model (LLM), which allows it to make decisions in a flexible, context-dependent way. In essence, an AI agent runs an AI model in a loop, taking in information (state, inputs), deciding on an action via the model’s inference or reasoning, and then executing that action before repeating. This autonomy means AI agents can perform complex tasks (planning steps, querying data, calling APIs, etc.) without constant human guidance, distinguishing them from basic AI copilots that only assist with suggestions.
An AI agent can be thought of as an intelligent loop: it receives input from external sources, decides next steps using the model, and then acts, all governed by AI-driven logic rather than hard-coded rules.
Example: Imagine an AI agent tasked with organising your inbox. It might read incoming emails (perception), use an LLM to decide which are important or how to respond (reasoning via model), then automatically sort emails or draft replies (action). The agent autonomously iterates this process. The model allows the agent to handle unexpected inputs or complex criteria (e.g. understanding email intent) that static rules would struggle with, making the agent adaptable and “intelligent” in its domain.
2. How do AI agents run? (loops and Iterations)
AI agents can operate in different modes depending on how their execution loop is structured. The loop determines whether the agent runs once and stops or continues iterating to refine its results or handle ongoing tasks. The three basic approaches are: a single iteration, a multi-step iteration, or an infinite (continuous) loop.
Single iteration
Figure 2: A single-iteration agent runs its loop only once. It starts, invokes the AI model to decide an action, executes the action, then ends. This one-and-done approach is like a straightforward function call, suitable for simple tasks where one pass is enough (e.g. answer a single question).
In a single-loop execution, the agent runs through the perceive-decide-act cycle only one time. The agent receives an input, the model produces an output or action, and the agent stops. There is no feedback or further planning, the agent does not revisit or refine its decision. This approach is simple and fast, but limited to tasks that can be completed in one shot. For example, an agent asked to summarise a document might do it in one go and terminate. Many basic tool-using LLM calls (like a single API call via an LLM) are essentially single-iteration agents.
Multi-step iteration
Figure 3: A multi-iteration agent runs a loop repeatedly for a set number of iterations or until a condition is met. After each action, it checks if the goal is achieved (“Goal achieved?”). If not, it feeds the new state back into the model for the next iteration. This allows step-by-step problem solving.
A multi-step (iterative) agent runs through the loop several times to refine its results or handle sub tasks sequentially. After each iteration, it can evaluate progress. The loop stops when a goal is achieved or a preset number of iterations is reached. This configuration is useful when tasks benefit from incremental progress, for example, an agent solving a puzzle might make multiple moves, checking after each if the puzzle is solved. Multi-iteration agents balance autonomy with safety: they eventually stop if a solution is found or a limit is hit, avoiding endless loops. Many planning agents (like those that reason step-by-step) use iterative loops: they generate a plan, execute part of it, then re-plan based on new information.
Infinite (continuous) loop
Figure 4: A continuous agent (infinite loop) runs indefinitely until stopped manually. It continuously observes inputs (or waits for new data), uses the model to decide actions, acts, completes goals and then loops back with new state about an existing or new goal. This configuration suits monitoring or long-running autonomous services.
An infinite-loop agent runs continuously, effectively autonomous over time. There is no fixed end state; instead, the agent keeps watching for new inputs or changes and responding to them based on existing or new goals. This is ideal for agents in monitoring or control roles – for example, a trading agent that runs 24/7, or an AI assistant that watches an email inbox all day. These agents include a mechanism to pause or wait between actions (e.g. sleep until new data arrives, or cycle at intervals). Because they never terminate on their own, infinite-loop agents need safeguards (like a manual stop or resource limits) to prevent runaway behaviour. They embody the idea of an autonomous process, akin to a daemon service that is always on.
3. Tools and how agents use them
Figure 5: Tool selection for an AI agent. A tool has a Name, a Description of what it does, and specified Parameters it requires. One or more models are given this information so they know how and when to use the tool.
AI agents extend their capabilities through tools (also called functions or plugins). An AI model on its own can only generate text; tools let it affect the world outside of text by performing actions like web browsing, math calculations, database queries, or controlling devices. A tool is typically defined by a name, a description, and the input parameters it expects. The agent’s system prompt or programming includes these tool definitions, effectively telling the AI model what it can do beyond just talking.
How agents use tools: During its inference/reasoning, if the model decides that using a tool is necessary, it will output a corresponding tool call (often in a structured format like JSON or a special syntax). The agent loop then executes the actual tool (e.g. calls an API or runs code) and gets the result, which it can feed back into the model . This cycle may repeat multiple times. For example, an agent might have a “web_search” tool – the model can decide “I should do a web search for XYZ”, the agent executes the search and returns the results, and then the model incorporates those results into its next inference/reasoning step.
Examples of tools: Common tools include web search and web browsing commands (to fetch information from the internet), file system tools (read/write files), calculation tools or code execution for math and data processing, and domain-specific APIs (e.g. a stock trading API or a CRM database query). If an AI agent needs current information, it could use a browser tool; if it needs to remember something, it might use a file or vector-database tool to store/ retrieve data. By leveraging tools, agents overcome the inherent limitation of LLMs (which cannot perform actions or fetch fresh data on their own). This synergy of LLM + Tools is powerful: the LLM decides when and what tool to use, and the tool execution extends the agent’s abilities beyond language.
4. The Model Context Protocol (MCP)
Modern AI agents often need to incorporate external context (data from databases, knowledge bases, or real-time information) in a standardised, secure way. The Model Context Protocol (MCP) is an emerging open standard designed to facilitate this. MCP “is an open standard that adds context to LLM
queries by enabling AI agents to call external tools and live data sources” [1] . In simpler terms, MCP provides a common language or interface for connecting AI agents with various data repositories and services (externally hosted tools). Instead of each agent having bespoke integrations for every database or API, MCP defines a uniform protocol so that any compliant data source can plug into any MCP-aware agent.
One way to think of MCP is like a “USB-C port” for AI, a universal plug for connectivity. Just as USB-C standardises how devices connect (so the same port can handle printers, monitors, chargers, etc.), MCP standardises how AI models and agents access external context. With MCP, an agent can query an MCP server for information (say, “customer account data” or “latest financial filings”) and the server handles retrieving that data (via tools, database queries, etc.), then returns it in a model-friendly format. This helps overcome the current fragmentation where each AI system has its own plugins, APIs or tools. By using MCP, developers can plug in new data sources or tools to an agent without retraining the model, as long as both adhere to the MCP specification. The result is a more connected intelligence: AI agents that maintain richer context and up-to-date knowledge, leading to more relevant and accurate responses.
For the world of agents, MCP offers several benefits: interoperability (any tool/data source that speaks MCP can work with any MCP-enabled agent), security (it encourages secure, permissioned data exchange between agents and sources ), and scalability (organisations can expose many internal data sources through MCP servers, and their AI agents instantly gain access to all that information). As AI agents become more prevalent in enterprise settings, protocols like MCP will be key to integrating AI into the existing data ecosystem in a safe and standardised manner.
5. Reasoning vs. Non-Reasoning Models in Query Planning
When building an AI agent, one design choice is selecting what kind of AI models to use for different tasks. Broadly, models can be categorised as “reasoning” vs “non-reasoning” models. Understanding the difference is important for query planning – i.e. how the agent figures out a plan to handle a user’s request or a problem.
Reasoning models: These are typically the large, advanced LLMs (like GPT-4 o3, Google Gemini 2.5 pro, deepSeek etc.) or other AI models that excel at step-by-step logical reasoning, complex problem solving, and “chain-of-thought”. A reasoning model doesn’t just blurt out an answer, it can internally break a problem into sub-steps or draw inferences. In practice, if a task requires reasoning or careful thinking (e.g. solving math word problems, writing code, making a multi-step plan), you want a reasoning-capable model. These models often use more computation and have been trained or prompted to reason explicitly. For instance, prompting GPT-4 o3 with “let’s think step by step” encourages it to show reasoning steps. Reasoning models are ideal for an agent’s planning stage, figuring out what sequence of actions to take, how to interpret complex instructions, or when analysing information that needs deduction.
Non-reasoning models: These are models that generate outputs quickly based on learned patterns, without performing an elaborate multi-step reasoning process each time (GPT 4.1, Gemini 2.0, Claude 3.5, etc). They might be smaller LLMs or even simpler ML models trained for classification or lookup. Non-reasoning models can answer factual queries or perform straightforward tasks by essentially regurgitating what they know (“pattern completion”) rather than reasoning it out. They don’t do things like multi-step logic; they’re more like an instantaneous mapping from question to answer. For example, a smaller model might instantly categorise an email as spam or not, using cues it learned from data, without “thinking” in sentences. These models are useful when the task is routine or the response is formulaic, they are faster and cheaper to run, and often sufficient if reasoning isn’t required.
In an advanced agent, query planning might involve a combination of both types of models working together. For instance, suppose a user asks an agent a broad question: “Analyse my investment portfolio and suggest changes for the next quarter.” A large reasoning model could be invoked to outline a plan: it might decide “Step 1: analyse stock performance; Step 2: check news; Step 3: optimise allocation based on risk.” This plan is generated using its reasoning ability. Then, for each step, the agent might use more specialised or efficient tools/models. A non-reasoning model (or a direct database query) might handle Step 1 by quickly fetching performance metrics. Another could handle Step 2 by classifying recent news as good or bad. Finally, the reasoning model might come back for Step 3 to synthesise and give a nuanced recommendation.
The benefit of this hybrid approach is efficiency: use the heavyweight reasoning model only where necessary (complex planning or understanding), and delegate straightforward subtasks to lighter weight models or deterministic tools. This way, the agent is both smart and efficient. It’s akin to a human (the reasoning model) delegating easy chores to an assistant or calculator (the non-reasoning helpers). Many real-world agent systems do exactly this: e.g. using GPT-4 o3 for reasoning and a smaller model or rule-based system for quick lookups or formatting results. In summary, reasoning models bring depth of thought, while non-reasoning models bring speed; a well-designed agent leverages both as appropriate to plan and execute queries optimally.
6. Running Agents Privately (AI Sovereignty and Privacy)
For businesses and users with high privacy requirements, it’s often desirable to run AI agents entirely on private infrastructure rather than relying on cloud APIs. This approach is aligned with the concept of AI sovereignty, maintaining full control over your AI systems, data, and models. In practice, this means using open-source models (for both reasoning and non-reasoning components) that can be deployed on-premises or in a private cloud, and using dedicated hardware (like GPUs) to power them. By doing so, none of the sensitive data or decisions ever leave the organisation’s controlled environment.
Recent advances in open-source LLMs have made this quite feasible. For example, Alibaba’s Qwen-2 72B model (72 billion parameters) is an open-source LLM that rivals the performance of top-tier proprietary models, in our experience. A company could deploy a model like Qwen-72B (or smaller variants like Qwen-7B for lighter tasks) on its own servers. This model could serve as the agent’s “brain” for inference and tool selection. An open source version of deepSeek could be used for reasoning.
In addition, smaller open models or rule-based systems can be used for non reasoning specific tasks, all running the organisation's cloud or bare metal servers. With dedicated GPUs or AI chips, the agent can achieve high throughput, essentially creating a private AI service similar to something like GPT-4, but hosted internally.
The advantages of this approach are significant for privacy and compliance. Data never has to be sent to an external provider, eliminating worries about sensitive information leakage or exposure to third party data handling. The organisation also gains full transparency and control: it can audit the model’s behaviour, ensure it meets industry regulations (important in finance, healthcare, etc.), and even modify the model if needed via fine tuning. This is a core aspect of AI sovereignty: “a strategic push to retain control over AI capabilities, data, and infrastructure on home turf” .
If the model or agent needs to be tailored, engineers can fine-tune the open-source model on proprietary data securely, something not possible with closed APIs.
Running agents privately with open models also avoids external service costs and limits. There are no API rate limits or fees per request – you pay for your hardware and electricity, but you’re not locked into a vendor contract. It can be more cost-effective at scale. Moreover, sovereignty provides resilience: even if a cloud AI service changes its terms or goes down, your in-house agent keeps running. Governments and enterprises concerned with strategic autonomy echo this sentiment; they support initiatives for local AI infrastructure so as not to be dependent on foreign AI services.
In summary, achieving end-to-end AI sovereignty for an agent involves using open-source reasoning models (like deepSeek, etc.) and any necessary smaller models, all hosted on infrastructure you control. Thanks to projects in the AI community, today it’s possible to approximate the capabilities of systems like GPT-4 within one’s own data center. This approach ensures that privacy is preserved (sensitive data stays in-house), compliance is easier (you know exactly where data is and how the model works), and autonomy is maximised (the AI is fully under your organisation’s governance). The trade-off is the technical effort and computing resources required, but for many, the benefits to data protection and independence are well worth it.
APEX:E3 is well positioned to help organisations achieve AI Sovereignty.
7. Future Outlook: Biased Agents and a Network of AI Economies
Looking ahead, AI agents might not remain neutral decision-makers – we can program them with different worldviews, biases, and incentive frameworks to suit various roles or strategies. In finance, for example, one could envision agents that are intentionally bullish or bearish in their approach. An agent with a bullish bias might give more weight to optimistic signals and take more aggressive investment positions, whereas a bearish agent might be risk-averse, focusing on downside protection. We already see rudiments of this in sentiment analysis: agents classify information as bullish, bearish, or neutral to inform trading decisions . In the future, entire agents could be instantiated with a “market outlook” bias, essentially encoding a point of view.
Beyond market stance, agents could be given incentive frameworks that align with monetisable outcomes. Consider a network of agents in a digital marketplace: each agent might represent a different stakeholder or strategy, each trying to maximise its own reward (profit, influence, accuracy, etc.). If these agents transact or negotiate with one another, they start forming an economy of agents. For instance, in automated trading, a bullish agent and a bearish agent might trade with each other – each trying to profit based on its model’s view, effectively bringing liquidity and diverse perspectives to the market. Another scenario is a network of content-generating agents with different “opinions” (some more sensational, some more factual), competing for user attention and ad revenue. This begins to resemble an ecosystem where agents are economic actors with programmed incentives.
Such an economy could be global and self-organising. If each agent can earn tokens or other rewards for successful actions, they become analogous to companies or traders in a market, except they are algorithms. This opens questions about network effects and emergent behaviour: Will a few super agents dominate due to better algorithms or more data, forming powerful hubs in the network? (Research suggests agent networks could exhibit winner-takes-most dynamics if not carefully designed,
due to network effects of scale) [2]. Conversely, could a balanced multi-agent economy arise, where countless specialised agents trade and collaborate, creating value in aggregate?
From a sovereignty and bias perspective, programming worldview and incentives into agents means we must carefully manage ethical and social implications. An agent’s bias is essentially a controlled perspective. Ideally, we ensure it’s used transparently and for intended purposes. For example, a “neutral” news aggregator agent might be programmed to avoid political bias, whereas another agent might be intentionally biased to simulate a particular demographic’s viewpoint (useful in simulations or marketing). Monetisation incentives could drive agents to behaviours like real businesses, a customer service agent might upsell because it has a revenue goal, while another agent might specialise in unbiased advice and be paid via subscription.
Ultimately, as AI agents proliferate, we might witness the rise of a networked global economy composed of AI agents. These agents, each with their own “personality” (biases) and “wallet” (incentives/ monetisation), could interact in markets for information, services, or digital goods. They could form supply chains (one agent produces data, selling to another that analyses it, which feeds into another that makes decisions). Humans would set the high-level objectives and constraints – ensuring, for example, that incentive-aligned agents remain within ethical bounds, but much of the day-to-day operation could be autonomous.
This vision is both exciting and challenging. It suggests a world where AI agents don’t just serve individual users in isolation, but also cooperate and compete with each other on a large scale, potentially spawning new efficiencies and innovations (as well as new systemic risks). Just as the global economy is a network of human agents (individuals, companies, institutions) with diverse goals and biases, a future AI-driven economy might be a network of digital agents exchanging value, information, and services. In preparing for that future, it’s crucial to design robust frameworks for agent interaction, ensure transparency of agent biases, and align their incentives with human values and economic well-being. The seeds of this future are visible today in areas like algorithmic trading, but in the coming years, it could extend to many domains, creating a dynamic, AI-augmented global economy that operates 24/7, seamlessly alongside the human economy.
8. Case Study: Autonomous Portfolio Management Agent
To make these concepts concrete, let’s consider a capital markets use case: an AI agent (or a team of agents) that autonomously manages an investment portfolio of stocks, bonds, and digital assets. The agent’s goal is to continuously monitor news, market data, and reports, and then enter or exit positions based on signals – much like a human portfolio manager, but automated. This agent would operate in an infinite loop configuration, running continuously to react to new information around the clock based on existing and dynamically created goals.
A robust design for this scenario could involve multiple specialised agents working together, each focusing on a particular aspect of the task, and a coordinator (or orchestrator) to make final decisions. Financial markets are complex, so breaking the problem into specialised roles can improve performance. For example, one agent might specialise in reading news and reports (fundamental analysis), another in crunching real-time price and technical indicator data (technical analysis), and another in keeping risk exposure within limits. They would share their insights with an orchestrator master agent that decides trades.
Figure 6: Simplified multi-agent architecture for an autonomous trading system. Multiple agents run in parallel: Sentiment Agent processes news and social media to gauge market mood; Technical Agent analyses price trends and indicators; Fundamentals Agent examines financial reports and economic data. Their outputs go to a Risk Manager Agent, which enforces risk limits, and finally a Portfolio Manager Agent decides and executes trades. The loop then continues with new data, enabling continuous portfolio management.
In this setup, each agent operates continuously and they communicate their findings to the Orchestrator:
Sentiment Agent: Uses natural language processing to read news headlines, social media (like finance tweets), and analyst opinions, determining the sentiment (bullish, bearish, or neutral) around assets. For example, a sudden wave of negative news about a company would be caught by this agent, labeled as bearish sentiment.
Technicals Agent: Computes technical trading signals from market data. For example, it might calculate trends (using moving averages, momentum indicators), detect mean-reversion opportunities (e.g. if price is far from average), and flag volatility regimes. This agent basically does what a quantitative technical trader would do, but nonstop and at high speed.
Fundamentals Agent: Continuously scans financial reports, earnings releases, and economic indicators. It might pull data like P/E ratios, growth rates, interest rates, or crypto on-chain metrics. Its goal is to assess the intrinsic or long-term outlook of assets – like having a research analyst AI reading all news and filings.
Market Data Agent: Continuously pulls in live market feeds, prices, volumes, order book data ensuring all other agents have up-to-the-second information . (Think of it as providing the “market heartbeat.”)
Risk Agent: Takes the signals from the Technicals, Fundamentals, and Sentiment agents and evaluates the overall risk. It calculates metrics like Value-at-Risk, ensures the portfolio isn’t over-leveraged or too concentrated, and sets guardrails . If the combined signals imply too much risk (e.g. all agents love a stock but it would overweight the portfolio), the Risk Manager might scale down the position size or veto a trade. It’s the safety check.
Portfolio Agent: Finally, this agent synthesises everything – it decides which assets to buy or sell, how much to allocate, and executes the trades. It prioritises opportunities, allocates capital across asset classes, and rebalances the portfolio to stay diversified . For instance, if the Technical agent says “buy S&P 500 now” and Sentiment is positive, the Portfolio Manager will initiate a buy order, but it will also consider if this fits within risk limits and the current portfolio strategy.
All these agents run continuously, updating their outputs as new data comes in. The infinite loop configuration means the Portfolio Agent is always listening to its analysis sub-agents and to the market. If news breaks that affects a stock, within seconds the Sentiment agent updates its view, the Technicals agent registers any price move, and the Portfolio agent may decide to adjust the position. Trades are executed via brokerage APIs (a “trade execution” tool). Because the agent operates 24/7, it can react faster than human managers. For example, exiting a position at 3 AM if critical news drops in Asia.
Such an autonomous agent system could maintain a multi-asset portfolio and adapt to market conditions in real-time. It effectively mimics a trading desk: listening to news, watching price ticks, performing analysis, and trading, but all done by AI components working in concert. This case also highlights why tools and data integration (like MCP or custom APIs) are vital: the agent needs access to live news feeds, market data streams, and trading execution platforms to function. In a production setting, one would carefully sandbox and supervise such an agent (e.g. with limits on trade size and proper testing) since it’s handling valuable assets in a complex environment.
[1] What is Model Context Protocol? | A Practical Guide
[2] Fueling Concentration Agents and Network Effects
Team APEX:E3 is developing advanced agents to solve real-world capital markets usecases. Please get in touch for a demonstration!