Evolvan - Case Study of undefined
Loading
Case Studies

FileAI LangSmith Cost Reduction

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

40%

Token Reduction Scenario

Input Cost / Query

Tools Offered

FileAI LangSmith Cost Reduction

The Challenge

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.

Unrestricted Tool Exposure

Every agent iteration received the complete set of approximately 38 tool definitions, regardless of the request's domain or complexity.

Repeated System Instructions

The long system prompt was attached to successive LLM calls, increasing the cumulative input-token count.

Unnecessary Write-Action Instructions

Read-only queries also carried the extensive rules governing write operations, confirmations, and action execution.

Context Cost Before 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.

Our Solution

The optimization combines LangSmith observability, domain-based tool selection, optional semantic matching, selective prompt construction, and automated evaluation.

Instrumentation and Tracing

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.

Request-Level Tool Selection

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.

Selective Prompt Construction

The agent receives only the selected tool definitions. For read-only requests, the unnecessary write-action instruction block is excluded.

Existing Agent Execution

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.

Business Impact

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.

40%

Input-token reduction

59%

Reduction in tools offered

4.00 seconds

End-to-end response time

$636

Monthly savings

LangSmith Trace Comparison

A comparison of the agent’s tool exposure and input-token consumption before and after request-level tool selection was introduced.

Request Processing Flow

Incoming request → Tool selection → Prompt construction → LLM execution → Tool execution → Response

Instrument and Trace

LangSmith tracing captures LLM execution details and token usage across agent runs.

Select Relevant Tools

The tool selector identifies relevant tools using keyword-based, semantic, or hybrid selection.

Construct the Prompt

The agent receives only the selected tool definitions and the instructions needed for the current request.

Execute the Existing Agent Loop

The custom tool-calling loop executes the request using the selected tools without requiring a replacement architecture.

Evaluate and Recover

Evaluation measures tool recall, tools offered, estimated token usage, and fallback behavior, while full-catalog retries preserve reliability when selection is uncertain.

Evolvan's Role

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.

Observability and Baseline Analysis

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.

Intelligent Tool Selection

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.

Prompt and Agent Optimization

Evolvan optimized prompt construction so the agent receives selected tool definitions and request-specific instructions while preserving FileAI’s existing custom tool-calling loop.

Evaluation, Reliability and Safety

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.