Workflow
LangChainJS
icon
Search documents
I Let an AI Control My Browser to Play Tic-Tac-Toe - LangChainJS Tutorials
LangChain· 2025-12-16 16:01
Hi, this is Christian from Lchain. Many LM providers now ship their own native tools. Not just generic function calls, but tools the model specifically trained and tuned to work with like entropics computer use, web search, bash or memory tools.With the latest version of lung chains, entropic and open air provider packages, we expose these simple provider tools so that you can call these model optimized tools seamlessly and type safe with your agent without hand rolling any JSON schemas or glue code. In thi ...
Agents Gone Wild? Use Tool Call Limits in LangChainJS to Keep Them in Check!
LangChain· 2025-11-20 16:30
Hi, this is Christian from LChain. Have you ever built an agent that just goes nuts with your API calls. Tools can give an agent incredible power, but can also cost you a lot of money to run.In this video, I will show you how you could keep your agent under control without any hard-coded guardrails within your system prompt. Today, we're taking a look at the tool called middleware within LChain. It's a clean declarative way to set credit limits, rate limits, or usage caps on any tools your agent uses.Think ...
Stop Endless Back-and-Forth — Add Model Call Limits in LangChainJS
LangChain· 2025-11-18 16:30
Agent Capabilities & Problem - LChain aims to provide customer support agents capable of handling routine questions and escalating complex issues to human support [1][2] - The industry faces challenges in preventing unproductive, lengthy conversations with AI agents, necessitating graceful escalation strategies [2][15] Solution: Model Call Limit Middleware - LChain introduces a model call limit middleware to control the number of model calls an agent can make, triggering escalation when a threshold is reached [3][4] - This middleware avoids complex conditional logic by setting limits on both thread model count (total conversation) and run model count (single invocation), effectively limiting tool calls [3][5][6] - The middleware uses "after model" and "after agent" hooks to track model call counts, resetting the run model count after each agent interaction [7] - When the model call limit is reached, the middleware can either throw an error or end the conversation with a predefined AI message, providing a customizable escalation path [8][11] Implementation & Example - LChain's example application demonstrates a customer support agent that answers questions about customer accounts and escalates when the model call limit is hit [8] - The agent utilizes predefined customer data, tools for data interaction, and the model call limit middleware configured with a thread limit and run limit, exemplified by a hard-coded limit of eight model calls [9][10] - The demo showcases how the agent initially answers customer queries but escalates to human support when the conversation becomes unproductive or exceeds the model call limit [11][12][13] Benefits & Conclusion - The model call limit middleware offers a reliable guardrail, preventing agents from overthinking and ensuring responsible escalation in real-world applications [14][15] - LChain encourages users to explore and combine various middlewares to enhance agent capabilities, providing a path to build more robust and stable AI agents [16]