Skip to content

The Foundation: Understanding Generative AI and Agency

⏱️ Estimated reading time: 20 minutes

Why This Chapter Matters

Imagine an AI system that doesn't just answer questions but can actually think through problems, make decisions, and take actions to achieve goals. This is the promise of agentic AI - systems that exhibit genuine autonomy and intelligence. But before we can build such systems, we need to understand the technological foundation that makes them possible: generative AI.

This chapter will take you from the basic concepts of generative AI to understanding how these technologies enable truly autonomous agents. By the end, you'll understand not just what generative AI is, but why it's the key that unlocks agentic systems.

The Generative Revolution: From Classification to Creation

The Paradigm Shift

Traditional AI systems were primarily discriminative - they could classify, predict, or recognize patterns in existing data. A spam filter could tell you if an email was spam or not, but it couldn't write an email. An image classifier could identify a cat in a photo, but it couldn't create a picture of a cat.

Generative AI changed everything by flipping this paradigm. Instead of just analyzing data, these systems can create new data that resembles their training data. This shift from analysis to creation is what makes agentic behavior possible.

Key Insight: The ability to generate - whether it's text, plans, code, or reasoning steps - is fundamental to agency. An agent needs to create responses, formulate plans, and generate actions, not just classify inputs.

The Mathematical Foundation

At its core, generative AI learns probability distributions over data. While we won't dive deep into the mathematics, understanding this concept is crucial:

  • Discriminative models learn P(label|data) - "What's the probability this email is spam given its contents?"
  • Generative models learn P(data) or P(data|conditions) - "What's the probability of this sequence of words?" or "What's the probability of this image given the prompt 'sunset over mountains'?"

This mathematical shift enables models to sample from learned distributions, creating new data that follows the patterns they've learned.

The Building Blocks: Core Generative Technologies

Large Language Models: The Reasoning Engine

Large Language Models (LLMs) are the most important breakthrough for agentic systems. But understanding why requires going beyond the surface level.

How LLMs Enable Agency

1. Sequential Decision Making LLMs generate text token by token, making a decision about the next word based on all previous context. This sequential decision-making process mirrors how agents need to make decisions about next actions based on current state.

Input: "The user asked for weather in Seattle. I should"
LLM reasoning: "call a weather API to get current conditions"
Output: "call the weather API for Seattle to retrieve current conditions"

2. In-Context Learning LLMs can learn new patterns from examples provided in their input context, without requiring retraining. This enables agents to adapt to new situations by providing relevant examples.

3. Abstract Reasoning Modern LLMs demonstrate remarkable ability to reason about abstract concepts, plan multi-step solutions, and even reflect on their own reasoning process.

The Transformer Architecture: Why It Works

The transformer architecture, introduced in the "Attention Is All You Need" paper, includes several innovations crucial for agentic behavior:

Self-Attention Mechanism Self-attention allows the model to consider relationships between all parts of the input simultaneously. For agents, this means understanding complex, multi-faceted situations where different pieces of information interact.

Example: "Book a flight to Paris for my business meeting on March 15th, but make sure it doesn't conflict with my daughter's graduation on March 14th"

