Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python AI agent libraries run a language model in a loop that calls tools, reads the results, and decides the next step. A framework manages the conversation state, tool definitions, and handoffs between agents across each run. These libraries let developers build agents that research, write code, and operate software for a user.
Popularity
LangChain has the most monthly downloads in this comparison, at 157.1M.
def main():
print("🤖 Agent with create_agent() Example\n")
# Create the model model = ChatOpenAI(
model=os.getenv("AI_MODEL"),
base_url=os.getenv("AI_ENDPOINT"),
api_key=os.getenv("AI_API_KEY"),
)
# Create agent using create_agent() - that's it! agent = create_agent(model, tools=[calculator])
# Use the agent query = "What is 125 * 8?"
print(f"👤 User: {query}\n")
# create_agent() returns a LangChain agent that expects messages array response = agent.invoke({"messages": [HumanMessage(content=query)]})
# The response contains the full state, including all messages # Get the last message which is the agent's final answer last_message = response["messages"][-1]
print(f"🤖 Agent: {last_message.content}\n")
print("💡 Key Differences from Manual Loop:")
print(" • create_agent() handles the ReAct loop automatically")
print(" • Less code to write")
print(" • Production-ready error handling built-in")
print(" • Same result, simpler API\n")
print("✅ Under the hood:")
print(
" create_agent() implements the ReAct pattern (Thought → Action → Observation)"
)
print(" and handles all the boilerplate for you.")
LangGraph
Orchestrates long-running agents through stateful graphs and a runtime.
Downloads / mo
58.7M
Stars
45.0K
Last release
1.2.22
License
MIT
Strengths
Retains graph state in checkpoints.Use a checkpointer to retain thread-scoped state across graph runs.
Pauses for application approval.Interrupt graph execution and resume it with an application-supplied response.
Limitations
Persistence needs a checkpointer.Configure a checkpointer before relying on retained thread state.
Resuming restarts the interrupted node.Keep code before an interrupt safe to repeat.
def run_hook_provider_demo(region: str = "us-west-2") -> dict[str, Any]:
"""Demonstrate HeadroomHookProvider for tool output compression.
Returns metrics from the demo run.
"""
from strands import Agent, tool
from strands.models import BedrockModel
from headroom.integrations.strands import HeadroomHookProvider
print_box(
"Demo 1: HeadroomHookProvider",
[
"The HeadroomHookProvider intercepts tool outputs and compresses",
"them BEFORE they're added to the conversation context.",
"",
"This reduces token usage for subsequent LLM calls by eliminating",
"redundant data from verbose tool outputs.",
"",
"Using: Claude 3 Haiku (anthropic.claude-3-haiku-20240307-v1:0)",
],
)
# Define tools with @tool decorator @tool
def search_docs_tool(query: str) -> str:
"""Search documentation for articles matching the query.
Args:
query: The search query to find relevant documentation
Returns:
JSON array of search results with titles, snippets, and URLs
"""
return search_documentation(query, limit=25)
@tool
def get_logs_tool(server: str, lines: int = 100) -> str:
"""Fetch server logs for analysis and troubleshooting.
Args:
server: Name of the server to fetch logs from
lines: Number of log lines to retrieve (default: 100)
Returns:
JSON array of log entries with timestamps and messages
"""
return get_server_logs(server, lines=lines)
@tool
def query_db_tool(sql: str) -> str:
"""Execute a database query and return results.
Args:
sql: SQL query to execute (e.g., SELECT * FROM users)
Returns:
JSON array of database rows
"""
return query_database(sql, limit=50)
@tool
def get_metrics_tool(timerange: str = "1h") -> str:
"""Get system metrics for the specified time range.
Args:
timerange: Time range for metrics (5m, 15m, 1h, 6h, 24h)
Returns:
JSON object with time-series metrics data
"""
return get_system_metrics(timerange)
# Create BedrockModel model = BedrockModel(
model_id="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
region_name=region,
temperature=0.1,
)
# Create HeadroomHookProvider hook_provider = HeadroomHookProvider(
compress_tool_outputs=True,
min_tokens_to_compress=100, # Compress outputs with 100+ tokens
preserve_errors=True,
)
# Create agent with hook agent = Agent(
model=model,
tools=[search_docs_tool, get_logs_tool, query_db_tool, get_metrics_tool],
hooks=[hook_provider],
)
print("\n Running agent queries that trigger tools with verbose output...")
print(" " + "-" * 60)
# Query 1: Search documentation print("\n Query 1: Searching documentation...")
result1 = agent(
"Search the documentation for 'authentication setup' and summarize "
"the top 3 most relevant articles you find."
)
print(f" Response: {str(result1)[:200]}...")
# Query 2: Get server logs print("\n Query 2: Fetching server logs...")
result2 = agent(
"Get the logs from server 'api-gateway' (100 lines) and tell me "
"how many ERROR and WARN level entries there are."
)
print(f" Response: {str(result2)[:200]}...")
# Query 3: Query database print("\n Query 3: Running database query...")
result3 = agent(
"Query the orders table and tell me how many orders have status 'completed' "
"and what the average order total is."
)
print(f" Response: {str(result3)[:200]}...")
# Query 4: Get metrics print("\n Query 4: Fetching system metrics...")
result4 = agent(
"Get the system metrics for the last hour and identify if there are "
"any services with high CPU usage (>70%) or memory issues."
)
print(f" Response: {str(result4)[:200]}...")
# Get metrics metrics = hook_provider.get_savings_summary()
# Display results print_box(
"HeadroomHookProvider Results",
[
f"Tool calls processed: {metrics['total_requests']}",
f"Compressions applied: {metrics['compressed_requests']}",
"",
f"Tokens BEFORE compression: {metrics['total_tokens_before']:,}",
f"Tokens AFTER compression: {metrics['total_tokens_after']:,}",
f"Tokens SAVED: {metrics['total_tokens_saved']:,}",
"",
f"Average savings: {metrics['average_savings_percent']:.1f}%",
],
style="success",
)
# Show per-tool breakdown if hook_provider.metrics_history:
tool_metrics = []
for m in hook_provider.metrics_history:
tool_metrics.append(
{
"tool": m.tool_name[:20],
"before": f"{m.tokens_before:,}",
"after": f"{m.tokens_after:,}",
"saved": f"{m.tokens_saved:,}",
"pct": f"{m.savings_percent:.1f}%",
}
)
print_metrics_table(
tool_metrics,
headers=["Tool", "Before", "After", "Saved", "%"],
keys=["tool", "before", "after", "saved", "pct"],
title="Per-Tool Compression Breakdown",
)
print_comparison(
metrics["total_tokens_before"],
metrics["total_tokens_after"],
"Tool Output Tokens",
)
return metrics
Pydantic AI Slim
Provides the slim package of the Pydantic AI agent framework.
@agent
def web_research_agent() -> Agent:
"""Pydantic AI Web Research Agent."""
async def execute(state: AgentState) -> AgentState:
async with agent_bridge(state) as bridge:
agent = PydanticAgent(
_pydantic_bridge_model(),
capabilities=[WebSearch()],
system_prompt="You help users find information by searching the web.",
output_type=AnswerToQueryOutput,
retries={"output": 3},
)
result = await agent.run(user_prompt(state.messages).text)
# capture the typed result as the completion (as the final # assistant message includes on the `final_answer()` tool # call that PydanticAI uses to report its answer bridge.state.output.completion = result.output.model_dump_json()
return bridge.state
return execute
from agents import Agent, Runner
agent = Agent(name='Assistant', instructions='You are a helpful assistant')
result = Runner.run_sync(agent, 'Write a haiku about recursion in programming.')
print(result.final_output)
import dspy
dspy.configure(lm=dspy.LM('openai/gpt-4.1-mini'))
agent = dspy.ReAct('question -> answer', tools=[])
result = agent(question='What is the capital of France?')
print(result.answer)
FAQ
LangGraph suits long-running agents that need explicit state and control flow. OpenAI Agents SDK and Pydantic AI Slim suit smaller agents with typed tools and handoffs. Browser Use suits agents that operate a web browser.
LangGraph orchestrates long-running agents as stateful graphs of steps. Its runtime persists state between steps, letting a run pause for human input and resume.
LangChain is a framework for building LLM applications from composable parts such as models, prompts, tools, and retrievers. Its agents run on LangGraph.
LangChain provides model integrations and a high-level agent API. LangGraph is the lower-level runtime for agents that need custom control flow and durable state.
DSPy is a framework for programming language models with declarative modules instead of hand-written prompts. Its optimizers tune prompts and weights against a metric.
google-adk is the Agent Development Kit, an open-source Google framework for building and deploying agents. It works with Gemini and other models.
For coding agents
Found your AI agent library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.