The 100-Tool Agent Is a Trap - Sohail Shaikh & Ankush Rastogi, Prosodica
AI Engineer · 28 min · 271 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01Hi everyone.
- 00:02Thanks for being here.
- 00:04I am Sohaib here and along with me is Ankush.
- 00:07So, today we'll be talking about a mistake that looks harmless at first.
- 00:13Giving which is basically giving an AI agent every tool access it might ever need all at once.
- 00:20So, basically that approach works well in a demo.
- 00:24It might even work with a small number of tools like like say for example 10 tools.
- 00:30But once the catalog grows, the agent gets slower.
- 00:36It might become more expensive and less accurate as well.
- 00:40That is why we are calling it the 100 tool agent trap.
- 00:43In the next half an hour or so, we'll show why it breaks, what the numbers look like, and how semantic routing with just-in-time context can help us fix this problem.
- 00:57So, a quick introduction about myself.
- 01:00I am Sohaib Shaikh.
- 01:02I'm currently working as a data scientist with Presodica.
- 01:06My background spans across AI, NLP, marketing, analytics, and even engineering.
- 01:13My current focus is on applied AI, NLP, and conversational intelligence along with rack systems.
- 01:20I'm especially interested in making AI systems more reliable, measurable, and even scalable beyond the demos in production.
- 01:31And I'm Ankush Astogi.
- 01:32I work as a senior data solutions engineer at Presodica.
- 01:38I have spent more than a decade in AI, data engineering, and production systems.
- 01:43My focus is the engineering side.
- 01:47So, it's not about what's going to work in notebook, but whether it's going to survive in with real load, real user, and real failures.
- 01:59So, that is the angle we are taking today.
- 02:04Suhail will focus more on the model and routing behavior, and I will focus more on system design, implementation, and production trade-offs.
- 02:15Awesome.
- 02:15Thank you, Ankush.
- 02:17Um so, let's get into it.
- 02:20So, let's imagine a common design.
- 02:22Um you tend to build a system, and it can do many things.
- 02:28Say, for example, querying a database, sending an email, um even checking a calendar, or looking up an order, calling an API, and so on and so forth.
- 02:38The simplest approach over here would be to give a model every tool definition on every request.
- 02:46Every function name, um every description, and even every JSON schema will go into the prompt, whether the user might need it or not.
- 02:55So, that We are calling that as a fat agent.
- 02:57At small scale, it feels fine.
- 03:00With 10 tools as well, the model might usually pick the right one.
- 03:04The demo looks good.
- 03:07Then, the product grows.
- 03:08Um 10 tools might become 30, or it will keep on increasing, and eventually the model starts calling the wrong function, and starts confusing similar tools, may invent tool names, and even take longer to respond.
- 03:28The important point is, basically, the design does not fail because one tool is badly written.
- 03:35It fails because every request is forced to carry the entire catalog.
- 03:40So, let's look here.
- 03:42There are, say for example, uh 741 tools in your uh in your entire schema, but and it will look, basically, take up to 127,000 tokens just to have all those tool descriptions in it.
- 04:00And this is even before the user user's actual question is even considered.
- 04:06So, basically, this will lead to context overload and uh we need to manage that properly.
- 04:15So, on this slide we see why it is failing and why the accuracy collapses beyond a point.
- 04:22So, when you look at the accuracy curve with the 10 tools, fat agent will get the tools right almost 78% of the times.
- 04:31That is not perfect, but it's usable.
- 04:35At almost 100 tools, the accuracy drops to around 40%.
- 04:39Less than half of the tools that are called are the correct tools.
- 04:45And if it grows beyond that, like say for example, in over here, at 741 tools, the accuracy will be a mere 13.6%.
- 04:55So, in short, it's roughly one correct tool out of eight tools.
- 05:00So, when we compare it with the semantic router, semantic router behaves very differently.
- 05:05It stays above 83% across the same catalog sizes.
- 05:11That is because the model is not choosing from hundreds of tools, it's choosing from a small and relevant set.
- 05:18One reason the fat agent fails is because it's lost in the middle problem.
- 05:24Model pays stronger attention to the beginning and end of the long context.
- 05:29When hundreds of tool schemas are packed into the middle, the model does not reliably use them.
- 05:35So, we end up paying paying for a huge prompt, and that prompts makes the decisions even harder.
- 05:45So, two more reasons over here.
- 05:48First is the latency and the second is the cost.
- 05:51So, we saw in the earlier slide that accuracy was a big problem.
- 05:56Another issue is with latency and cost over here as we can see.
- 06:03So, like say for example, if we have 741 tools, we saw that it requires almost 127,000 tokens.
- 06:11That will include the tool description and the schema text.
- 06:15So, that cost is basically being paid on every request.
- 06:20At 100,000 requests a day, if you push this into production, you are sending in billions of tokens and just to describe those tools.
- 06:30And with just-in-time routing, the prompt may include only three to five relevant schemas, closer to about 1,000 tokens.
- 06:38That is roughly a 99% reduction in tool context tokens.
- 06:44Another issue is latency.
- 06:46With fat agent approach, time to first token grows as the tool catalog grows because the model has to process a larger prompt before it can answer the user question.
- 06:57So, say for example, if you have 500 tools in your agent, the fat agent path can push first token latency past 5 seconds.
- 07:08So, this is specifically important if your product is real-time because this will take longer time to respond.
- 07:18So, which will make the design feel slow and unpredictable.
- 07:21So, and with semantic routing, it might feel more responsive and it will be more real-time in a way.
- 07:33Here is the clean comparison.
- 07:35So, on the left side, we have a fat agent design and on the right side, we have our semantic router design.
- 07:43So, in the fat agent design, every schema is loaded for every request, no matter what the user asked.
- 07:54And because of that, the catalog will grow, the prompt will grow, due to which the latency will rise and accuracy will drop.
- 08:04The agent also becomes one large monolithic, which makes it hard to test, risky to update, and even painful to debug.
- 08:16But, in the case of semantic routing design, the agent does not start with every tool.
- 08:23So, in this case, the router first look at the user's query.
- 08:29It retrieves the three to five most relevant tool, and then it injects only those into the model call.
- 08:38So, the context stays small, latency stays stable, and the accuracy holds because the model is choosing from a focused list instead of giant catalog.
- 08:51This is Okay, so there is a one important caveat here.
- 08:56If you have fewer than 20 tools, a router may be unnecessary.
- 09:02Just load the tools directly.
- 09:04But, once you passed 50 tools in the production system, then justifying router-based schema make more sense.
- 09:19Thanks, Ankush.
- 09:20So, let's now look into how semantic routing works.
- 09:25If you have built a rack system previously, this will feel pretty similar to that.
- 09:30The difference is that we will retrieve tools instead of the documents.
- 09:35So, at the first stage, say for example, over here, each tool will have a clear description.
- 09:42For example, a search flights tool, uh a check calendar availability tool, or a retrieve customer order status.
- 09:50Say for example, the second step would be those descriptions needs to get embedded and stored in a vector index.
- 09:59This is usually done offline when the tool catalog is created or updated.
- 10:06At the runtime, the user will ask a question, we embed the user query with the same embedding model.
- 10:15Then, we search that vector index for the tools with the description that are closest to the query.
- 10:23So, the router will then return the top K tools.
- 10:27Often, K would be three or five tools that matches the user query.
- 10:32And only those selected schemas will get injected into the model call.
- 10:38So, this is the whole pattern.
- 10:40At the first step, you need to index tool descriptions offline.
- 10:45Then, retrieve relevant tools at runtime and keep the model's context focused.
- 10:51So, in short, the idea is pretty simple.
- 10:55Semantic routing is basically a rack for tools.
- 10:58Um if you already have an embedding model and vector database in your stack, most of the infrastructure is already familiar to you.
- 11:10Thank you, Sohil.
- 11:11Now, we will deep dive into just-in-time context injection.
- 11:16So, semantic routing is the retrieval layer.
- 11:21And just-in-time context injection is the context management strategy.
- 11:27So, in the case of fat agent approach, it loads everything before the query is understood.
- 11:35Due to which the model receives a huge list of tools first, and then it tries to reason through it.
- 11:45Just-in-time context does the reverse.
- 11:48It will wait until the query is known, then it will inject only the context needed for that request.
- 11:58I mean, this is not a new software idea.
- 12:01We have used lazy loading, just-in-time compilation, and on-demand resource loading from years.
- 12:10We are just applying the simple and same principle to the LLM context.
- 12:16Anthropic has written about this pattern with on-demand tooling loading through MCP.
- 12:24Their report token usage went from 150k tokens down to 2,000, which is 98.7% token reduction.
- 12:36That is the signal.
- 12:37Large tool catalog should not be dumped into the into every prompt.
- 12:43They should be retrieved when needed.
- 12:47So, moving to the next slide, let's talk about how to evaluate this fairly.
- 12:56We measure four things here: tool selection accuracy, time to first token, input tokens per request, and the estimated cost per thousand call.
- 13:09So, here for data sets, we used Berkeley function calling leaderboard, Skills bench style scenarios, and synthetic tool pools that allow us to scale the number of tools, so we can test
- 13:24at 10, 50, 100, 200, or even 1041 tools.
- 13:30So, we ran the same queries in two modes, the fat agent one and the semantic routing.
- 13:37Same model, same answer key, same tool catalog.
- 13:42The only difference was whether the model saw every tool or only the routed tool.
- 13:49We also swept K at 3, 5, 10 to understand the trade-off.
- 13:56So, the smaller K is the faster and cheaper.
- 13:59Larger K can be the can recover more edge cases.
- 14:05In practice, K equals 5 is a strong default starting point.
- 14:09So, if you are want to try this, you can default it to five.
- 14:15Here, K means the number of tools the semantic router retrieves and gives to the LLM for each user queries.
- 14:26Here are the benchmark result that we got.
- 14:30So, here is the result on the left side.
- 14:35We see the fat agent accuracy line drop sharply as the tool count grows.
- 14:42It started around 78% at 10 tool and then falls to around 13% at 1041 tools.
- 14:51But, in the case of router, the router line stays above 83% because the model stays stable.
- 15:00From the model points of view, it always choosing the handful of tool, even if the real catalog contains 100.
- 15:13On the right side, time to first token shows the same story.
- 15:19The fat agent path gets slower as more tool schemas are added.
- 15:26At large catalog sizes, the model spend noticeable time just processing the prompt.
- 15:34But in case of router, it stays almost flat because of the prompt size is under controlled.
- 15:43This is the core lesson from the benchmark.
- 15:47The catalog can grow, but the model's working set should stay small.
- 15:54Now, on the next slide, we'll be discussing about the implementation pattern.
- 16:00There are three steps in it.
- 16:03Step one is offline.
- 16:05So, build a catalog of tool.
- 16:08For each tool, store the name, description, schema.
- 16:13Then, embed the description and store it into a vector database.
- 16:19You can use Chroma DB, you can use Pinecone, you can use Quadrant.
- 16:25Whichever vector database you are using.
- 16:28Then, step two will happen on every request.
- 16:33Embed the user's query.
- 16:35Then, run the nearest neighbor search.
- 16:38And return the top K tools.
- 16:42In the step three, it will also happen on every request.
- 16:48Fetch the schema for those selected tools.
- 16:52And then, pass only those schemas into the model call and log which tool was selected.
- 16:59So, here, logging really matters.
- 17:02So, let's say if you miss something and if you want to improve the description or you want to tune the K, you need a good logging system that you can use it.
- 17:16So, the runtime overhead is small, one embedding call, and one vector search.
- 17:24The payoff is much smaller prompt and more stable tool selection problem.
- 17:33Awesome.
- 17:34So, now that you have learned about the implementation pattern, I'll take you through the code version of it, which is pretty straightforward.
- 17:45So, initially you need to loop through the tool catalog, and for each tool, as Ankur mentioned, embed the description, store that in the vector database with the tool name and other details.
- 17:57At run time, embed that user query, compare that query vector against the stored tool vectors using cosine similarity or vector search, and then retrieve the top most relevant tools,
- 18:13and then call the model only with those schemas and the function or tool parameter.
- 18:19That final line is the most important part because the model does not receive all the tools, it only receive the routed tools.
- 18:26This works with any embedding model and at and with any vector database.
- 18:31You can start, as Ankur mentioned, you can start with Quadrant or any other database vector database locally, and then move to a more managed vector store later if needed.
- 18:44If you already have an existing rag infrastructure, this is not a new infrastructure as we mentioned earlier, it is the same retrieval pattern applied to the tool selection.
- 18:56Thank you, Suhail.
- 18:58Uh Now, we will discuss semantic routing in action.
- 19:03So, imagine you have a 200 tool agent.
- 19:07A user asks, "Find me a flight to New York next Wednesday.
- 19:13The router embeds that query.
- 19:16Returns tool like search flights, book flight, calendar check.
- 19:21The model sees only those relevant schema, so it is much more likely to call the correct tool.
- 19:29But, if we load all 200 tools, hotels tool, weather tool, emails tool, sequels tool, or any unrelated workflow tool, it would all be competing for attention.
- 19:44That is when model starts choosing the wrong function.
- 19:49Now, let's take a second query.
- 19:52What is the weather in Paris right now?
- 19:55The router returns get weather and get forecast.
- 20:00Flights tools are not injected.
- 20:03Hotels tools are not injected.
- 20:06They are simply not available at this request.
- 20:10This is an underrated benefit.
- 20:13But, the router does not only add the right tool, it also removes the wrong tool from the model's choice set.
- 20:22Now, in the next slide, we will discuss implementation checklist.
- 20:28So, here is the production checklist if somebody wants to uh follow this along.
- 20:34So, first, get locked the tool in one place.
- 20:39So, add name, description, schema, owner, and the version.
- 20:45Second is to build the index.
- 20:48Embed each description and store the vectors.
- 20:53The third one is write the router.
- 20:57So, in this, embed the query, then search the index, and take top K and fetch schema.
- 21:06The next one is the fourth one in which a user need to wire it up into the agent loop.
- 21:13So, the model tool list should come from the router, not from a hard-coded full catalog.
- 21:21Fifth is to evaluate.
- 21:23Run your test set at K equals to three, five, and 10, and then pick the smallest K that meets your accuracy target.
- 21:36Sixth is to monitor production.
- 21:39Log selected tools, final tool calls, failure, and fallback usage.
- 21:47Then re-embed tools when descriptions or schema change.
- 21:52This is not the 6-month platform rewrite.
- 21:56For most team, it is a focused sprint.
- 22:00So, in the next slide, we will discuss what community already has confirmed.
- 22:09This is not just the observation.
- 22:11So, Anthropic has published on-demand tool loading with MCP, and reported a drop of 150k tokens to 2k, which is a huge reduction in tokens.
- 22:24Developers have raised similar issues in mainstream agent and SDK projects, pointing out that sending all tools definition on every request can increase latency, token usage, and tool confusion.
- 22:44Open proj open-source projects like MCP zero have also explored routing at very large scale, including thousands of tool across many servers.
- 22:59And you can find form forums post from builder who hit tool confusion with only few tools.
- 23:08Long before they reach 100.
- 23:10So, if you if your agent start failing as tool are added, it doesn't automatically means your prompt are bad.
- 23:20It may means the architecture is asking the model to solve the wrong problem.
- 23:30So, here we are just trying to say about the We are going to talk about the open-source projects that we came across.
- 23:39So, one of them is of from Areilo Labs.
- 23:43They have an open-source semantic router project that you can easily use to test locally for benchmarking, Toolbench, and the Berkeley function calling loader leaderboard are also useful starting points.
- 23:57And for practical guidance, you could read the Anthropic MCP write-up.
- 24:02It explains why on-demand tool loading matters and gives a strong real-world signal for this architecture.
- 24:10The point is that you don't need to invent the ecosystem from scratch.
- 24:14Those pieces already exist.
- 24:18Next slide.
- 24:24Sorry.
- 24:25Here it is.
- 24:27Thank you.
- 24:27So, there are a few trade-offs with this.
- 24:30The first risk could be a router miss.
- 24:34So, if the So, the router may fail to retrieve the tool the models need and handle that with you could handle that with a feed fallback.
- 24:45If the model cannot complete the task, you could widen K, run a second retrieval pass, or even route it to a broader tool group.
- 24:55The second risk would be weak tool descriptions.
- 24:59If your descriptions are weak, embeddings will end up being weak.
- 25:04Write descriptions in the words users actually use and include intent, action, and key entities along with it.
- 25:13The third risk would over here would be rare tools.
- 25:17So, some tools may never score high unless their descriptions include the right language.
- 25:23So, you need to monitor data misses and rewrite those descriptions accordingly.
- 25:28And finally, just to conclude, do not over-engineer small systems.
- 25:33If you have 10 or 15 tools, static loading may still be fine.
- 25:38Routing generally pays off when the catalog is large enough that the prompt size, latency, or tool confusion becomes a real production problem.
- 25:51So, a few takeaways.
- 25:55First thing is, as we discussed, tool overload hurts accuracy.
- 25:59Loading every schema into every prompt makes the model's decision harder as the catalog grows on.
- 26:07The second one would be to about tokens.
- 26:11It's like tokens are both cost and latency.
- 26:16Larger tool catalogs can add add tens of thousands of tokens before the user's actual request is handled.
- 26:24Semantic routing can help fix that problem.
- 26:28The When the catalog can be is large, the model only sees the tools relevant to the current query.
- 26:37This is basically a rag for tools.
- 26:40Index those descriptions, properly retrieve at run time, and inject only what is needed.
- 26:46And finally, start simple.
- 26:49Use K as five as a starting point, log every decision, and evaluate against a real test set.
- 26:58And improve their tools descriptions over time in case you get incorrect tools being picked up.
- 27:07And the goal is not to make these agents more complicated.
- 27:11It's It is basically to stop forcing the model to reason over irrelevant tools.
- 27:20So, there are some references on this slide.
- 27:24So, if you're building something, you can use these references.
- 27:29Like semantic routing libraries, tool bench, Berkeley function calling leaderboard, Anthropic MCP write-up, and vector stores like Pinecone, Quadrant.
- 27:43Thank you so much for watching this.
- 27:46If this was useful, please share it with someone building agents.
- 27:50They have either already hit this wall or they're about to.
- 27:55You can scan our LinkedIn QR codes on this slide to connect with us.
- 28:01We are happy to continue the conversation, share resources, or hear how others are approaching this problem in their own system.
- 28:11Thank you so much for watching this.
- 28:14I'm Ankush.
- 28:16This is Suheel, here.
- 28:17Thank you so much.
- 28:18Yeah.
- 28:19Thanks, everyone.