Implement full fallback_models support across all integration points: 1. Model Resolution Pipeline (src/shared/model-resolution-pipeline.ts) - Add userFallbackModels to ModelResolutionRequest - Process user fallback_models before hardcoded fallback chain - Support both connected provider and availability checking modes 2. Agent Utils (src/agents/utils.ts) - Update applyModelResolution to accept userFallbackModels - Inject fallback_models for all builtin agents (sisyphus, oracle, etc.) - Support both single string and array formats 3. Model Resolver (src/shared/model-resolver.ts) - Add userFallbackModels to ExtendedModelResolutionInput type - Pass through to resolveModelPipeline 4. Delegate Task Executor (src/tools/delegate-task/executor.ts) - Extract category fallback_models configuration - Pass to model resolution pipeline - Register session category for runtime-fallback hook 5. Session Category Registry (src/shared/session-category-registry.ts) - New module: maps sessionID -> category - Used by runtime-fallback to lookup category fallback_models - Auto-cleanup support 6. Runtime Fallback Hook (src/hooks/runtime-fallback/index.ts) - Check SessionCategoryRegistry first for category fallback_models - Fallback to agent-level configuration - Import and use SessionCategoryRegistry Test Results: - runtime-fallback: 24/24 tests passing - model-resolver: 46/46 tests passing Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
/**
|
|
* Session Category Registry
|
|
*
|
|
* Maintains a mapping of session IDs to their assigned categories.
|
|
* Used by runtime-fallback hook to lookup category-specific fallback_models.
|
|
*/
|
|
|
|
// Map of sessionID -> category name
|
|
const sessionCategoryMap = new Map<string, string>()
|
|
|
|
export const SessionCategoryRegistry = {
|
|
/**
|
|
* Register a session with its category
|
|
*/
|
|
register: (sessionID: string, category: string): void => {
|
|
sessionCategoryMap.set(sessionID, category)
|
|
},
|
|
|
|
/**
|
|
* Get the category for a session
|
|
*/
|
|
get: (sessionID: string): string | undefined => {
|
|
return sessionCategoryMap.get(sessionID)
|
|
},
|
|
|
|
/**
|
|
* Remove a session from the registry (cleanup)
|
|
*/
|
|
remove: (sessionID: string): void => {
|
|
sessionCategoryMap.delete(sessionID)
|
|
},
|
|
|
|
/**
|
|
* Check if a session is registered
|
|
*/
|
|
has: (sessionID: string): boolean => {
|
|
return sessionCategoryMap.has(sessionID)
|
|
},
|
|
|
|
/**
|
|
* Get the size of the registry (for debugging)
|
|
*/
|
|
size: (): number => {
|
|
return sessionCategoryMap.size
|
|
},
|
|
|
|
/**
|
|
* Clear all entries (use with caution, mainly for testing)
|
|
*/
|
|
clear: (): void => {
|
|
sessionCategoryMap.clear()
|
|
},
|
|
}
|