LN: Shieh (2024) — Generative AI Agents

Bibliographic Reference

Citation: Shieh, J. (2024). Generative AI agents: Build autonomous AI systems with LangChain and LlamaIndex. Packt Publishing. https://www.packtpub.com/en-us/product/generative-ai-agents-9781835084991


Pass 1 — Bird’s Eye View (5 Cs)

CAssessment
CategoryTechnical implementation book
ContextPractical guide for building production-grade agentic systems using LangChain (orchestration) and LlamaIndex (RAG). Written by a practitioner, 2024 — captures the current state of the LLM agent ecosystem
CorrectnessCode examples verified against LangChain 0.2+; covers ReAct, tool calling, and RAG pipelines with working implementations
Contributions(1) Full ReAct agent implementation; (2) RAG pipeline design; (3) Tool integration patterns; (4) Spec-Driven Development application to agent design; (5) Context-Driven Development for agent prompting
ClarityVery good — assumes Python familiarity; progressive from simple to complex

Relevance: ⭐⭐⭐⭐

Provides the implementation logic for PUMA’s agent pipeline: ReAct reasoning for complex issues, RAG for Stage 4, and tool-calling for SmartPMO. The SDD and CDD integration directly maps to PUMA’s prompt engineering methodology.


Pass 2 — Key Concepts

ReAct Agent Implementation

The book’s core implementation pattern for reasoning agents:

from langchain.agents import create_react_agent
from langchain import hub
 
prompt = hub.pull("hwchase17/react")
agent = create_react_agent(llm, tools, prompt)
 
# ReAct loop:
# Thought: Analyse the issue description
# Action: classify_issue(description="...", schema={...})
# Observation: {"type": "Bug", "confidence": 0.87}
# Final Answer: Bug, High priority

This pattern directly implements PUMA’s Stage 4 (RAG-enhanced triage) and Stage 5 (SmartPMO) architectures.

RAG Pipeline Design

The book’s RAG architecture maps to PUMA Stage 4:

  1. Ingest: Index historical issue resolutions into a vector database
  2. Retrieve: Given new issue, retrieve k most similar resolved issues
  3. Augment: Include retrieved context in the triage prompt
  4. Generate: Triage with historical context

Spec-Driven Development (SDD) for Agents

A key contribution: using specifications to define agent behaviour before implementation. The SDD pattern:

  1. Write the agent specification (what it does, what it consumes, what it produces)
  2. Write acceptance tests (what constitutes correct behaviour)
  3. Implement the agent to satisfy the spec
  4. Validate against the spec

This directly mirrors PUMA’s SP-Triage-Agent spec and BMAD BDD scenarios.

Context-Driven Development (CDD)

CDD principle: the quality of an agent’s output is bounded by the quality of context it receives. Shieh’s CDD framework:

  • Always include explicit task context in system prompts
  • Provide output format specification in every prompt
  • Use few-shot examples as context anchors
  • Restate key constraints at the prompt end (Contextual Anchoring)

PUMA Integration

  • Stage 4 RAG implementation: Shieh’s RAG pipeline as the technical basis
  • BMAD agent prompts: CDD principles as the prompt engineering framework
  • Spec-Driven Development: SP-Triage-Agent and SP-Architecture specs follow Shieh’s SDD approach

MOCs