FileAI optimized its custom AI assistant to reduce LLM input-token consumption by selecting relevant tools for each request instead of sending the entire tool catalog with every model call.
Input Tokens / Query
Token Reduction Scenario
Input Cost / Query
Tools Offered

LangSmith tracing exposed a significant source of overhead: even a simple, read-only schedule query repeatedly included 37–38 tool definitions and an extensive write-action instruction block, despite requiring only one tool.
Every agent iteration received the complete set of approximately 38 tool definitions, regardless of the request's domain or complexity.
The long system prompt was attached to successive LLM calls, increasing the cumulative input-token count.
Read-only queries also carried the extensive rules governing write operations, confirmations, and action execution.
These costs accumulated before the model could make its decision. Reducing the number of tools used after a model call would not eliminate the cost of sending their definitions in the first place.
The optimization combines LangSmith observability, domain-based tool selection, optional semantic matching, selective prompt construction, and automated evaluation.
LangSmith tracing uses traceable and wrapOpenAI to capture LLM execution details, including token usage, across agent runs. This makes it possible to identify expensive calls and quantify prompt overhead.
A dedicated tool-selector.js module identifies relevant tools using domain keywords covering workforce, finance, sales, trade partners, folders, and notifications. The selector supports keyword-based, semantic, and hybrid strategies.
The agent receives only the selected tool definitions. For read-only requests, the unnecessary write-action instruction block is excluded.
The custom tool-calling loop continues to execute the request using the selected tools. The optimization does not require replacing the existing architecture with LangGraph.
The headline query's input-token consumption fell by 10,600 tokens, a 40% reduction. The offline evaluation independently demonstrated that the selector offered 15.1 tools on average, compared with 37 in the evaluated baseline. Response time decreased by approximately 27%, from 5.48 seconds to 4 seconds.
Input-token reduction
Reduction in tools offered
End-to-end response time
Monthly savings
A comparison of the agent’s tool exposure and input-token consumption before and after request-level tool selection was introduced.
Incoming request → Tool selection → Prompt construction → LLM execution → Tool execution → Response
LangSmith tracing captures LLM execution details and token usage across agent runs.
The tool selector identifies relevant tools using keyword-based, semantic, or hybrid selection.
The agent receives only the selected tool definitions and the instructions needed for the current request.
The custom tool-calling loop executes the request using the selected tools without requiring a replacement architecture.
Evaluation measures tool recall, tools offered, estimated token usage, and fallback behavior, while full-catalog retries preserve reliability when selection is uncertain.
Evolvan analyzed FileAI’s AI-assistant traces and identified repeated tool-schema and instruction overhead as a major source of unnecessary token consumption. Evolvan designed and implemented the request-level tool-selection layer, selective prompt construction, LangSmith observability, offline evaluation workflow, and reliability guardrails required to reduce context usage without replacing the existing agent architecture or weakening its execution safeguards.
Evolvan instrumented the agent workflow with LangSmith tracing to measure token usage at each LLM step, identify repeated tool-schema overhead, and establish a measurable baseline for optimization.
Evolvan designed the request-level selector that combines domain keywords, semantic matching, and hybrid selection strategies to expose only the tools relevant to each request.
Evolvan optimized prompt construction so the agent receives selected tool definitions and request-specific instructions while preserving FileAI’s existing custom tool-calling loop.
Evolvan implemented offline evaluation, full-catalog fallbacks, retry behavior, feature-flag rollback, and confirmation safeguards to reduce context without compromising tool recall, permissions, or action security.