Skip to content

feat(routing): add grob_autotune MCP tool for offline classifier calibration (T-P5b)#272

Merged
Destynova2 merged 1 commit intomainfrom
feat/grob-autotune
Apr 25, 2026
Merged

feat(routing): add grob_autotune MCP tool for offline classifier calibration (T-P5b)#272
Destynova2 merged 1 commit intomainfrom
feat/grob-autotune

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

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

  • `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`; existing `test_inject_builtin_tools_*` tests updated for the new tool count.

Test plan

  • `cargo check --lib` clean
  • `cargo clippy --lib --tests -- -D warnings` clean
  • `cargo test routing::classify::autotune` — 4 passed
  • `cargo test server::mcp_handlers::tests::test_inject` — 3 passed
  • All prek pre-commit + pre-push hooks green
  • CI green (auto-merge enabled below)

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.

…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.
@Destynova2 Destynova2 enabled auto-merge April 25, 2026 18:39
@Destynova2 Destynova2 merged commit 6e2a099 into main Apr 25, 2026
42 checks passed
@Destynova2 Destynova2 deleted the feat/grob-autotune branch April 25, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant