Chapter 7-9: Knowledge-based Agents
Logical Agents
Knowledge-based agents typically store facts using logic. First-order logic can be expressed using the logic programming language Prolog. Here are two online examples using SWI-Prolog:
Python provides several modules for logic and symbolic mathematics. Here is a short primer on logic programming with Python.
Large Language Models
Large language models (LLMs) can be used as knowledge-based agents that work with natural language rather than logic. They can be used via an API or run locally. Important tasks include prompt engineering and context engineering.
Example:
Libraries and Prompting:
- OpenAI Python API Library.
- Hugging Face provides a large collection of downloadable pretrained LLMs.
- Prompt engineering guide from OpenAI.
- Textbook: Speech and Language Processing by Dan Jurafsky and James H. Martin. Part I contains an excellent introduction to language models, transformers, and large language models.
Agentic AI
An agentic AI solution uses a set of specially prompted LLM calls. It may involve any of the following:
- Multiple LLM calls
- LLMs can use tools (browse the web, access files, etc.) to interact with an environment.
-
A planner coordinates the activities of the agents. It may use one of these approaches:
- A developer-defined workflow using “prompt chaining” and feedback between LLMs.
- An LLM that plans its own tasks (acting as an autonomous agent, hence the name agentic AI).
Video:
Articles:
Tools:
- OpenAI Agents SDK: native support for function calling, retrieval, and tool orchestration for the OpenAI ecosystem.
- CrewAI: orchestrate multiple specialized AI agents working collaboratively.
- LangGraph: a low-level LLM orchestration framework for building structured, reproducible agent pipelines.
- Model Context Protocol (MCP): An open protocol that enables seamless integration between LLM applications and external data sources and tools.
License
© 2025 Michael Hahsler. All code and documents in this repository are provided under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License.