fix: remove hardcoded model defaults from categories and agents

BREAKING CHANGE: Model resolution overhauled

- Created centralized model-resolver.ts with priority chain:
  userModel → inheritedModel → systemDefaultModel
- Removed model field from all 7 DEFAULT_CATEGORIES entries
- Removed DEFAULT_MODEL constants from 10 agents
- Removed singleton agent exports (use factories instead)
- Made CategoryConfigSchema.model optional
- CLI no longer generates model overrides
- Empty strings treated as unset (uses fallback)

Users must now:
1. Use factory functions (createOracleAgent, etc.) instead of singletons
2. Provide model explicitly or use systemDefaultModel
3. Configure category models explicitly if needed

Fixes model fallback bug where hardcoded defaults overrode
user's OpenCode configured model.
This commit is contained in:
Kenny
2026-01-17 12:51:03 -05:00
parent be1af6d980
commit 76508cfc7d
31 changed files with 459 additions and 496 deletions
+35
View File
@@ -0,0 +1,35 @@
/**
* Input for model resolution.
* All model strings are optional except systemDefault which is the terminal fallback.
*/
export type ModelResolutionInput = {
/** Model from user category config */
userModel?: string;
/** Model inherited from parent task/session */
inheritedModel?: string;
/** System default model from OpenCode config - always required */
systemDefault: string;
};
/**
* Normalizes a model string.
* Trims whitespace and treats empty/whitespace-only as undefined.
*/
function normalizeModel(model?: string): string | undefined {
const trimmed = model?.trim();
return trimmed || undefined;
}
/**
* Resolves the effective model using priority chain:
* userModel → inheritedModel → systemDefault
*
* Empty strings and whitespace-only strings are treated as unset.
*/
export function resolveModel(input: ModelResolutionInput): string {
return (
normalizeModel(input.userModel) ??
normalizeModel(input.inheritedModel) ??
input.systemDefault
);
}