Introduction to Agent SDKs
The space of artificial intelligence is rapidly evolving, with a growing emphasis on intelligent agents capable of performing complex tasks, interacting with users, and adapting to dynamic environments. Building such agents from scratch can be a daunting task, requiring expertise in natural language processing, machine learning, knowledge representation, and more. This is where Agent SDKs (Software Development Kits) come into play. Agent SDKs provide developers with pre-built components, frameworks, and tools to accelerate the development of intelligent agents, abstracting away much of the underlying complexity.
An Agent SDK typically offers functionalities for defining agent behaviors, managing conversational flows, integrating with external tools and APIs, handling memory and context, and often includes features for deployment and monitoring. Choosing the right Agent SDK is crucial for the success of your project, as different SDKs cater to various use cases, programming languages, and levels of abstraction. This tutorial aims to provide a practical comparison of several popular Agent SDKs, illustrating their strengths and weaknesses through concrete examples.
Key Features to Consider in an Agent SDK
- Language Support: Does it support your preferred programming language (Python, JavaScript, Java, etc.)?
- Ease of Use and Learning Curve: How quickly can a new developer become productive with the SDK?
- Integration Capabilities: Can it easily integrate with other services, APIs, databases, and existing systems?
- State Management and Memory: How well does it handle conversational context and long-term memory for the agent?
- Orchestration and Workflow: Does it provide tools for defining complex agent behaviors, decision-making, and multi-step processes?
- Scalability and Performance: Can it handle a high volume of interactions and complex computations?
- Deployment Options: What are the supported deployment environments (cloud, on-premise, serverless)?
- Community and Documentation: Is there an active community and thorough documentation to assist during development?
- Extensibility: How easy is it to extend the SDK’s functionalities with custom components?
Comparing Agent SDKs: LangChain vs. LlamaIndex vs. Microsoft Semantic Kernel
For this tutorial, we will focus on three prominent and widely used Agent SDKs: LangChain, LlamaIndex, and Microsoft Semantic Kernel. Each of these offers a unique approach to building intelligent agents, particularly those using large language models (LLMs).
1. LangChain: The Orchestrator for LLM-Powered Applications
LangChain has rapidly emerged as a dominant framework for developing applications powered by large language models. Its core philosophy revolves around ‘chaining’ together different components to create complex workflows. It provides a thorough set of abstractions for interacting with LLMs, managing prompts, handling conversational memory, integrating with external tools (Agents), and retrieving information from various data sources (Retrieval).
LangChain Key Features:
- Chains: Define sequences of calls, e.g., prompt templates + LLM + output parser.
- Agents: Allow LLMs to choose a sequence of actions to take, often using tools.
- Memory: Store and retrieve information about past interactions.
- Loaders: Load data from various sources (PDFs, websites, databases).
- Vectorstores: Store and query embeddings for semantic search.
- Tools: External functionalities an agent can use (e.g., search engines, calculators, custom APIs).
LangChain Practical Example: A Simple Conversational Agent with Tool Use
Let’s build a LangChain agent that can answer general questions and also use a calculator tool if a mathematical operation is detected.
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_react_agent
from langchain import hub
from langchain_core.tools import Tool
from langchain.chains import LLMMathChain
# 1. Initialize the LLM
llm = ChatOpenAI(temperature=0, model="gpt-4o")
# 2. Define Tools
# Calculator tool
llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True)
calculator = Tool(
name="Calculator",
func=llm_math_chain.run,
description="Useful for when you need to answer questions about math."
)
tools = [calculator]
# 3. Get the prompt from LangChain Hub (ReAct style)
# The ReAct prompt guides the LLM to think, observe, and act.
prompt = hub.pull("hwchase17/react")
# 4. Create the ReAct agent
agent = create_react_agent(llm, tools, prompt)
# 5. Create the Agent Executor
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, handle_parsing_errors=True)
# 6. Run the agent
print(agent_executor.invoke({"input": "What is the capital of France?"}))
print(agent_executor.invoke({"input": "What is 1234 * 5678?"}))
Explanation:
- We initialize an OpenAI Chat model.
- We define a
Calculatortool using LangChain’sLLMMathChain. - We pull a standard ReAct prompt from LangChain Hub. ReAct (Reasoning and Acting) is a paradigm that allows LLMs to perform dynamic reasoning and action planning.
create_react_agentcombines the LLM, tools, and prompt to create an agent.AgentExecutoris responsible for running the agent, managing its thought process, and executing tools.- When asked about the capital of France, the LLM answers directly. When asked a math question, it recognizes the need for the calculator, calls the tool, and provides the result.
2. LlamaIndex: Data Framework for LLM Applications
While LangChain focuses heavily on orchestration and chaining LLM calls, LlamaIndex (formerly GPT Index) specializes in data ingestion, indexing, and retrieval for LLM applications. Its primary goal is to make it easy to connect LLMs with custom data sources, enabling powerful RAG (Retrieval-Augmented Generation) applications. LlamaIndex excels at building knowledge bases and making them queryable by LLMs.
LlamaIndex Key Features:
- Data Connectors: Ingest data from various sources (documents, databases, APIs).
- Data Indexing: Structure and store data in a way that is optimized for LLM queries (e.g., vector stores, knowledge graphs).
- Query Engines: Retrieve relevant information from indexes and synthesize answers using LLMs.
- Agents: Combine query engines with tools and LLMs for more complex, multi-step reasoning over data.
- Service Context: Manage LLM, embedding model, and other service configurations.
LlamaIndex Practical Example: Querying a Custom Document
Let’s create a simple LlamaIndex application that can answer questions based on a local text file.
# First, create a dummy file: 'policy.txt'
# Content:
# "Our company's vacation policy grants employees 15 days of paid time off per year.
# After 5 years of service, employees receive an additional 5 days.
# Unused vacation days do not roll over to the next year."
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding
import os
# Set OpenAI API key (ensure it's in your environment variables)
# os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
# 1. Configure LLM and Embedding Model (optional, but good practice)
Settings.llm = OpenAI(model="gpt-4o", temperature=0)
Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small")
# 2. Load documents from a directory
documents = SimpleDirectoryReader("data").load_data() # Assuming 'policy.txt' is in a 'data' directory
# 3. Create an index from the documents (VectorStoreIndex is common)
index = VectorStoreIndex.from_documents(documents)
# 4. Create a query engine
query_engine = index.as_query_engine()
# 5. Query the engine
response = query_engine.query("How many vacation days do employees get per year?")
print(response)
response = query_engine.query("What happens to unused vacation days?")
print(response)
Explanation:
- We first create a
policy.txtfile in adatadirectory. - We configure the LLM and embedding model via
Settings. SimpleDirectoryReaderloads the text file.VectorStoreIndex.from_documentsprocesses the documents, splits them into chunks, embeds them, and stores them in a vector database (in-memory by default).index.as_query_engine()creates an interface to query the index.- When a query is made, the query engine retrieves relevant document chunks based on semantic similarity and then uses the LLM to synthesize an answer from those chunks.
3. Microsoft Semantic Kernel: The Orchestrator for AI-Powered Apps with Plugins
Microsoft Semantic Kernel (SK) is an open-source SDK that allows developers to integrate large language models (LLMs) and other AI capabilities into their applications using existing programming languages (C#, Python, Java). It focuses on enabling applications to orchestrate interactions with LLMs and traditional code, emphasizing a ‘plugin’ architecture. SK is particularly strong for developers already within the Microsoft ecosystem or those looking for a solid, enterprise-grade framework.
Semantic Kernel Key Features:
- Kernel: The central orchestration engine for AI and traditional code.
- Skills/Plugins: Collections of semantic functions (LLM prompts) and native functions (traditional code) that the AI can invoke.
- Semantic Functions: Prompts that define what the LLM should do.
- Native Functions: Traditional code methods exposed to the AI, allowing it to interact with external systems.
- Memory: Store and retrieve information for conversational context.
- Planners: Enable the AI to plan and execute a sequence of skills to achieve a goal.
Semantic Kernel Practical Example: A Simple Planner with Custom Plugin
Let’s create a Semantic Kernel application that can greet the user and also perform a simple arithmetic operation using a custom native function (plugin).
import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.functions import kernel_function
import asyncio
# 1. Initialize the Kernel
kernel = sk.Kernel()
# 2. Configure the LLM service
# Ensure your OPENAI_API_KEY is set as an environment variable
kernel.add_service(
OpenAIChatCompletion(
service_id="chat_completion",
ai_model_id="gpt-4o",
),
)
# 3. Define a custom native plugin (Skills in SK)
class MathPlugin:
@kernel_function(description="Adds two numbers together.", name="Add")
def add(self, num1: float, num2: float) -> float:
return num1 + num2
@kernel_function(description="Multiplies two numbers together.", name="Multiply")
def multiply(self, num1: float, num2: float) -> float:
return num1 * num2
# 4. Import the plugin into the kernel
kernel.add_plugin(MathPlugin(), plugin_name="MyMathPlugin")
# 5. Define a semantic function (for general conversation)
# This is a simple prompt that can be invoked directly or used by a planner
prompt_template = "{{$input}}"
chat_function = kernel.create_function_from_prompt(
prompt_template=prompt_template,
plugin_name="ChatPlugin",
function_name="Chat"
)
async def main():
# 6. Invoke the chat function directly
result = await kernel.invoke(chat_function, sk.KernelArguments(input="Hello, what can you do for me?"))
print(f"Chat response: {result}")
# 7. Use a planner to orchestrate actions, including our MathPlugin
# For complex planning, you'd use a dedicated planner like SequentialPlanner
# For this simple example, we'll demonstrate a direct call via prompt with function calling capabilities
# The LLM, when invoked with the right prompt, will recognize and use the registered plugins.
# Let's create a goal for the LLM to achieve using available plugins.
goal = "I need to know the sum of 10 and 20, and then multiply that result by 3."
# SK's function calling mechanism allows the LLM to pick the right function.
# We'll use a chat completion service directly, allowing it to use tools.
history = kernel.create_chat_history()
history.add_user_message(goal)
response = await kernel.get_service("chat_completion").get_chat_message_content(
history=history,
settings=sk.OpenAIChatCompletionSettings(function_call="auto")
)
print(f"Planner response: {response}")
if __name__ == "__main__":
asyncio.run(main())
Explanation:
- We initialize the
Kerneland add an OpenAI chat completion service. - We define a
MathPluginclass with@kernel_functiondecorators, exposingaddandmultiplyas native functions. - We import this plugin into the kernel.
- A simple semantic function
chat_functionis created for direct LLM interaction. - In
main(), we first invoke the chat function directly. - Then, for the planning example, we create a chat history with a goal. By using
function_call="auto"in the settings, the LLM is enableed to decide whether to directly answer or to call one of the registered native functions (plugins) to achieve the goal. SK handles the translation of the LLM’s function call into actual method invocations and then feeds the result back to the LLM.
Choosing the Right Agent SDK
The choice of Agent SDK heavily depends on your project’s specific needs and your existing technology stack:
- Choose LangChain if:
- You need extensive LLM orchestration, complex agentic behavior, and flexible chaining of components.
- You want to integrate a wide variety of LLMs, tools, and memory types.
- You are building applications that involve multi-step reasoning, dynamic tool selection, and conversational agents.
- You value a large, active community and extensive examples.
- Choose LlamaIndex if:
- Your primary focus is on connecting LLMs to your custom data (documents, databases, APIs) for RAG.
- You need solid data ingestion, indexing, and retrieval capabilities.
- You are building knowledge base Q&A systems, document summarizers, or data-aware agents.
- You prioritize efficient and scalable data management for LLMs.
- Choose Microsoft Semantic Kernel if:
- You are a C#, Python, or Java developer looking to smoothly integrate AI into existing applications.
- You want a solid, enterprise-ready framework from Microsoft.
- You need to combine LLM capabilities (semantic functions) with traditional code (native functions/plugins) in a structured way.
- You are building applications that require AI to interact with your internal systems and APIs.
Conclusion
Agent SDKs are indispensable tools for building sophisticated AI applications. LangChain, LlamaIndex, and Microsoft Semantic Kernel each offer powerful features tailored to different aspects of AI development. LangChain excels at orchestrating complex LLM workflows and agentic reasoning. LlamaIndex is the go-to for data integration and retrieval-augmented generation. Semantic Kernel provides a strong foundation for integrating AI into existing applications with a solid plugin architecture, especially for enterprise use cases. By understanding their core strengths and seeing them in action through practical examples, you are now better equipped to select the right SDK to bring your intelligent agent ideas to life.
🕒 Last updated: · Originally published: January 15, 2026