Self-attention helps the model understand:
- The booking task (flight to Paris)
- The business context (meeting)
- The temporal constraint (March 15th)
- The personal constraint (daughter's graduation)
- The conflict resolution requirement

Positional Encoding This allows models to understand sequence and order, crucial for temporal reasoning and planning.

Layer Normalization and Residual Connections These enable training very deep networks, allowing for complex, multi-step reasoning.

Beyond Text: Multimodal Generative Models

Vision-Language Models

Models like GPT-4V, LLaVA, and DALL-E demonstrate how generative AI can work across modalities. For agents, this means:

  • Visual Understanding: Analyzing screenshots, charts, or physical environments
  • Visual Communication: Creating diagrams, visualizations, or images to communicate ideas
  • Multimodal Reasoning: Combining visual and textual information for richer understanding

Audio and Video Generation

Emerging models can generate and understand audio and video, enabling agents that can: - Communicate through speech - Understand video content - Create multimedia presentations

Specialized Generative Models for Agency

Code Generation Models

Models like Codex, CodeT5, and specialized programming assistants enable agents to: - Write and modify code dynamically - Create custom tools and scripts - Adapt their capabilities through programming

Planning and Reasoning Models

Some models are specifically designed or fine-tuned for: - Multi-step planning - Logical reasoning - Mathematical problem solving

From Generation to Agency: The Critical Connection

The Agency Stack

Generative AI enables agency through a conceptual stack:

Level 1: Generation Capability - Generate coherent text, code, plans - Sample from learned distributions - Maintain context and consistency

Level 2: Goal-Directed Generation - Generate outputs that work toward specific objectives - Understand and follow instructions - Adapt generation based on feedback

Level 3: Interactive Generation - Engage in multi-turn interactions - Build and maintain state across interactions - Learn from ongoing experience

Level 4: Autonomous Agency - Set and pursue complex goals - Make decisions in uncertain environments - Coordinate multiple capabilities toward objectives

Why Generation Enables Agency

1. Plan Formation Agents need to create plans to achieve goals. Generative models can create detailed, step-by-step plans in natural language.

2. Flexible Response Generation Rather than selecting from pre-written responses, agents can generate contextually appropriate responses for novel situations.

3. Tool Usage Agents need to formulate requests to external tools and APIs. Generative models can create properly formatted API calls and interpret responses.

4. Self-Reflection Advanced agents can generate self-evaluations, identifying mistakes and areas for improvement.

5. Communication Agents must communicate with humans and other agents in natural, contextually appropriate ways.

Practical Example: From Generative Model to Agent

Let's trace how a generative model becomes an agent through a concrete example:

Stage 1: Base Generative Model

Input: "What's the weather like?"
Output: "I don't have access to current weather information. You could check weather.com or your local news for current conditions."

Stage 2: Tool-Augmented Generation

Input: "What's the weather like in Seattle?"
Reasoning: "I need current weather data. I should use the weather API."
Tool Call: get_weather(location="Seattle")
Tool Response: {"temperature": 62, "condition": "partly cloudy", "humidity": 68}
Output: "The current weather in Seattle is 62°F and partly cloudy with 68% humidity."

Stage 3: Multi-Step Planning

Input: "Plan my outfit for a business meeting in Seattle tomorrow"
Reasoning: "I need to: 1) Check tomorrow's weather in Seattle, 2) Consider appropriate business attire, 3) Account for weather conditions"
Tool Call: get_weather_forecast(location="Seattle", date="tomorrow")
Tool Response: {"temperature": 58, "condition": "light rain", "precipitation": 70}
Output: "Based on tomorrow's forecast (58°F with light rain), I recommend:
- A business suit with a weather-resistant blazer
- Leather dress shoes or waterproof alternatives
- An umbrella or raincoat
- Slightly warmer layers since it'll be cool"

Stage 4: Autonomous Goal Pursuit

Input: "I have a business meeting in Seattle tomorrow but haven't prepared"
Agent Goal Formation: "Help user prepare comprehensively for Seattle business meeting"
Generated Plan:
1. Check weather and suggest appropriate attire
2. Research the company and attendees
3. Suggest talking points or agenda items
4. Recommend transportation options
5. Provide local restaurant suggestions for potential business lunch

[Agent then executes this plan autonomously, using multiple tools and generating comprehensive preparation materials]

The Technical Challenges and Solutions

Challenge 1: Consistency and Coherence

Problem: Generative models can produce inconsistent or incoherent outputs across long interactions.

Solutions: - Advanced prompting techniques (system prompts, few-shot examples) - Memory systems to maintain context - Structured generation with constraints

Challenge 2: Hallucination and Reliability

Problem: Models can generate plausible-sounding but incorrect information.

Solutions: - Tool integration for factual information - Verification and validation steps - Confidence estimation and uncertainty handling

Challenge 3: Goal Alignment

Problem: Ensuring generated content serves intended goals rather than just being plausible.

Solutions: - Reward modeling and RLHF (Reinforcement Learning from Human Feedback) - Constitutional AI approaches - Multi-step verification processes

Looking Forward: The Path to Advanced Agency

Current Capabilities

Today's generative AI can: - Engage in complex conversations - Generate code and execute tools - Create multi-step plans - Adapt to new situations through in-context learning

Emerging Capabilities

Research frontiers include: - Better long-term memory and learning - More sophisticated planning and reasoning - Improved multi-agent coordination - Enhanced safety and alignment

The Foundation for What's Next

Understanding generative AI is crucial because every advanced agentic capability builds on these foundations: - Memory systems (Chapter 3) use generative models to create relevant retrievals - Planning systems (Chapter 5) use generation to create and modify plans - Reflection systems (Chapter 4) use generation for self-evaluation - Multi-agent systems (Chapter 6) use generation for communication and coordination

Key Takeaways

  1. Generative AI is the engine of agency - The ability to create new content enables autonomous behavior
  2. The shift from discrimination to generation is fundamental to moving from reactive to proactive systems
  3. Modern LLMs combine multiple capabilities - reasoning, planning, tool use, and communication
  4. Agency emerges from structured application of generative capabilities toward goal achievement
  5. Technical challenges have practical solutions that enable reliable agent behavior

Practical Next Steps

To solidify your understanding:

  1. Experiment with prompting: Try designing prompts that guide an LLM through multi-step reasoning
  2. Explore tool integration: Connect an LLM to external APIs and observe how generation enables tool usage
  3. Study agent frameworks: Look at frameworks like LangChain or AutoGPT to see these principles in action
  4. Consider consistency: Think about how to maintain coherent agent behavior across long interactions

In the next chapter, we'll build on this foundation to explore the fundamental principles that guide the design of agentic systems, moving from understanding the technology to understanding the principles of autonomous behavior.


Next Chapter Preview: "Principles of Agentic Systems" will explore how we organize generative capabilities into coherent, goal-directed systems that can operate autonomously in complex environments.