Abstract: The present invention describes a system and method for deterministic tool selection for large language model (LLM) query execution using historical usage logs and graph-based optimization. The system utilizes a unique deterministic algorithm to identify an optimal subset of tools and MCP (Model Context Protocol) servers based on user query characteristics and prior performance metrics. The system uses LLM to extract structured intent from a natural language user query. It then incorporates a graph-based representation of tools and their relationships, where nodes and edges are scored based on historical performance and compatibility. A scoring mechanism for tools is implemented based on success rates, token usage, and execution performance. A deterministic traversal algorithm is employed over the tool graph that selects the most suitable sequence of tools for a given user query. Finally, an execution planner filters and finalizes the best tool path under resource and contextual constraints.
Description:FIELD OF INVENTION
The present invention relates to software development. More specifically, it relates to a system and method for deterministic tool section for Large Language Model (LLM) queries using historical activity data and graph-based optimization.
BACKGROUND OF THE INVENTION
Conventional methods include prompt engineering techniques, like few-shot learning and chain-of-thought prompting and task-specific fine-tuning of models to address specific use cases. Additionally, Retrieval Augmented Generation is used to integrate external knowledge into LLM responses and query rewriting techniques can refine user inputs. However, selecting the right combination of tools from a vast repository remains a challenge.
The proliferation of LLMs and their surrounding ecosystem has led to an explosion of tools and plugins that perform context-sensitive tasks. Existing systems rely on heuristic or probabilistic models, leading to inconsistent outcomes. Moreover, token limits and latency constrain further complicate decision-making. There exists a need for a deterministic, reproducible and intelligent selection mechanism that aligns tools and Model Context Protocol (MCP) servers with the needs of the user query and historical performance data.
PRIOR ART
202227025984 discloses system, method and apparatus including computer programs encoded on a computer storage medium, that identify and issue search queries expected to be issued in the future. A set of search queries that have been issued by multiple user devices can be obtained. For each query instance, contextual data can be obtained. A first query and its contextual data can be input to a model that outputs the query's likelihood of being issued in the future. The model can be trained using contextual data for training queries and a corresponding label for the training queries. The learning model outputs the first query's likelihood of being issued in future, and this query is stored as a repeatable query if the likelihood satisfying a repeatability threshold. Subsequently, a stored repeatable query is issued upon a selection of a user selectable interface component and the search engine provides search results for the query.
US20240062016A1 discloses system and method for detecting intent of a textual message for a business records process includes receiving a request message, executing semantic queries to determine an intent of the request message, by, for each semantic query, where the semantic query specifies a machine learning language model to be used, what text and metadata from the message and textual prompt to provide to each machine learning language model, and a formatting template specifying how an expected answer from each machine learning language model should be formatted, providing some of the extracted text and metadata and a textual prompt to each machine learning language model as specified in the semantic query, receiving an answer from each machine learning language model that includes an indication of an intent classification, and performing a corresponding business action in response to the indicated intent classification.
DEFINITIONS:
The expression “system” used hereinafter in this specification refers to an ecosystem comprising, but is not limited to a system with a user, input and output devices, processing unit, plurality of mobile devices, a mobile device-based application to identify dependencies and relationships between diverse businesses, a visualization platform, and output; and is extended to computing systems like mobile, laptops, computers, PCs, etc.
The expression “input unit” used hereinafter in this specification refers to, but is not limited to, mobile, laptops, computers, PCs, keyboards, mouse, pen drives or drives.
The expression “output unit” used hereinafter in this specification refers to, but is not limited to, an onboard output device, a user interface (UI), a display kit, a local display, a screen, a dashboard, or a visualization platform enabling the user to visualize, observe or analyze any data or scores provided by the system.
The expression “processing unit” refers to, but is not limited to, a processor of at least one computing device that optimizes the system.
The expression “large language model (LLM)” used hereinafter in this specification refers to a type of machine learning model designed for natural language processing tasks such as language generation. LLMs are language models with many parameters, and are trained with self-supervised learning on a vast amount of text.
The term “Deterministic algorithms/tools” used hereinafter in this specification refers to, its one that, given the same input, will always produce the same output and follow the same execution path. This predictability is crucial for many applications, including testing, debugging, and achieving reliable results in areas like financial calculations or simulations.
The term “Model Context Protocol (MCP)” used hereinafter in this specification refers to standardize how AI models, especially large language models (LLMs), interact with external tools and data sources. It essentially acts as a universal connector, enabling AI to access information, execute tasks, and utilize services in a structured and secure way.
An “optimal subset” refers to a subset of a larger set that is selected or determined to be the best or most suitable for a specific purpose or task.
OBJECTS OF THE INVENTION:
The primary object of the present invention is to provide a system and method for deterministic tool selection for LLM queries using historical activity data and graph-based optimization.
Another object of the present invention is to provide a system and method to analyzes the user query using an LLM to extract semantic intent, action types, context boundaries and model directives.
Yet another object of the present invention is to provide a system and method which retrieves historical activity logs detailing past tool invocations, success/failure metrics, token usage and execution duration.
Yet another object of the present invention is to provide a system and method that constructs a tool selection graph where nodes represent tools/MCP serves and edges represent compatibility, dependency relationships.
Yet another object of the present invention is to provide a system and method that personalized tool paths based on real query needs.
Yet another object of the present invention is to provide a system and method that applies a graph traversal algorithm to deterministically select the top-K tools that minimize token usage, maximize success likelihood and fulfil all required user action in order.
SUMMARY
Before the present invention is described, it is to be understood that the present invention is not limited to specific methodologies and materials described, as these may vary as per the person skilled in the art. It is also to be understood that the terminology used in the description is for the purpose of describing the particular embodiments only and is not intended to limit the scope of the present invention.
The present invention describes a system and method for deterministic tool selection for large language model (LLM) query execution using historical usage logs and graph-based optimization. The system utilizes a unique deterministic algorithm to identify an optimal subset of tools and MCP (Model Context Protocol) servers based on user query characteristics and prior performance metrics.
According to an aspect of the present invention, the system describes a deterministic method for selecting optimal tools and MCP servers to execute LLM queries based on historical activity logs and current query semantics. The system uses LLM to extract structured intent from a natural language user query. It then incorporates a graph-based representation of tools and their relationships, where nodes and edges are scored based on historical performance and compatibility. A scoring mechanism for tools is implemented based on success rates, token usage, and execution performance. A deterministic traversal algorithm is employed over the tool graph that selects the most suitable sequence of tools for a given user query. Finally, an execution planner filters and finalizes the best tool path under resource and contextual constraints.
BRIEF DESCRIPTION OF DRAWINGS
A complete understanding of the present invention may be made by reference to the following detailed description which is to be taken in conjugation with the accompanying drawing. The accompanying drawing, which is incorporated into and constitutes a part of the specification, illustrates one or more embodiments of the present invention and, together with the detailed description, it serves to explain the principles and implementations of the invention.
FIG. 1 illustrates a flowchart of the workflow of the present invention.
FIG.2 illustrates the sequence diagram of the system of the present invention.
DETAILED DESCRIPTION OF INVENTION:
Before the present invention is described, it is to be understood that this invention is not limited to methodologies described, as these may vary as per the person skilled in the art. It is also to be understood that the terminology used in the description is for the purpose of describing the particular embodiments only and is not intended to limit the scope of the present invention. Throughout this specification, the word “comprise”, or variations such as “comprises” or “comprising”, will be understood to imply the inclusion of a stated element, integer or step, or group of elements, integers or steps, but not the exclusion of any other element, integer or step, or group of elements, integers or steps. The use of the expression “at least” or “at least one” suggests the use of one or more elements or ingredients or quantities, as the use may be in the embodiment of the invention to achieve one or more of the desired objects or results. Various embodiments of the present invention are described below. It is, however, noted that the present invention is not limited to these embodiments, but rather the intention is that modifications that are apparent are also included.
The present invention describes a system and method for deterministic tool selection for large language model (LLM) query execution using historical usage logs and graph-based optimization. The system utilizes a unique deterministic algorithm to identify an optimal subset of tools and MCP (Model Context Protocol) servers based on user query characteristics and prior performance metrics. In the context of LLMs, tools are external functions that extend the model’s capabilities—for example, a web search tool that an LLM can call to fetch real-time news or a calculator tool to perform precise mathematical operations the model can't reliably compute on its own. In contrast, tools within a Modular Coordination Platform (MCP) are modular, reusable components designed to be orchestrated in workflows—such as a summarizer tool that condenses meeting transcripts, a code analysis tool that detects bugs, or a routing tool that delegates tasks to the most suitable model or agent. While LLM tools enhance a single model’s reasoning by enabling access to specialized functions, MCP tools are building blocks that collectively power complex, multi-step AI systems through coordination and modularity. The system incorporates LLM-driven query understanding to extract intent, action, and model preferences, and uses a graph-based scoring and traversal mechanism to select tools with optimal performance, success rates, and token efficiency. The system comprises of an input unit , a processing unit and output unit , wherein the processing unit further comprises of query interpreter module, historical activity log analyzer module, tool graph generator module, graph optimizer engine module, and execution planner module.
According to the embodiment of the present invention, the query interpreter module is powered by Large Language Model. It receives input in natural language, then extracts the intent, model, action, context from the input and outputs a structured intent profile. The historical activity log analyzer module processes tool logs over time. It aggregates success or failure rates, average tokens used, average response times and quality scores (if available). The Tool Graph Generator module creates a directed graph wherein the nodes represent tools/Model Context Protocol (MCPs), the edges represent compatibility or dependency relations, the weights on nodes represent normalized historical metrics and the weights on edges represent the overhead cost or failure risk. The weights on nodes and edges are numerical values that provide additional information about the importance, cost, or capacity of elements in a graph.
According to the embodiment of the present invention , the Graph Optimizer Engine module uses deterministic algorithms (for example topological sort and greedy score maximization or custom Dijkstra variant). A deterministic algorithm is an algorithm that, given the same input, will always follow the exact same sequence of steps, and produce the exact same output every time. This module outputs top-N paths that complete the task. Top-N Paths refer to a set of the N most optimal paths between two points in a network or graph, ranked according to specific criteria such as shortest distance, lowest cost, or highest efficiency. Instead of identifying only the single best path, this method determines multiple alternative paths, allowing for flexibility, redundancy, or improved decision-making in route selection. The Execution Planner module chooses the final path by considering token constraints, execution budget, user-defined preferences and sends the final path to the orchestrator. Orchestrator is a set of actions that are needed to perform a task. Orchestration is similar to a Jenkins or Robotic process automation that can perform set of tasks in a given order. Token constraints refer to limits on the number of tokens (small units of text) that a LLM system can process in one interaction. An orchestrator decides which tools to call, in what order, and how to handle inputs/outputs. It may also analyze a user's request, invoke relevant APIs, and combine results to give a final answer.
According to an embodiment of the present invention, system and method for deterministic tool selection for large language model (LLM) query execution as described in FIG. 1 comprises the steps of:
• Analyzing the user query using an LLM to extract semantic intent, action types, context boundaries, and model directives by the query interpreter module;
• Retrieving historical activity logs detailing past tool invocations, success/failure metrics, token usage, and execution duration by the historical activity log analyzer module;
• Constructing a tool selection graph where nodes represent tools/MCP servers and edges represent compatibility, sequencing, or dependency relationships by the tool graph generator module;
• Scoring each node based on historical success rate, token efficiency, result quality (as derived from prior evaluations) and compatibility with current query's inferred needs by the graph optimizer engine module;
• Appling the graph traversal algorithm (e.g., weighted DAG traversal, shortest path, or a custom scoring function) to deterministically select the top-K tools that minimize token usage, maximize success likelihood and fulfill all required user actions in order by the execution planner module.
According to the embodiment of the present invention, FIG. 2 is a sequence diagram that illustrates the flow of selecting top tools in response to a user request using a large language model (LLM) and an associated algorithm that evaluates tool usage data. The user initiates the process by sending a user request to the LLM (Large Language Model). The LLM processes the request and forwards it to the algorithm of the system, asking it to analyze the request to determine the best tools. The algorithm accesses activity logs to retrieve relevant tool statistics, such as usage frequency, performance, or relevance. Based on this analysis, the algorithm performs a selection of the top tools that best match the user’s request. The algorithm sends the selected top tools back to the LLM. The LLM sends the top tools back to the user, possibly with explanations or integration steps.
According to the embodiment of the present invention, the algorithm design is as follows:
1. Intent Extraction (IE):
intent = LLM.extract_intent(query)
// Output: {action: 'search', target: 'codebase', model: 'gpt-4', context: 'index'}
2. Tool Scoring (TS):
for each tool t:
score_t = w1*success_rate(t) + w2*efficiency(t) - w3*avg_tokens(t) - w4*fail_rate(t)
3. Graph Construction (GC):
G = DirectedGraph()
for each tool t:
G.add_node(t, score=score_t)
for each compatible tool t2:
G.add_edge(t, t2, weight=transition_cost(t, t2))
4. Graph Optimization (GO):
result_paths = find_top_paths(G, start=best_entry_tool(intent), constraints={token_limit})
final_plan = choose_plan(result_paths)
Advantages:
The present invention offers several key advantages. The present invention overcomes the existing shortcomings by providing an improved system and method for deterministic tool selection for LLM queries using historical activity data and graph-based optimization. The system utilizes a unique deterministic algorithm to identify an optimal subset of tools and MCP (Model Context Protocol) servers based on user query characteristics and prior performance metrics. It incorporates LLM-driven query understanding to extract intent, action, and model preferences, and uses a graph-based scoring and traversal mechanism to select tools with optimal performance, success rates, and token efficiency.
It provides deterministic and reproducible output, ensuring that the same input will consistently produce the same result, which is critical for debugging, validation, and reliable performance. It enables token-efficient and result-optimized tool usage, meaning it makes smart use of computational resources and tokens to achieve the most effective outcomes with minimal overhead. The system also supports personalized tool paths based on real query needs, allowing it to dynamically adapt the sequence and selection of tools depending on the specific requirements of a user's input, enhancing both relevance and efficiency. Additionally, it features a modular, extensible system for evolving tool stacks, which means new tools can be easily integrated or existing ones updated without disrupting the overall architecture, making it future-proof and scalable.
While considerable emphasis has been placed herein on the specific elements of the preferred embodiment, it will be appreciated that many alterations can be made and that many modifications can be made in preferred embodiment without departing from the principles of the invention. These and other changes in the preferred embodiments of the invention will be apparent to those skilled in the art from the disclosure herein, whereby it is to be distinctly understood that the foregoing descriptive matter is to be interpreted merely as illustrative of the invention and not as a limitation.
, Claims:We claim,
1. A system and method for deterministic tool section for Large Language Model queries
characterized in that
the system comprises of an input unit , a processing unit and output unit , wherein the processing unit comprises of query interpreter module, historical activity log analyzer module, tool graph generator module, graph optimizer engine module, and execution planner module;
such that the method for deterministic tool selection for large language model -LLM query execution comprises the steps of:
• analyzing the user query using an LLM to extract semantic intent, action types, context boundaries, and model directives by the query interpreter module;
• retrieving historical activity logs detailing past tool invocations, success and failure metrics, token usage, and execution duration by the historical activity log analyzer module;
• constructing a tool selection graph where nodes represent tools and Model Context Protocol servers and edges represent compatibility, sequencing, or dependency relationships by the tool graph generator module;
• scoring each node based on historical success rate, token efficiency, result quality and compatibility with current query's inferred needs by the graph optimizer engine module; and
• applying the graph traversal algorithm to deterministically select the tools that minimize token usage, maximize success likelihood and fulfill all required user actions in order by the execution planner module.
2. The system and method as claimed in claim 1, wherein the query interpreter module is powered by Large Language Model and it receives input in natural language, then extracts the intent, model, action, context from the input and outputs a structured intent profile.
3. The system and method as claimed in claim 1, wherein the historical activity log analyzer module processes tool logs over time and it aggregates success or failure rates, average tokens used, average response times and quality scores if available.
4. The system and method as claimed in claim 1, wherein the tool graph generator module creates a directed graph wherein the nodes represent tools and Model Context Protocol servers, the edges represent compatibility or dependency relations, the weights on nodes represent normalized historical metrics and the weights on edges represent the overhead cost or failure risk.
5. The system and method as claimed in claim 1, wherein , the graph optimizer engine module uses deterministic algorithms that, given the same input, will always follow the exact same sequence of steps, and produce the exact same output every time and this module outputs top-N paths that complete the task.
6. The system and method as claimed in claim 1, wherein the top-N Paths refer to a set of the N most optimal paths between two points in a network or graph, ranked according to specific criteria such as shortest distance, lowest cost, or highest efficiency such that this method determines multiple alternative paths, allowing for flexibility, redundancy, or improved decision-making in route selection.
7. The system and method as claimed in claim 1, wherein the execution planner module chooses the final path by considering token constraints, execution budget, user-defined preferences and sends the final path to the orchestrator.
8. The system and method as claimed in claim 1, wherein the user initiates the process by sending a user request to the Large Language Model, that processes the request and forwards it to the system, asking it to analyze the request to determine the best tools, then the system accesses activity logs to retrieve relevant tool statistics and based on this analysis, the system performs a selection of the top tools that best match the user’s request and sends the selected top tools back to the LLM and the LLM sends the top tools back to the user.
| # | Name | Date |
|---|---|---|
| 1 | 202521064487-STATEMENT OF UNDERTAKING (FORM 3) [07-07-2025(online)].pdf | 2025-07-07 |
| 2 | 202521064487-POWER OF AUTHORITY [07-07-2025(online)].pdf | 2025-07-07 |
| 3 | 202521064487-FORM 1 [07-07-2025(online)].pdf | 2025-07-07 |
| 4 | 202521064487-FIGURE OF ABSTRACT [07-07-2025(online)].pdf | 2025-07-07 |
| 5 | 202521064487-DRAWINGS [07-07-2025(online)].pdf | 2025-07-07 |
| 6 | 202521064487-DECLARATION OF INVENTORSHIP (FORM 5) [07-07-2025(online)].pdf | 2025-07-07 |
| 7 | 202521064487-COMPLETE SPECIFICATION [07-07-2025(online)].pdf | 2025-07-07 |
| 8 | Abstract.jpg | 2025-07-29 |
| 9 | 202521064487-FORM-9 [26-09-2025(online)].pdf | 2025-09-26 |
| 10 | 202521064487-FORM 18 [01-10-2025(online)].pdf | 2025-10-01 |