Optimal Skill Selection for LLM Agents with Provable Bicriteria Guarantees
A method that picks which 'skill documents' to feed an AI coding agent, with mathematically guaranteed near-optimal results
Coding agents like Codex or Claude Code load reusable 'skill documents' into their limited context window to gain task-specific abilities, but current systems just score each skill independently and pack in the top matches, letting redundant skills waste tokens or even hurt performance. The researchers modeled skill selection as an optimization problem that balances covering needed capabilities against context cost under a token budget, and built a polynomial-time algorithm called Best Prefix Selection (BPS) with the first proven performance guarantee for this task. On a contamination-controlled coding benchmark, BPS reached 0.73 measured task success, beating existing skill routers, text retrievers, and the agent's own selection (0.20-0.52), while using 28% fewer tokens than the strongest existing router.
METAL MEDIA explanatory visual
A method that picks which 'skill documents' to feed an AI coding agent, with mathematically guaranteed near-optimal results
- 01Coding agents choose skill documents from a library to load into an LLM's limited context window, but current methods score skills independently and use top-k or greedy packing with no guarantee of quality or cost control
- 02The researchers built a structured objective: each skill supplies latent 'capabilities,' each query demands certain capabilities, overlapping supply of the same capability gives diminishing returns, while covering different capabilities complements each other -- and this benefit is offset by a token-length penalty
- 03They designed BPS, an algorithm that enumerates small seed sets, greedily grows each into a chain by adding the item with best benefit-per-token, records every intermediate combination along the way, and picks the best one overall
- 04They proved a bicriteria approximation guarantee in polynomial time: the algorithm captures at least (1-1/e) of the achievable benefit while paying no more than the full token penalty (a coefficient of 1) -- the best possible benefit ratio achievable in polynomial time
- 05Trained only on pass/fail execution outcomes, the fitted model correctly recovered the hidden skill-capability mapping (99.6% accuracy), and on a contamination-controlled BigCodeBench variant, BPS achieved 0.73 success versus 0.20-0.52 for existing baselines
What they did
- Coding agents choose skill documents from a library to load into an LLM's limited context window, but current methods score skills independently and use top-k or greedy packing with no guarantee of quality or cost control
- The researchers built a structured objective: each skill supplies latent 'capabilities,' each query demands certain capabilities, overlapping supply of the same capability gives diminishing returns, while covering different capabilities complements each other -- and this benefit is offset by a token-length penalty
- They designed BPS, an algorithm that enumerates small seed sets, greedily grows each into a chain by adding the item with best benefit-per-token, records every intermediate combination along the way, and picks the best one overall
- They proved a bicriteria approximation guarantee in polynomial time: the algorithm captures at least (1-1/e) of the achievable benefit while paying no more than the full token penalty (a coefficient of 1) -- the best possible benefit ratio achievable in polynomial time
- Trained only on pass/fail execution outcomes, the fitted model correctly recovered the hidden skill-capability mapping (99.6% accuracy), and on a contamination-controlled BigCodeBench variant, BPS achieved 0.73 success versus 0.20-0.52 for existing baselines

| tj | ∈argmaxi∈T∖{t1,⋯,tj−1}G^(i∣{t1,⋯,tj−1}), | (13) | ||
|---|---|---|---|---|
| mj | :=G^(tj∣{t1,⋯,tj−1}),∀j∈[|T|]. |

Why it matters
As skill/tool libraries for AI agents keep growing, choosing which items to load into limited context has become a first-order bottleneck for both accuracy and cost, and this work is the first to explain why naive top-k relevance scoring fails and to offer a selection algorithm with a provable guarantee. Anyone building agent frameworks can use this principle to cut wasted context while boosting task success.
Terms in this paper
- skill document · a reusable instruction file that teaches an LLM agent how to perform a specific task
- context window · the maximum amount of text (tokens) an LLM can process at once
- submodular function · a function where adding a new item gives diminishing extra benefit as more similar items are already selected
- bicriteria approximation · a guarantee that bounds two different objectives (here, benefit and cost) with separate approximation ratios
- knapsack constraint · a limit requiring choices to fit within a fixed budget, like packing a bag with a weight limit
Original abstract (English)
Loading reusable skill documents into a bounded context window is now the primary way large language model (LLM) agents acquire task-specific capabilities, which makes skill selection a first-order determinant of task performance and token cost. Yet current agents score skills independently by semantic relevance and assemble the set by top-$k$ or greedy packing, with no quality guarantee or cost awareness on the selected set. As a result, redundant or poorly chosen skills waste scarce context tokens and can even degrade performance. We give the first model of how the selected skill set shapes execution outcomes and cast skill selection as an optimization problem: choose a skill set under a hard token budget to maximize a monotone submodular benefit minus context penalty. For this problem, we develop Best Prefix Selection (BPS), a polynomial-time algorithm, and prove, to our knowledge, the first performance guarantee for skill selection: a bicriteria $(1-1/e,1)$ approximation whose benefit coefficient is optimal in polynomial time. On a contamination-controlled BigCodeBench variant, BPS outperforms all the baselines, reaching $0.73$ measured task success versus $0.20$--$0.52$ for released skill routers, text retrievers, and the executor's own selection, on $28\%$ fewer tokens than the strongest released router.
Read on arXivLatest papers
- SWE-bench Science: Can Coding Agents Resolve Engineering Tasks in Science?AI coding agents were tested on fixing real scientific software, and even the best one failed more than half the time
- FlashPrefill V2: Block-Sparse Prefill Attention for Long-Context LLM ServingMaking sparse attention fast enough and accurate enough for real LLM serving, not just papers
- PolicyGuide: From Guarding One Action to Guiding the Whole Workflow for Policy-Compliant LLM AgentsMaking customer-service AI agents follow the whole procedure, not just avoid one bad action
- EXIMO: VLM Guided Exploration of VLA PoliciesTeaching a robot new chores without human teleoperation, by letting a chatty AI supervise it
- EnvHarness: Awakening Static Worlds for Agent LearningInstead of building new training worlds from scratch, this work adds a plug-in layer that reshapes existing ones around each agent's actual weaknesses
- Bounded Sovereignty and the Control Tax: Pricing AI Oversight When the Deployer Does Not Own the ModelCompanies that rent AI instead of owning it can only do half of AI safety oversight
- Beyond Imitation: Filtering On-Policy Distillation by Reasoning ProgressA fix for AI models that get penalized by their teacher even when they're reasoning correctly
- PersonalBench: Measuring the Authorship Gap in LLM PersonalizationAI can be prompted to write 'like someone,' but its own voice never fully disappears
Latest from METAL MEDIA
Figures: Yu Chen et al., arXiv:2608.19993, cc-by-nc-sa-4.0