feat(config): add ModelPresetConfig and runtime preset switching#3714
Draft
chengyongru wants to merge 1 commit into
Draft
feat(config): add ModelPresetConfig and runtime preset switching#3714chengyongru wants to merge 1 commit into
chengyongru wants to merge 1 commit into
Conversation
cbd5289 to
8b44b37
Compare
This was referenced May 10, 2026
602f8e4 to
74e0c3f
Compare
74e0c3f to
bd7723c
Compare
- Add `ModelPresetConfig` schema for named model presets - Add `model_presets` dict to `Config` and `model_preset` field to `AgentDefaults` - Add `resolve_preset()` to return effective model params from preset or defaults - Add `@model_validator` to reject unknown preset names - Update `_match_provider()` to use resolved preset model/provider - Update `make_provider()` and `provider_signature()` to use `resolve_preset()` - Add `model_preset` property to `AgentLoop` for atomic runtime switching - Update `AgentLoop.from_config()` to inject a runtime `default` preset - Wire self-tool to inspect/clear preset state - Update CLI display strings to show active preset
bd7723c to
2e84a9c
Compare
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
This PR introduces named model presets and atomic runtime switching, building on the
AgentLoop.from_config()refactor from PR #3708.Changes
Schema (
nanobot/config/schema.py):ModelPresetConfig— a named bundle ofmodel,provider,max_tokens,context_window_tokens,temperature, andreasoning_effort.model_presetsdict to rootConfig.model_presetfield toAgentDefaults.resolve_preset()to return effective params from either the active preset or individual defaults.@model_validatorto reject unknown preset names at load time._match_provider()to use resolved preset model / provider.Provider factory (
nanobot/providers/factory.py):make_provider()andprovider_signature()to useconfig.resolve_preset().Agent loop (
nanobot/agent/loop.py):model_presetsandmodel_presetparameters toAgentLoop.model_presetproperty with getter / setter for atomic switching.from_config()to inject a runtimedefaultpreset (built from config defaults) so users can always switch back.Self tool (
nanobot/agent/tools/self.py):model_presetincheckoutput._active_presetwhenmodelis set directly.ValueError/KeyErrorfrom property setters.CLI (
nanobot/cli/commands.py):serve,agent, andstatus.Tests
tests/config/test_model_presets.py— schema validation, preset resolution, provider matchingtests/agent/test_self_model_preset.py— runtime switching, self-tool integration, default preset injectionRollback
Revert this commit to remove preset schema fields and restore direct
defaults.modelusage infrom_config().