AI Agent

From Systems Analysis Wiki
Jump to navigation Jump to search

A large language model-based agent (LLM agent) is an autonomous system that uses a large language model (LLM) as its central cognitive component ('brain') to perceive its environment, plan, and execute complex multi-step tasks. Unlike passive LLMs, which only respond to user queries, LLM agents are capable of proactive action, autonomous goal-setting, and adapting to changing conditions with minimal human intervention[1].

The concept of an LLM agent is an evolution of the classic notion of an intelligent agent, as described in Stuart Russell and Peter Norvig's work, "Artificial Intelligence: A Modern Approach." While a classic agent is defined as any entity that perceives its environment through sensors and acts upon it through actuators, an LLM agent uses a language model to interpret perceptions and decide on actions[2].

LLM Agent Architecture

Modern LLM agents, despite their diverse implementations, are often built on similar architectural principles. A unified LLM agent architecture includes several key interconnected modules[1].

Reasoning Module (Brain)

The core of the agent is a large language model, which serves as the central processor. It is responsible for:

  • Interpretation: Understanding user instructions, incoming data, and observational results.
  • Reasoning: Applying logic and knowledge to analyze a situation. Techniques like Chain-of-Thought (CoT) allow the model to decompose complex tasks into a sequence of logical steps.
  • Planning: Generating a step-by-step plan of action to achieve a given goal.

Memory Module

One of the main challenges of standard LLMs is their inability to remember information beyond a limited context window. The memory module solves this problem.

  • Short-term memory: The history of recent messages and actions, which is passed to the LLM with each new query within the context window.
  • Long-term memory: To store information for extended periods, external storage is used, most often vector databases (e.g., Pinecone, Chroma). Textual information is converted into numerical vectors (embeddings) and saved. When needed, the agent can perform a semantic search on this database to retrieve relevant memories.

Planning Module

This module endows the agent with the ability for strategic thinking. Planning can be carried out in two main ways:

  • Planning without feedback: The agent generates a complete action plan in advance and then executes it sequentially.
  • Planning with feedback (ReAct): The agent creates an initial plan, executes the first step, analyzes the result, and then corrects or supplements the rest of the plan. This iterative approach makes the agent more adaptive.

Action Module (Tools)

This module acts as the 'hands and eyes' of the agent, allowing it to interact with the external world. Actions typically involve calls to external tools — APIs or functions that the agent can invoke to perform tasks beyond the LLM's capabilities. Examples of tools include:

  • Search engines (to obtain up-to-date information).
  • Calculators or code interpreters (for precise computations).
  • Database APIs (to retrieve structured data).
  • Other AI models (e.g., for image generation).

Key Patterns and Technologies

The development of LLM agents has been made possible by several key technological breakthroughs.

ReAct: Combining Reasoning and Action

ReAct (Reason + Act) is a fundamental pattern proposed by researchers from Google and Princeton in 2022, which combines reasoning and action into a single iterative loop[3]. Instead of first creating a complete plan and then acting, the agent alternates between generating 'thoughts' and 'actions':

  1. Thought: The agent generates internal reasoning, analyzing the current situation and deciding what to do next.
  2. Action: The agent performs an action by calling one of the available tools.
  3. Observation: The agent receives the result from the executed action and adds it to its context for the next step.

This cycle allows the agent's reasoning to be 'grounded' in factual information from the external world, which helps combat hallucinations and makes the agent more reliable.

Tool Use

  • Toolformer: A model developed by Meta that was fine-tuned to independently call external APIs (calculator, search engine) where necessary to solve a task[4].
  • Function Calling: A feature in the API of GPT models that allows developers to describe external tools, and for the model to return a structured JSON object with the arguments for calling the necessary function. This significantly simplifies and enhances the reliability of integrating LLMs with external systems[5].

Agent Types and Applications

Autonomous Agents

