feat(routing): add grob_autotune MCP tool for offline classifier calibration (T-P5b)#272
Merged
Destynova2 merged 1 commit intomainfrom Apr 25, 2026
Merged
feat(routing): add grob_autotune MCP tool for offline classifier calibration (T-P5b)#272Destynova2 merged 1 commit intomainfrom
Destynova2 merged 1 commit intomainfrom
Conversation
…bration (T-P5b) Closes the Phase P routing-intelligence work. Pairs with the ConfigSection::Classifier work (T-P5a, #268) by exposing a higher-level MCP surface dedicated to classifier tuning. Two actions: - action=suggest — returns the seven classifier weights/thresholds (5 weights + 2 tier thresholds) as TuneSuggestion entries. The MVP reports the current values with proposed == current; future revisions will infer patches from observed traffic. Operators can still iterate manually using the rationale field as a placeholder. - action=apply — accepts a list of {key, value} patches and persists them via the existing config_guard::persist_and_reload pipeline. This is sugar over batching multiple grob_configure calls into one MCP round-trip; the same deny-list (api_key, providers, dlp) and whitelist (weights.*, thresholds.*) apply. Files: - src/routing/classify/autotune.rs — new module with TuneSuggestion, AutotunePatch, current_snapshot() + 4 unit tests. - src/routing/classify/mod.rs — registers the autotune module. - src/server/mcp_handlers.rs — handle_autotune handler, dispatch registration, tool description in tools/list. The implementation is intentionally minimal: it ships the surface without speculating on the inference strategy. See docs/how-to/auto-tune-routing.md for the manual tuning workflow.
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.
Summary
Closes the Phase P routing-intelligence work. Pairs with #268 (T-P5a) by exposing a higher-level MCP surface dedicated to classifier tuning.
Two actions
`action=suggest` — returns the seven classifier weights/thresholds (5 weights + 2 tier thresholds) as `TuneSuggestion` entries:
```json
{
"action": "suggest",
"suggestions": [
{ "key": "weights.tools", "current": 1.0, "proposed": 1.0,
"rationale": "current value; manual tuning recommended (see auto-tune-routing.md)" },
...
]
}
```
The MVP reports `proposed == current`; future revisions will infer patches from observed traffic. Operators can iterate manually using the rationale field as a placeholder.
`action=apply` — accepts a list of `{key, value}` patches and persists them via the existing `config_guard::persist_and_reload` pipeline:
```json
{
"action": "apply",
"patches": [
{ "key": "weights.tools", "value": 5.0 },
{ "key": "thresholds.complex_threshold", "value": 6.0 }
]
}
```
This is sugar over batching multiple `grob_configure` calls into one MCP round-trip; the same deny-list (`api_key`, `providers`, `dlp`) and whitelist (`weights.`, `thresholds.`) apply.
Files changed
Test plan
Note on scope
The implementation intentionally ships the surface without speculating on the inference strategy. The `proposed` field is wired and forward-compatible with future inference logic. See `docs/how-to/auto-tune-routing.md` for the manual tuning workflow.