feat: add runVariantExperiment for AI-driven tool variant optimization#213
Merged
Conversation
Promotes the runtime tool-override experiment loop from a documented userland pattern to a first-class API. runVariantExperiment establishes a baseline, injects each candidate variant via toolOverrides, compares against the original baseline, ranks by a chosen metric, disqualifies regressing candidates by default, and emits a structured apply/reject/ inconclusive proposal. A proposeVariants callback supports iterative agent-driven rounds with convergence control. Includes the optimize-mcp-tool-metadata skill for agent-driven workflows, docs, and runnable snippets for both the high-level API and the manual low-level loop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
aditya-scio
reviewed
Jun 15, 2026
There was a problem hiding this comment.
This is a nice API lift. Pulling the baseline → variant → compare loop into runVariantExperiment makes the experimentation model much more usable for agents and for humans, while still keeping the important invariant that the dataset/server source are not mutated. The default regression guard is also the right default, otherwise it’s too easy to optimize into local wins that make the overall tool worse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code changes:
runVariantExperimentAPI to run multi-round, metric-driven MCP tool-metadata experiments (baseline + variants viatoolOverrides, comparison, ranking, regression-guarding, and structured apply/reject/inconclusive proposals), exposes its types from the public surface, documents the high-level vs manual loops with runnable snippets, and adds anoptimize-mcp-tool-metadataskill to let agents iteratively propose and evaluate tool-description/schema variants without mutating datasets or server source.