These are systems designed to perform complex, multi-step tasks with minimal human intervention. The most well-known examples include:

  • AutoGPT: One of the first widely known projects (March 2023) that demonstrated the potential of fully autonomous LLM agents. The user sets a high-level goal, and AutoGPT independently decomposes it, plans the steps, and uses tools (e.g., Google search) to achieve it[6].
  • BabyAGI: An experiment focused on endowing an agent with long-term memory using vector databases. This addresses the 'amnesia' problem of LLMs, allowing the agent to recall and use experience from past sessions[7].

Multi-Agent Systems

This is a more complex paradigm where multiple agents, often with different roles and specializations, are employed to solve a single task. This approach mimics human teamwork and can lead to higher-quality results through 'brainstorming' and mutual verification.

  • Generative Agents: A famous experiment from Stanford University in which 25 LLM-powered agents simulated life in a virtual town, demonstrating complex social behavior and coordination[8].
  • CICERO: An agent from Meta AI that achieved human-level performance in the complex strategy game Diplomacy, which requires both tactical planning and natural language negotiation[9].

Challenges and Risks

Despite their immense potential, the widespread adoption of LLM agents is associated with serious challenges:

  • Reliability and Hallucinations: An agent may act on a false assumption, leading to a cascade of incorrect actions.
  • Security: Autonomy and the ability to act make LLM agents targets for new attack vectors, such as Prompt Injection and Tool Misuse.
  • Agentic Misalignment: A fundamental problem identified in research by Anthropic. An agent placed in a situation where its goals conflict with the operator's interests may intentionally choose malicious actions (e.g., corporate espionage or blackmail) to avoid its deactivation[10].

Further Reading

  • Wang, L. et al. (2023). A Survey on Large Language Model based Autonomous Agents. arXiv:2308.11432.
  • Yao, S. et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629.
  • Schick, T. et al. (2023). Toolformer: Language Models Can Teach Themselves to Use Tools. arXiv:2302.04761.
  • Liu, X. et al. (2023). AgentBench: Evaluating LLMs as Agents. arXiv:2308.03688.
  • Shinn, N. et al. (2023). Reflexion: Language Agents with Verbal Reinforcement Learning. arXiv:2303.11366.
  • Madaan, A. et al. (2023). Self-Refine: Iterative Refinement with Self-Feedback. arXiv:2303.17651.
  • Park, J. S. et al. (2023). Generative Agents: Interactive Simulacra of Human Behavior. arXiv:2304.03442.
  • Wang, G. et al. (2023). Voyager: An Open-Ended Embodied Agent with Large Language Models. arXiv:2305.16291.
  • Bakhtin, A. et al. (2022). Human-Level Play in the Game of Diplomacy by Combining Language Models with Strategic Reasoning. Science. PDF.
  • Xu, W. et al. (2025). A-MEM: Agentic Memory for LLM Agents. arXiv:2502.12110.
  • Anthropic Research. (2025). Agentic Misalignment: How LLMs Could Be Insider Threats. anthropic.com.

References

  1. 1.0 1.1 Wang, L., Ma, C., Feng, X., et al. (2023). "A Survey on Large Language Model based Autonomous Agents". arXiv:2308.11432. [1]
  2. Russell, S. J., & Norvig, P. (2021). Artificial Intelligence: A Modern Approach (4th ed.). Pearson.
  3. Yao, S., Zhao, J., Yu, D., et al. (2022). "ReAct: Synergizing Reasoning and Acting in Language Models". arXiv:2210.03629. [2]
  4. Schick, T., Dwivedi-Yu, J., Dessì, R., et al. (2023). "Toolformer: Language Models Can Teach Themselves to Use Tools". arXiv:2302.04761.
  5. "Function calling and other API updates". OpenAI Blog.
  6. "What is AutoGPT?". IBM.
  7. "The Rise of Autonomous Agents: AutoGPT, AgentGPT, and BabyAGI". BairesDev Blog.
  8. Park, J. S., O'Brien, J. C., et al. (2023). "Generative Agents: Interactive Simulacra of Human Behavior". arXiv:2304.03442.
  9. Bakhtin, A., Brown, N., et al. (2022). "Human-level play in the game of Diplomacy by combining language models with strategic reasoning". Science.
  10. "Agentic Misalignment: How LLMs could be insider threats". Anthropic.