FitText: Evolving Agent Tool Ecologies via Memetic Retrieval Kyle Zheng, Han Zhang, Renliang Sun, Chenchen Ye, Wei Wang Abstract A semantic gap separates how users describe tasks from how tools are documented. As API ecosystems scale to tens of thousands of endpoints, static retrieval from the initial query alone cannot bridge this gap: the agent’s understanding of what it needs evolves during execution, but its tool set does not. We introduce FitText , a training-free framework that makes retrieval dynamic by embedding it directly in the agent’s reasoning loop. FitText generates natural-language pseudo-tool descriptions as retrieval probes, refines them iteratively using retrieval feedback, and explores diverse alternatives through stochastic generation. Memetic Retrieval adds evolutionary selection pressure over candidate descriptions, guided by a tool memory that avoids redundant search. On ToolRet (43k tools, 4 domains), FitText improves average retrieval rank from 8.81 to 2.78; on StableToolBench (16,464 APIs), it achieves a 0.73 average pass rate—a 24-point absolute gain over static query retrieval. The gains transfer across base models capable of acting as competent semantic operators; under weaker base models, Memetic’s evolutionary search inverts—amplifying noise rather than refining signal—surfacing model capacity as a prerequisite for evolutionary tool exploration. 1 Introduction Large language models (LLMs) demonstrate strong reasoning and planning capabilities ( Minaee et al. 2024 ) , yet remain limited in their ability to interact with the external world through tools and APIs. To overcome this limitation, tool-augmented LLM agents have been introduced, enabling models to invoke APIs, databases, and external environments for more complex and grounded task execution ( Qin et al. 2024a ; Qu et al. 2025 ) . A fundamental challenge in such systems lies in identifying which tools should be used for a given task, a process known as tool retrieval . Existing approaches fall into two paradigms, both with critical limitations: (i) Schema injection , which provides agents with a manually curated, fixed set of candidate tools in the prompt context ( Huang et al. 2023 ; Shen et al. 2023 ; Paranjape et al. 2023 ) causing context rot, as assumed by standard benchmarks ( Guo et al. 2024 ; Qin et al. 2024b ) . Furthermore, manual tool curation is unrealistic as tool ecosystems grow to tens of thousands of APIs ( Qin et al. 2024b ) . (ii) Static root-query retrieval , which selects tools once before execution based on the initial user query ( Qu et al. 2024b ) . However, user intent is inherently amorphous and a query alone may not fully capture information needs ( Asai et al. 2023 ) , making one-shot retrieval brittle. Both paradigms assume that all required tools can be determined upfront, yet agents often discover the need for new tools during reasoning as their understanding of the task evolves. This motivates dynamic retrieval , where tool discovery is integrated into the reasoning process, allowing the agent to decide when and what to retrieve adaptively throughout execution. Compounding the problem, prior retrieval methods overlook the substantial semantic gap between user queries and tool descriptions. Queries are high-level and goal-oriented (e.g., Figure 1 , “My flight was cancelled, help me get a refund”), while tool descriptions are functional (e.g., “Get the current status of a flight”). This gap is further widened in stochastic API environments whose available functionality cannot be anticipated at query time, and by general-purpose embedding models not trained for cross-domain matching between task intent and tool metadata. To address these challenges, we propose FitText , an LLM-guided dynamic tool retrieval framework (Figure 1 ). Instead of using the user query directly, the LLM reasons about the task and produces a pseudo-tool description , a natural-language hypothesis of the needed tool’s functionality. This description bridges the semantic gap between user intent and tool metadata, enabling retrieval in a semantically aligned space. This parallels pseudo-answer rewriting and query rewriting in RAG ( Li et al. 2024 ; Liu & Mozafari 2024 ) , where generating a hypothetical answer bridges the query–document gap; our pseudo-tool descriptions analogously bridge the query–tool gap. While sharing conceptual roots with hypothetical document generation ( Gao et al. 2022 ; Wang et al. 2023 ) and pseudo-relevance feedback ( Lavrenko & Croft 2001 ) , tool retrieval introduces distinct challenges: tools are structured with parameters and schemas, retrieved tools must be executable , and the agent’s evolving context provides a richer refinement signal than a static query. We also adapt corpus-steered query expansion ( Lei et al. 2024 ) to the tool domain. Our main contributions are summarized as follows: • We introduce FitText , a training-free framework that reframes tool retrieval as exploration over a heterogeneous tool ecology . The LLM generates pseudo-tool descriptions as retrieval probes—hypotheses about needed functionality—and refines them adaptively as the agent’s task understanding evolves. We instantiate the framework as a spectrum of strategies trading speed for thoroughness: Single-Pass, Multi-Turn Refinement, and Scattershot. • We introduce Memetic Retrieval , a multi-generation evolutionary loop over pseudo-tool descriptions with crossover, mutation, retrieval-fitness selection, and a tool memory that suppresses redundant search across generations. Memetic achieves the highest average pass rate on StableToolBench (0.73) and the best average retrieval rank on ToolRet (2.78), with the largest gains concentrated on ambiguous, multi-tool tasks (G2/G3) where deterministic retrieval is weakest. • We find empirically that retrieval, not planning, is the binding constraint on end-to-end agent performance: scaling the analysis model improves retrieval across all strategies, while scaling the planner does not. This redirects attention from planning-centric agent improvements to retrieval-side capacity. • We show that memetic search is base-model contingent : gains require an LLM capable of acting as a competent semantic operator on pseudo-tool descriptions. Under weaker base models, both diversity- and depth-generating moves collapse together—evolutionary search amplifies noise rather than refining signal, inverting AlphaEvolve’s frontier-model result and bounding when memetic strategies should be deployed. 2 Problem Statement Figure 1: Comparison between Previous Query-based Retrieval and Dynamic Retrieval. The prior query-based retrieval fails to select the correct tool due to static dependency on earlier queries, while the proposed dynamic retrieval adaptively updates the retrieval context based on intermediate tool outputs, leading to successful task completion. We frame tool retrieval as a zero-shot retrieval and decision-making problem : given a task goal derived from user query q , the agent must identify, possibly across multiple steps, the most relevant tools from \mathcal{T} without task-specific training data or hardcoded retrieval pipelines. This requires reasoning over both the query structure and the affordances of candidate tools, bridging the gap between semantic understanding of tasks and the operational use of tools in execution. Formally, the agent generates a sequence of actions a_{1},a_{2},\ldots,a_{T} where a_{t}\in\mathcal{A} . At each step t , the available actions depend on the function schema \mathcal{F}_{t}\subseteq\mathcal{T} , the subset of tools currently exposed to the agent from the full tool corpus \mathcal{T} . In long-horizon tasks, retrieval errors at early steps compound across the action sequence ( Song et al. 2026 ) , making the quality of \mathcal{F}_{t} the binding constraint on task success. Strategy trigger. The framework permits retrieval to be invoked during reasoning: at any step t , the agent may emit a retrieval request, causing the system to update the function schema \mathcal{F}_{t+1}\leftarrow\mathcal{F}_{t}\cup\mathrm{Retrieve}(a_{t},\mathcal{T}) . The trigger mechanism and its implementation are detailed in § 4.2 . Desiderata. We seek a tool retrieval framework satisfying the following properties: (i) Model-agnostic: the framework must operate with any base LLM without architecture-specific modifications; (ii) Training-free: it must not require fine-tuning the retriever or LLM, enabling deployment with API-only models; (iii) Orthogonal: the framework composes with advances in agentic planning and stronger base models without requiring co-adaptation, serving as a modular, plug-and-play capability. 3 Related Work 3.1 Tool-Augmented Large Language Models Tool-augmented LLM agents enhance reasoning through external tool invocation. Early systems connected models to specific environments such as web browsers and APIs ( Nakano et al. 2021 ; Song et al. 2023 ; Wang et al. 2024 ) , while ReAct ( Yao et al. 2022 ) established observation-action reasoning loops. Subsequent work splits into training-based methods that fine-tune on tool-call datasets ( Schick et al. 2023 ; Patil et al. 2024 ) and training-free approaches that inject tool schemas into prompts for in-context selection, as exemplified and evaluated by MetaTool ( Huang et al. 2023 ) . However, these methods assume oracle tools are provided, which is unrealistic. 3.2 Tool Retrieval for LLM Agents Tool retrieval aims to identify the top- K most relevant tools from a large repository for a given user query, serving as the foundation for effective tool use in LLM-based agents. While tool-augmented LLM research has concentrated on tool usage and calling, with planning-centric approaches such as ToolChain* ( Zhuang et al. 2023 ) improving action sequencing, the upstream retrieval bottleneck remains comparatively underexplored, with errors in tool selection propagating through inference trees ( Chen et al. 2025 ) . Recent work on dynamic tool discovery demonstrates that on-demand retrieval yields superior scalability for long-horizon tasks, even without additional training ( Li et al. 2025c ) . Early approaches adopt conventional information retrieval techniques, which can be broadly divided into term-based and semantic-based methods. Term-based models such as TF–IDF ( Sparck Jones 1972 ) and BM25 ( Robertson et al. 2009 ) rely on sparse lexical overlap between the query and tool documentation, often failing when users describe tool functionalities in natural or task-specific language. To capture deeper semantic relations, recent research shifts toward semantic retrieval inspired by RAG ( Lewis et al. 2020 ) , encoding queries and tool descriptions into a shared dense embedding space. Representative works include Tool2Vec ( Moon et al. 2024 ) , which models diverse user invocation patterns to reduce the semantic gap between user requests and API specifications. Further refinements introduce hierarchical or specialized retrieval architectures: AnyTool ( Du et al. 2024 ) and ToolRerank ( Zheng et al. 2024 ) perform coarse-to-fine selection across category-tool-API levels, while COLT ( Qu et al. 2024a ) designs completeness-oriented reranking and Re-Invoke ( Chen et al. 2024 ) applies invocation rewriting to improve precision. MCP-Zero ( Fei et al. 2025 ) preliminarily explores allowing LLMs to actively request tools, but its approach focuses on conceptual formulation with minimal refinement or experimental validation. Concurrently, ToolDreamer ( Sengupta et al. 2025 ) proposes instilling LLM reasoning into tool retrievers through training, and Xu et al. 2024 enhance retrieval with iterative LLM feedback, while our approach achieves similar goals at inference time without parameter updates. ToolGen ( Wang et al. 2025 ) explores a generative approach to unified tool retrieval and calling, contrasting with our retrieval-augmented framework that decouples tool discovery from invocation. Despite these advances, existing retrieval-based frameworks face several fundamental limitations. (1) Static retrieval: most methods retrieve tools only once, preventing adaptation as reasoning evolves (§1). (2) Task-specific or structure-dependent designs: many methods rely on additional assumptions such as hierarchical tool taxonomies, pre-collected diverse user invocation patterns, or structured API documentation, which restricts their applicability to broader, unstructured tool environments where only user query and raw tool descriptions are available. (3) Semantic gap: direct query-to-tool matching yields poor recall (§1); prior work aligns tool embeddings toward queries, while we invert this direction via pseudo-tool generation. Connection to prompt optimization. Automatic prompt optimization formulates search over discrete textual spaces ( Li et al. 2025b ) , with recent work applying LLM-driven evolutionary operators ( Agrawal et al. 2025 ) and strategic exploration–exploitation trade-offs ( Cui et al. 2025 ) . While these methods optimize instruction prompts scored by a downstream objective, our framework searches over pseudo-tool descriptions, textual artifacts whose fitness is evaluated by retrieval quality against the tool corpus rather than end-task performance. 4 Method Figure 2: Illustration of our proposed dynamic tool retrieval framework. The figure compares the workflows of Single-Pass , Multi-Turn Refinement , and Scattershot Retrieval . 4.1 Overview We frame tool retrieval as tool exploration : the API catalog constitutes a large, heterogeneous tool ecology , and the user query defines an ecological niche that the agent must fill by discovering well-adapted tools through imperfect retrieval signals. During reasoning, the agent searches this ecology by generating pseudo-tool descriptions , intermediate hypotheses about needed functionality that serve as retrieval probes (§ 4.2 ). We instantiate this framework as a progression of strategies: Single-Pass generates one hypothesis; Multi-Turn iteratively refines hypothesis using retrieval feedback; Scattershot explores diverse hypotheses in parallel via voting; and Memetic subsumes both through an evolutionary loop ( Guo et al. 2025 ) with fitness-driven selection, crossover, mutation, and local search. Each strategy addresses a specific limitation of its predecessor, forming a spectrum from fast (Single-Pass) to thorough (Memetic). 4.2 Dynamic Tool Retrieval Framework When a strategy trigger fires (§ 2 ), the system extracts one or more pseudo-tool descriptions d=\textsc{LLM}(q,\mathcal{H}) from the agent’s output a_{t} . Concretely, the output contains pseudo-tool blocks delimited by special tokens ( \texttt{\lx@text@lbrace BEGIN\lx@text@rbrace}\ldots\texttt{\lx@text@lbrace END\lx@text@rbrace} ); upon detection, the system intercepts a_{t} , extracts each block, and runs the configured retrieval strategy. Because generating a tool hypothesis requires reasoning about expected inputs and outputs, each pseudo-tool implicitly encodes a more granular task plan than explicit planning approaches such as cluster-based tool selection ( Liu et al. 2025 ) . Retrieval mechanism. Given a pseudo-tool description d and the tool corpus \mathcal{T}=\{t_{1},\ldots,t_{n}\} , we compute relevance via embedding similarity. Let \mathbf{e}(\cdot) denote a sentence embedding function (SimCSE ( Gao et al. 2021 ) , RoBERTa-large variant). We compute the relevance score as: \mathrm{score}(d,t_{i})=\cos\!\big(\mathbf{e}(d),\,\mathbf{e}(t_{i})\big), (1) and retrieve the top- k tools R=\textsc{Ret}(d,\mathcal{T},k) by descending score. Retrieved tools are injected into the function schema \mathcal{F}_{t+1}\leftarrow\mathcal{F}_{t}\cup R , enabling the agent to invoke newly discovered tools in subsequent steps. Single-Pass Retrieval. In the simplest instantiation, the initial description d_{0}=\textsc{LLM}(q,\mathcal{H}) is used directly for a single retrieval step with no further refinement. This establishes the benefit of LLM-generated pseudo-tools over raw query retrieval: even a single pseudo-tool description bridges the semantic gap by operating in a space closer to tool documentation than the original user query. However, Single-Pass provides no mechanism to correct misalignment between d_{0} and the tool database after the initial retrieval. 4.3 Multi-Turn Refinement The initial pseudo-tool description d_{0} may not align well with actual tool representations in \mathcal{T} . Drawing on the iterative self-refinement paradigm ( Madaan et al. 2023 ) , we propose a multi-turn refinement mechanism that uses retrieval feedback to progressively improve description quality. Intuition. After each retrieval step, the agent receives concrete examples of tools that actually exist in the database. These exemplars provide a grounding signal by revealing the vocabulary, structure, and granularity of real tool descriptions that the LLM can use to refine its hypothesis. Formal description. Let d^{(0)}=d_{0} be the initial pseudo-tool description. At each refinement turn t=1,\ldots,T : \displaystyle R^{(t)} \displaystyle=\textsc{Ret}\!\big(d^{(t-1)},\,\mathcal{T},\,k\big), (2) \displaystyle\mathcal{B}^{(t)} \displaystyle=\mathcal{B}^{(t-1)}\cup\big\{\mathrm{blurb}(r):r\in R^{(t)}\big\}, (3) \displaystyle d^{(t)} \displaystyle=\textsc{LLM}_{\mathrm{refine}}\!\big(d^{(t-1)},\,\mathcal{B}^{(t)},\,q\big), (4) where \mathcal{B}^{(t)} is the accumulated set of exemplar tool descriptions (deduplicated) and \mathrm{blurb}(r) extracts a normalized natural-language summary of tool r . The refinement operator \textsc{LLM}_{\mathrm{refine}} generates an updated pseudo-tool description conditioned on (i) the current description, (ii) the exemplar set, and (iii) the original query. The final retrieval uses d^{(T)} : \text{Output}=\textsc{Ret}\!\big(d^{(T)},\,\mathcal{T},\,k\big). (5) The temperature parameter \tau is set low ( \tau\leq 0.7 ) to encourage focused, incremental refinement rather than divergent exploration. While effective, Multi-Turn follows a single deterministic trajectory that may converge to a local optimum when d_{0} is poorly formulated. 4.4 Scattershot Retrieval To overcome the single-trajectory limitation of Multi-Turn, Scattershot Retrieval introduces population-level diversity by generating multiple diverse pseudo-tool descriptions and aggregating their retrieval results through voting. Intuition. A single pseudo-tool description may miss relevant tools due to the inherent ambiguity of natural-language generation. By sampling M diverse descriptions at high temperature, the framework explores a broader region of the pseudo-tool space, increasing the probability that at least one description aligns well with each required tool. Diverse generation. For each initial description d_{0} , we first perform a seed retrieval R_{0}=\textsc{Ret}(d_{0},\mathcal{T},k) and extract exemplars \mathcal{E}=\{\mathrm{blurb}(r):r\in R_{0}\} . We then generate M diverse children in parallel at elevated temperature \tau=1.5 : d_{i}\;\sim\;\textsc{LLM}_{\mathrm{scatter}}\!\big(d_{0},\,\mathcal{E};\;\tau\big),\quad i=1,\ldots,M. (6) Hierarchical voting. Each child d_{i} independently retrieves its own candidate set R_{i}=\textsc{Ret}(d_{i},\mathcal{T},k) . Results are aggregated by vote count, mean rank, and mean similarity (Algorithm 7 ), ensuring tools consistently retrieved across diverse hypotheses are prioritized. 4.5 Memetic Retrieval Figure 3: Overview of Memetic Retrieval. The framework progresses through five phases: Seed generates an initial population of pseudo-tool descriptions; Evaluate scores each via retrieval fitness; Evolution applies truncation selection with crossover and mutation; Refinement refines offspring through retrieval feedback; and Output aggregates results via hierarchical voting. The generation loop repeats for G iterations. Scattershot generates a diverse population but discards all information after a single generation. We now present Memetic Retrieval algorithm, which combines population-based exploration with iterative refinement through a multi-generation evolutionary loop. Intuition. Each pseudo-tool description acts as a mutable hypothesis, analogous to a meme in cultural evolution, whose quality is evaluated by retrieval outcomes. The algorithm maintains a population of competing hypotheses, applies selection pressure via a fitness signal, and generates new candidates through crossover and mutation . The LLM serves as a semantic evolutionary operator ( Guo et al. 2025 ; Agrawal et al. 2025 ) , performing meaning-preserving crossover and intent-aware mutation at the meaning level rather than token-level perturbation ( Novikov et al. 2025 ) . A memetic local search step refines each offspring using retrieval feedback. Fitness function. The fitness of a pseudo-tool description d_{i} with retrieval result R_{i}=\textsc{Ret}(d_{i},\mathcal{T},k) is: f(d_{i})=\underbrace{s_{\mathrm{ret}}(d_{i},R_{i})}_{\text{retrieval quality}}-\underbrace{0.5\cdot\max_{(M_{j},g_{j})\in\mathcal{M}}J(R_{i},M_{j})\cdot\mathbbm{1}\!\big[J(R_{i},M_{j})>0.3\big]}_{\text{memory penalty}}, (7) where s_{\mathrm{ret}}(d_{i},R_{i})=0.7\,\sigma_{1}(R_{i})+0.3\,\bar{\sigma}_{3}(R_{i}) combines top-1 and mean top-3 cosine similarities, J(\cdot,\cdot) is Jaccard similarity, and \mathcal{M}=\{(M_{j},g_{j})\} is the tool memory storing previously retrieved tool sets with generation indices. The retrieval score operates at the semantic level (embedding similarity), while the Jaccard penalty operates at the syntactic level (set overlap); together they discourage redundant exploration. Because API outcomes are stochastic, this memory acts as a soft taboo rather than a hard ban, recording what not to revisit ( Suzgun et al. 2025 ) . At the population level, the penalty implicitly coordinates exploration by steering candidates away from already-covered regions. Algorithm 1 Memetic Retrieval 1: \mathcal{D}_{0} , \mathcal{T} , k , \mathcal{M} , N{=}6 , G{=}3 , \theta{=}0.95 , \tau{=}1.5 , B 2: Ranked tool list; updated \mathcal{M} 3: for each ancestor a\in\mathcal{D}_{0} do 4: \mathcal{P}\leftarrow\textsc{SeedPop}(a,\mathcal{T},k,N,\tau) Alg. 6 5: for g\leftarrow 1 to G do 6: for each d_{i}\in\mathcal{P} do R_{i}\leftarrow\textsc{Ret}(d_{i},\mathcal{T},k) ; f_{i}\leftarrow f(d_{i}) Eq. 7 7: end for 8: d^{*}\leftarrow\arg\max_{i}f_{i} ; if f(d^{*})\geq\theta or g=G then break 9: \mathcal{P}_{\mathrm{sel}}\leftarrow\mathrm{top}_{\lceil N/2\rceil}(\mathcal{P},f) ; \mathcal{P}^{\prime}\leftarrow\{d^{*}\} elitism 10: while |\mathcal{P}^{\prime}|Q_{\max} then return \infty 12: end if 13: if \mathrm{ch}(n)\neq\emptyset then 14: Inject diversity prompt summarising prior children 15: end if 16: o\leftarrow\mathrm{LLM}(\mathcal{H}(n),\mathcal{F}(n)) ; Q\leftarrow Q+1 17: if o contains pseudo-tool blocks then 18: n_{\mathrm{th}}\leftarrow Thought child 19: if not duplicate in \mathcal{M} then 20: \mathit{tools}\leftarrow\textsc{SelectAndRunStrategy}(o,\mathcal{F},\mathrm{LLM},\mathcal{M}) 21: \mathcal{F}(n_{\mathrm{th}})\leftarrow\mathcal{F}(n_{\mathrm{th}})\cup\mathit{tools} 22: \mathcal{M}.\mathrm{update}(o) 23: end if 24: end if 25: for each function call (a,x)\in o do 26: n_{a}\leftarrow Action child; n_{x}\leftarrow ActionInput child 27: (\mathrm{obs},\kappa)\leftarrow\textsc{Exec}(a,x,\mathcal{F}(n)) 28: if \kappa=1 then replace a with sentinel 29: end if 30: if \kappa=3 then n_{x}.\mathrm{terminal}\leftarrow\mathrm{True} 31: end if 32: if \kappa\in\{1,2,4\} then n_{x}.\mathrm{pruned}\leftarrow\mathrm{True} 33: end if 34: end for 35: for each child c\in\mathrm{ch}(n) do 36: b\leftarrow\textsc{DFSDT}(c,D_{\max},W,Q_{\max},\mathcal{S},\mathcal{M},\mathcal{F}) 37: if |\mathcal{S}|\geq\mathcal{S}_{\max} then return \infty 38: end if 39: if b>1 then return b-1 40: end if 41: end for 42: end for 43: return 1 Mathematical formalization. Let the search tree be \mathcal{G}=(\mathcal{N},E) where each edge (n,c)\in E corresponds to one LLM generation step. (We use \mathcal{G} to avoid overloading \mathcal{T} which denotes the tool corpus.) The message history at node n along path \pi(n)=(n_{0},n_{1},\ldots,n) is: \mathcal{H}(n)=\bigl[\mathrm{sys}(q)\bigr]\circ\bigl[\mathrm{usr}(q)\bigr]\circ\bigl(a_{i},x_{i},o_{i}\bigr)_{i\in\pi(n)}, (8) where (a_{i},x_{i},o_{i}) are action/argument/observation triples. Backtracking propagates when b>1 , continuing expansion only when b\leq 1 . Dynamic retrieval triggers when: \max_{m\in\mathcal{M}}\mathrm{SequenceSim}(o,m)<0.82\;\wedge\;o\not\subset m\;\;\forall m\in\mathcal{M}. (9) B.2 Strategy Details: Scattershot, DBD, and IBI We detail the three non-evolutionary strategies below. All use the shared notation: q (query), \mathcal{T} (tool corpus), \mathbf{e}(\cdot) (sentence embedding via SimCSE-RoBERTa-large), \textsc{Ret}(d,\mathcal{T},k) (top- k retrieval by cosine similarity), \mathrm{blurb}(t) (normalized natural-language description of tool t ), and J(A,B)=|A\cap B|/|A\cup B| (Jaccard similarity). DBD (Description-by-Description). DBD maintains independent per-lineage refinement paths, each anchored to its original ancestor description. Unlike IBI, exemplars are lineage-local and the ancestor is included in every refinement prompt as an anchor. Algorithm 3 DBD — Per-Lineage Iterative Refinement 1: LLM output o , corpus \mathcal{T} , top- k , turns n_{t} 2: API key list 3: \mathcal{D}_{0}\leftarrow\textsc{ParseBlocks}(o) 4: for each ancestor a\in\mathcal{D}_{0} do 5: d\leftarrow a ; \mathcal{E}\leftarrow\emptyset 6: for t\leftarrow 1 to n_{t} do 7: (Q,R)\leftarrow\textsc{Ret}(d,\mathcal{T},k) 8: \mathcal{E}\leftarrow\mathcal{E}\cup\{\mathrm{blurb}(r):r\in R\} 9: d^{\prime}\leftarrow\textsc{ParseSingle}(\mathrm{LLM}_{\mathrm{refine}}(a,d,\mathcal{E},q)) 10: if d^{\prime}\neq\emptyset then d\leftarrow d^{\prime} 11: end if 12: end for 13: Append d to finals 14: end for 15: return \bigcup_{d\in\mathit{finals}}\textsc{Ret}(d,\mathcal{T},k).\mathrm{api\_list} For each ancestor a\in\mathcal{D}_{0} , define d_{a}^{(0)}=a and \mathcal{E}_{a}^{(0)}=\emptyset . At turn t : \displaystyle\mathcal{E}_{a}^{(t)} \displaystyle=\mathcal{E}_{a}^{(t-1)}\cup\{\mathrm{blurb}(r):r\in\textsc{Ret}(d_{a}^{(t-1)},\mathcal{T},k)\}, (10) \displaystyle d_{a}^{(t)} \displaystyle=\textsc{ParseSingle}\!\left(\mathrm{LLM}_{\mathrm{refine}}(a,d_{a}^{(t-1)},\mathcal{E}_{a}^{(t)},q)\right). (11) Final output: \mathrm{Output}=\bigcup_{a\in\mathcal{D}_{0}}\textsc{Ret}(d_{a}^{(n_{t})},\mathcal{T},k) . LLM cost per lineage: n_{t} calls; retrievals: n_{t}+1 . IBI (Iterative Bootstrapped Improvement). IBI applies a single global refinement prompt across all descriptions simultaneously. It accumulates exemplar tool blurbs across iterations and optionally uses an LLM judge to check sufficiency. Algorithm 4 IBI — Iterative Bootstrapped Improvement 1: LLM output o , corpus \mathcal{T} , top- k , turns n_{t} , sufficiency flag check 2: API key list 3: \mathcal{D}\leftarrow\textsc{ParseBlocks}(o) ; \mathcal{B}\leftarrow\emptyset 4: for t\leftarrow 1 to n_{t} do 5: for each d\in\mathcal{D} do 6: (Q,R)\leftarrow\textsc{Ret}(d,\mathcal{T},k) 7: \mathcal{B}\leftarrow\mathcal{B}\cup\{\mathrm{blurb}(r):r\in R\} 8: end for 9: if check and \mathrm{LLM}_{\mathrm{judge}}(q,\mathcal{B})=\mathrm{True} then 10: break 11: end if 12: o^{\prime}\leftarrow\mathrm{LLM}_{\mathrm{refine}}(\mathcal{D},\mathcal{B},q) 13: \mathcal{D}^{\prime}\leftarrow\textsc{ParseBlocks}(o^{\prime}) 14: if \mathcal{D}^{\prime}=\emptyset then break 15: end if 16: \mathcal{D}\leftarrow\mathcal{D}^{\prime} 17: end for 18: for each d\in\mathcal{D} do 19: Append \textsc{Ret}(d,\mathcal{T},k).\mathrm{api\_list} to keys 20: end for 21: return \mathit{keys} Let \mathcal{D}^{(0)} be the initial description set. At each turn t : \displaystyle\mathcal{B}^{(t)} \displaystyle=\mathcal{B}^{(t-1)}\cup\bigcup_{d\in\mathcal{D}^{(t-1)}}\{\mathrm{blurb}(r):r\in\textsc{Ret}(d,\mathcal{T},k)\}, (12) \displaystyle\mathcal{D}^{(t)} \displaystyle=\textsc{ParseBlocks}\!\left(\mathrm{LLM}_{\mathrm{refine}}(\mathcal{D}^{(t-1)},\mathcal{B}^{(t)},q)\right). (13) LLM cost (worst case, n_{t} turns, m descriptions): n_{t} refinement calls +n_{t} optional judge calls; retrievals: (n_{t}+1)\cdot m . Scattershot. Scattershot introduces population-level diversity by sampling multiple candidate descriptions per ancestor in parallel at high temperature, then aggregating via population-level voting. Algorithm 5 Scattershot — Parallel Diversity Sampling 1: LLM output o , corpus \mathcal{T} , top- k , fan-out size S , temperature T_{b} , budget B 2: API key list 3: \mathcal{D}_{0}\leftarrow\textsc{ParseBlocks}(o) 4: for each ancestor a\in\mathcal{D}_{0} do 5: (Q_{0},R_{0})\leftarrow\textsc{Ret}(a,\mathcal{T},k) 6: \mathcal{E}\leftarrow\{\mathrm{blurb}(r):r\in R_{0}\} 7: C\leftarrow\textsc{Parallel}\!\left[\mathrm{LLM}_{\mathrm{scatter}}(a,\mathcal{E};\;T_{b})\right]_{i=1}^{S} 8: \mathcal{P}\leftarrow\{c_{i}:c_{i}\leftarrow\textsc{ParseSingle}(C_{i}),\;c_{i}\neq\emptyset\} 9: Extend keys with \textsc{Vote}(\mathcal{P},\mathcal{T},k,B) 10: end for 11: return \mathit{keys} The following subroutines are shared between Scattershot and Memetic (Algorithm 1 ): Algorithm 6 Seed Population 1: Ancestor a , \mathcal{T} , k , N , \tau 2: Population \mathcal{P} 3: R_{0}\leftarrow\textsc{Ret}(a,\mathcal{T},k) 4: \mathcal{E}\leftarrow\{\mathrm{blurb}(r):r\in R_{0}\} 5: \mathcal{P}\leftarrow\textsc{LLM}_{\mathrm{seed}}(a,\mathcal{E},N;\;\tau) 6: return \mathcal{P} Algorithm 7 Hierarchical Voting 1: Population \mathcal{P} , \mathcal{T} , k , budget B 2: Top- B ranked tool list 3: for each d_{i}\in\mathcal{P} do 4: R_{i}\leftarrow\textsc{Ret}(d_{i},\mathcal{T},k) 5: end for 6: \mathcal{C}\leftarrow\bigcup_{i}R_{i} candidate pool 7: for each tool t\in\mathcal{C} do 8: v(t)\leftarrow|\{i:t\in R_{i}\}| vote count 9: \bar{r}(t)\leftarrow\mathrm{mean}_{i:t\in R_{i}}\mathrm{rank}_{i}(t) 10: \bar{s}(t)\leftarrow\mathrm{mean}_{i:t\in R_{i}}\mathrm{sim}_{i}(t) 11: end for 12: Sort \mathcal{C} by (v\!\downarrow,\;\bar{r}\!\uparrow,\;\bar{s}\!\downarrow) 13: return \mathrm{top}_{B}(\mathcal{C}) For each ancestor a , let \mathcal{E}_{a}=\{\mathrm{blurb}(r):r\in\textsc{Ret}(a,\mathcal{T},k)\} be seed exemplars. Draw a population of S children independently: d_{i}\sim\mathrm{LLM}_{\mathrm{scatter}}(a,\mathcal{E}_{a};\;T_{b}),\quad i=1,\ldots,S, (14) where T_{b}=1.5 is fixed. For each ancestor a , Vote is applied to \{d_{1},\ldots,d_{S}\} . Scattershot is Memetic with G{=}1 and no fitness evaluation, selection, or local search, a degenerate single-generation case that establishes the population-voting idea. LLM cost per lineage: S parallel calls; retrievals: S+1 . B.3 Hyperparameter Settings and Notation Table 8 lists key hyperparameters. Table 9 summarizes the mathematical notation. Table 8: Hyperparameter settings for all experiments. Parameter Description Value k Top- k retrieval candidates 5 \mathbf{e}(\cdot) Embedding model SimCSE-RoBERTa-large Analysis LLM Query analysis model GPT-4.1 Refinement LLM Description refinement model GPT-4.1-mini / Qwen3-30B T Multi-Turn refinement turns 3 or 5 \tau_{\mathrm{refine}} Multi-Turn temperature \leq 0.7 S Scattershot fan-out size 5 or 10 \tau_{\mathrm{scatter}} Scattershot generation temperature 1.5 N Memetic population size 6 (V1) / 8 (V2) G Memetic generations 3 \theta Memetic fitness threshold 0.95 \theta_{c} Crowding similarity threshold 0.85 \tau_{\mathrm{memetic}} Memetic base temperature 1.5 B Voting budget (top- B output) 5 Tool corpus sizes StableToolBench Total tool corpus 16,464 APIs ToolRet Total tool corpus 43k tools Table 9: Summary of mathematical notation. Symbol Definition q User query a_{t}\in\mathcal{A} Action at time step t \mathcal{A} Action space \mathcal{F}_{t}\subseteq\mathcal{T} Function schema (active tools) at step t \mathcal{T}=\{t_{1},\ldots,t_{n}\} Tool corpus d Pseudo-tool description \mathcal{D}_{0} Initial pseudo-tool descriptions (ancestors) \mathcal{H} Message history \mathbf{e}(\cdot)\to\mathbb{R}^{d} Sentence embedding function R\subseteq\mathcal{T} Retrieved tool set (top- k ) \mathcal{E} Exemplar set (tool blurbs) f(d_{i})\in\mathbb{R} Fitness function \mathcal{P} Population of descriptions \mathcal{M} Tool memory \mathcal{S} Answer set (DFSDT) \tau\in\mathbb{R}^{+} Temperature \theta\in[0,1] Fitness threshold N\in\mathbb{N} Population size G\in\mathbb{N} Number of generations B\in\mathbb{N} Retrieval budget Temperature note. A temperature of \tau=1.5 for GPT-4.1-mini is critical for memetic performance. Higher temperature promotes solution divergence in the initial population, preventing premature convergence during the exploration phase of evolutionary search. Appendix C Memetic Extensions C.1 Memetic V2 Algorithm Algorithm 8 presents the full Memetic V2 pseudocode. V2 extends V1 with an LLM-based scoring component in the fitness function, temperature annealing, tournament selection, adaptive crossover rate, and guided mutation. Below we detail each component. Fitness function f_{2} . f_{2}(d_{i})=\alpha\,s_{\mathrm{ret}}(d_{i},R_{i})+\beta\,\mathrm{LLM}_{\mathrm{score}}(q,R_{i})-\gamma\,\mathrm{mem}(d_{i})-\delta\,\mathrm{crowd}(d_{i}), (15) where default weights are (\alpha,\beta,\gamma,\delta)=(0.5,0.3,0.2,1.0) and s_{\mathrm{ret}}(d_{i},R_{i})=0.7\,\sigma_{1}(R_{i})+0.3\,\bar{\sigma}_{3}(R_{i}) , with \sigma_{1} the top-1 and \bar{\sigma}_{3} the mean top-3 cosine similarity scores from retrieval R_{i}=\textsc{Ret}(d_{i},\mathcal{T},k) . The crowding term uses \delta=1.0 (unit weight) by design, since \mathrm{crowd}\in[0,1] is already normalized to the same scale. Note that LLM-generation of a population operates at the semantic level, while Jaccard similarity operates at the syntactic level; together they provide complementary diversity signals that prevent the population from collapsing to a single mode. Temperature annealing. T_{g}=\max\!\left(T_{b}-0.4,\;\;T_{b}+0.1-0.15\,g\right), (16) with mutation receiving an additional +0.1 bonus. With T_{b}=1.5 : T_{0}=1.6 , T_{1}=1.45 , T_{2}=1.30 , T_{3}=1.15 (floor at T_{b}-0.4=1.1 ). Memory penalty with exponential decay. \mathrm{mem}(d_{i})=\max_{(M_{j},g_{j})\in\mathcal{M}}\!\left[0.5\cdot J(R_{i},M_{j})\cdot e^{-g_{j}/3}\right]. (17) Newer memories ( g_{j} small) penalize more heavily; older memories decay exponentially. Crowding penalty. \mathrm{crowd}(d_{i})=\frac{1}{N-1}\sum_{j\neq i}\mathbbm{1}\!\left[\cos(\mathbf{e}(d_{i}),\mathbf{e}(d_{j}))>\theta\right]. (18) For the edge case N=1 , define \mathrm{crowd}(d_{i})=0 . Tournament selection. \mathrm{select}()=\arg\max_{d\in S}\,f_{2}(d),\qquad S\sim\mathrm{Uniform}(\mathcal{P},3). (19) Adaptive crossover rate. p_{\mathrm{cross}}(g)=\max(0.4,\;0.6-0.1\,g). (20) Guided mutation. Let \mathcal{L}(d)=\mathrm{bottom}_{m}\{R_{d}\} be the m lowest-scoring tools retrieved by d : d_{\mathrm{child}}\leftarrow\begin{cases}\mathrm{LLM}_{\mathrm{guided}}(d_{c},\mathcal{L}(d_{a});\;T_{g}+0.1)&\text{if low-quality tools detected}\\ \mathrm{LLM}_{\mathrm{mut}}(d_{c};\;T_{g}+0.1)&\text{otherwise}\end{cases} (21) Algorithm 8 Memetic V2 1: LLM output o , corpus \mathcal{T} , top- k , memory \mathcal{M} , N{=}8 , G{=}3 , threshold \theta{=}0.95 , weights \alpha,\beta,\gamma , temperature T_{b}{=}1.5 , budget B 2: API key list; \mathcal{M} updated 3: \mathcal{D}_{0}\leftarrow\textsc{ParseBlocks}(o) 4: for each ancestor a\in\mathcal{D}_{0} do 5: (Q_{0},R_{0})\leftarrow\textsc{Ret}(a,\mathcal{T},k) ; \mathcal{E}\leftarrow\{\mathrm{blurb}(r):r\in R_{0}\} 6: \mathcal{P}\leftarrow\mathrm{LLM}_{\mathrm{seed}}(a,\mathcal{E},N;\;T_{0}) 7: for g\leftarrow 1 to G do 8: T_{g}\leftarrow temperature from Eq. 16 9: for each d_{i}\in\mathcal{P} do 10: R_{i}\leftarrow\textsc{Ret}(d_{i},\mathcal{T},k) ; f_{i}\leftarrow f_{2}(d_{i}) via Eq. 15 11: end for 12: d^{*}\leftarrow\arg\max_{i}f_{i} ; f^{*}\leftarrow\max_{i}f_{i} 13: if f^{*}\geq\theta or g=G then break 14: end if 15: \mathcal{P}_{\mathrm{sel}}\leftarrow\emptyset 16: while |\mathcal{P}_{\mathrm{sel}}|<\lceil N/2\rceil do 17: S\leftarrow\mathrm{sample}(\mathcal{P},3) ; \mathcal{P}_{\mathrm{sel}}\leftarrow\mathcal{P}_{\mathrm{sel}}\cup\{\arg\max_{d\in S}f_{2}(d)\} 18: end while 19: \mathcal{P}^{\prime}\leftarrow\{d^{*}\} 20: while |\mathcal{P}^{\prime}|