<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LangChain &#8211; iAIFeed</title>
	<atom:link href="https://www.iaifeed.com/tag/langchain/feed" rel="self" type="application/rss+xml" />
	<link>https://www.iaifeed.com</link>
	<description>iAIFeed</description>
	<lastBuildDate>Mon, 12 Oct 2026 12:41:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://www.iaifeed.com/wp-content/uploads/2026/07/cropped-iaifeed1-80x80.png</url>
	<title>LangChain &#8211; iAIFeed</title>
	<link>https://www.iaifeed.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Add Tool-Calling Agents to a LangChain App</title>
		<link>https://www.iaifeed.com/how-to-add-tool-calling-agents-to-a-langchain-app</link>
					<comments>https://www.iaifeed.com/how-to-add-tool-calling-agents-to-a-langchain-app#respond</comments>
		
		<dc:creator><![CDATA[iamltlb]]></dc:creator>
		<pubDate>Mon, 12 Oct 2026 12:41:33 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[LangChain]]></category>
		<guid isPermaLink="false">https://www.iaifeed.com/how-to-add-tool-calling-agents-to-a-langchain-app</guid>

					<description><![CDATA[Turn a plain retrieval chain into an agent that decides when to search, call an API, or answer directly. Working code, real limits, and when an agent is the wrong choice.]]></description>
										<content:encoded><![CDATA[<p>Once a basic <a href="https://www.iaifeed.com/ai-tool/langchain">LangChain</a> chain works, the next step is letting the model choose its own actions. That is what an agent does: it reads your question, picks a tool, reads the result, and repeats until it has an answer.</p>
<p><strong>Quick answer:</strong> Define tools with the <code>@tool</code> decorator, pass them to <code>create_react_agent</code> or <code>AgentExecutor</code>, and cap the loop with <code>max_iterations</code>. Setup is about 20 lines.</p>
<p>Fair warning up front: agents are slower and cost more than a fixed chain. Every tool call is another round trip to the model. I only reach for one when the path genuinely depends on the input.</p>
<h2>When should you use an agent instead of a chain?</h2>
<p>Use an agent when the number of steps is unknown at build time. A support bot that might check an order, then refund it, then email the customer fits. A summarizer that always loads a doc and summarizes fits a chain, and running it as an agent just adds latency and failure points.</p>
<h2>How do you define a tool in LangChain?</h2>
<p>The decorator route is cleaner than the old dictionary style because the docstring becomes the description the model reads when deciding whether to call it.</p>
<pre><code>from langchain_core.tools import tool

@tool
def get_order_status(order_id: str) -> str:
    """Look up the shipping status for an order ID."""
    return db.fetch(order_id)</code></pre>
<p>The docstring is not decoration. Vague descriptions are the single biggest cause of an agent calling the wrong tool.</p>
<h2>How do you wire the agent together?</h2>
<p>LangGraph is the current recommended path; the older <code>AgentExecutor</code> still ships but the team pushes people toward graphs for anything with branching.</p>
<pre><code>from langchain.agents import create_react_agent, AgentExecutor
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = create_react_agent(llm, [get_order_status, search_docs], prompt)
executor = AgentExecutor(agent=agent, tools=[get_order_status, search_docs],
                         max_iterations=6, verbose=True)
print(executor.invoke({"input": "Is order A19 shipped?"}))</code></pre>
<p>Set <code>max_iterations</code>. Without it a confused agent will keep calling tools until you hit a rate limit or your budget does.</p>
<h2>Chain vs agent: which fits your case?</h2>
<table>
<tr>
<th>Dimension</th>
<th>Fixed chain</th>
<th>Tool-calling agent</th>
</tr>
<tr>
<td>Latency</td>
<td>One model call</td>
<td>One call per step</td>
</tr>
<tr>
<td>Cost</td>
<td>Predictable</td>
<td>Scales with tool use</td>
</tr>
<tr>
<td>Debugging</td>
<td>Linear, easy</td>
<td>Branching, needs tracing</td>
</tr>
<tr>
<td>Best for</td>
<td>Known workflow</td>
<td>Unknown number of steps</td>
</tr>
</table>
<h2>How do you debug a misbehaving agent?</h2>
<p>Turn on <code>verbose=True</code> first. Nine times out of ten you see the model picking a tool that does not match the intent, and the fix is a sharper docstring or a tighter parameter type. LangSmith, the vendor&#8217;s tracing tool, has a free tier and shows every step; it is worth the extra setup once your agent has more than three tools.</p>
<h2>What does it cost to run?</h2>
<p>An agent with a couple of steps on GPT-4o runs roughly $0.03-$0.10 per conversation; the same task on a fixed chain is closer to a cent. If you are on gpt-4o-mini, multiply your expectations down by 10-15x. There is no LangChain fee — you pay your provider.</p>
<h2>What are the limits people hit?</h2>
<ul>
<li>Looping: the agent retries the same failing tool. Cap iterations and add a fallback message.</li>
<li>Tool sprawl: past 10-15 tools, selection accuracy drops. Split into sub-agents.</li>
<li>Silent errors: a tool returning an empty string looks like success. Return explicit error text.</li>
<li>Version churn: package names moved between 0.1 and 0.3; pin your versions.</li>
</ul>
<p><strong>Who this suits:</strong> teams building assistants that need to act, not just answer. <strong>Who should wait:</strong> if your task is a fixed pipeline, an agent will be slower and harder to test. Build the chain first.</p>
<h2>Quick Summary</h2>
<ul>
<li>Agents let the model choose tools; chains run a fixed path.</li>
<li>Define tools with <code>@tool</code> and a clear docstring the model can read.</li>
<li>Always set <code>max_iterations</code> to stop runaway loops.</li>
<li>Expect 3-10x the cost and latency of an equivalent chain.</li>
<li>LangGraph is the recommended structure for branching agents in 2026.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.iaifeed.com/how-to-add-tool-calling-agents-to-a-langchain-app/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Build Your First AI App With LangChain in 2026</title>
		<link>https://www.iaifeed.com/how-to-build-your-first-ai-app-with-langchain</link>
					<comments>https://www.iaifeed.com/how-to-build-your-first-ai-app-with-langchain#respond</comments>
		
		<dc:creator><![CDATA[iamltlb]]></dc:creator>
		<pubDate>Mon, 12 Oct 2026 12:41:14 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[LangChain]]></category>
		<guid isPermaLink="false">https://www.iaifeed.com/how-to-build-your-first-ai-app-with-langchain</guid>

					<description><![CDATA[A hands-on walkthrough of installing LangChain, wiring up an LLM, and shipping a working chain that answers questions over your own PDFs.]]></description>
										<content:encoded><![CDATA[<p>LangChain is an open-source Python and JavaScript framework for connecting large language models to your own data, tools, and APIs. This guide builds a small but real app: a chain that reads a PDF and answers questions about it.</p>
<p><strong>Quick answer:</strong> Install <a href="https://www.iaifeed.com/ai-tool/langchain">LangChain</a> with <code>pip install langchain langchain-openai</code>, set your API key, and you can have a working question-answering chain in about 30 minutes.</p>
<p>I keep the scope tight on purpose. Most tutorials try to cover agents, memory, and 12 integrations at once, and you end up copying code you don&#8217;t understand. Here you get one chain that works, then a few notes on where to go next.</p>
<h2>What do you need before starting?</h2>
<p>Python 3.10 or newer, and an API key from any provider LangChain supports. OpenAI works out of the box, but the same code runs on Anthropic, Google, or a local Ollama model with a three-line swap.</p>
<p>You do not need a GPU. The heavy lifting happens on the provider&#8217;s servers. Budget roughly $0.01-$0.05 per run on a mid-size document with GPT-4o-mini class models.</p>
<h2>How do you install LangChain?</h2>
<p>LangChain split into packages in late 2024, so install the core plus the integration you need. The old monolithic <code>langchain</code> package still works but wires up everything, which is slower to import.</p>
<pre><code>pip install langchain langchain-openai langchain-community pypdf</code></pre>
<p>Then export your key. Never hardcode it.</p>
<pre><code>export OPENAI_API_KEY="sk-..."</code></pre>
<h2>How do you load and split a PDF?</h2>
<p>Loaders live in <code>langchain-community</code>. Splitting matters more than people expect: chunks of 800-1000 characters with 100 characters of overlap tend to retrieve better than one giant blob.</p>
<pre><code>from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter

docs = PyPDFLoader("report.pdf").load()
chunks = RecursiveCharacterTextSplitter(
    chunk_size=900, chunk_overlap=120
).split_documents(docs)</code></pre>
<h2>How do you store the chunks and retrieve answers?</h2>
<p>Vector stores turn text into embeddings so you can search by meaning. Chroma is the least painful local option, and you can always move to a hosted store later.</p>
<pre><code>from langchain_openai import OpenAIEmbeddings, ChatOpenAI
from langchain_chroma import Chroma
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate

store = Chroma.from_documents(chunks, OpenAIEmbeddings())
retriever = store.as_retriever(search_kwargs={"k": 4})

prompt = ChatPromptTemplate.from_template(
    "Answer using only this context:\n{context}\n\nQuestion: {question}")

chain = ({"context": retriever, "question": RunnablePassthrough()}
         | prompt | ChatOpenAI(model="gpt-4o-mini") | StrOutputParser())

print(chain.invoke("What was Q3 revenue?"))</code></pre>
<p>The <code>|</code> operator is the part worth understanding. Each piece takes the previous output and passes it forward. Debugging is easier when you print the output of each step instead of the final answer only.</p>
<h2>Is LangChain free?</h2>
<p>The library is MIT licensed and costs nothing. You pay your model provider. Running GPT-4o-mini over a 40-page PDF costs a few cents per question; the same query on a frontier model can be 20-50x more.</p>
<h2>What are the common mistakes?</h2>
<ul>
<li>Chunks too large, so the retriever pulls irrelevant text and the model drifts.</li>
<li>Forgetting overlap, which cuts sentences in half at boundaries.</li>
<li>Not setting <code>k</code>, so you get the default handful of chunks whether or not they help.</li>
<li>Ignoring <code>langchain_text_splitters</code> as a separate package and hitting import errors.</li>
</ul>
<p><strong>Who this suits:</strong> developers who want to prototype RAG or tool-calling apps without building the glue from scratch. <strong>Who should skip it:</strong> if you only need a chat completion call, the raw OpenAI SDK is less code and fewer version upgrades.</p>
<h2>Quick Summary</h2>
<ul>
<li>LangChain is a free open-source framework for connecting LLMs to data and tools.</li>
<li>Install with <code>pip install langchain langchain-openai</code> plus a vector store package.</li>
<li>Split documents into 800-1000 character chunks with overlap for better retrieval.</li>
<li>You pay only your model provider, typically cents per query.</li>
<li>Best for RAG and agent prototypes; overkill for a single chat call.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.iaifeed.com/how-to-build-your-first-ai-app-with-langchain/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
