feat(core): Wire up chat code path for model configs. (#12850)

This commit is contained in:
joshualitt
2025-11-19 20:41:16 -08:00
committed by GitHub
parent 43d6dc3668
commit 257cd07a3a
19 changed files with 485 additions and 347 deletions
@@ -231,4 +231,42 @@ describe('ModelConfigService Integration', () => {
topP: 0.95, // from base
});
});
it('should correctly merge static aliases, runtime aliases, and overrides', () => {
// Re-instantiate service for this isolated test to not pollute other tests
const service = new ModelConfigService(complexConfig);
// Register a runtime alias, simulating what AgentExecutor does.
// This alias extends a static base and provides its own settings.
service.registerRuntimeModelConfig('agent-runtime:my-agent', {
extends: 'creative-writer', // extends a multi-level alias
modelConfig: {
generateContentConfig: {
temperature: 0.1, // Overrides parent
maxOutputTokens: 8192, // Adds a new property
},
},
});
// Resolve the configuration for the runtime alias, with a matching agent scope
const resolved = service.getResolvedConfig({
model: 'agent-runtime:my-agent',
overrideScope: 'core',
});
// Assert the final merged configuration.
expect(resolved.model).toBe('gemini-1.5-pro-latest'); // from 'default-text-model'
expect(resolved.generateContentConfig).toEqual({
// from 'core' agent override, wins over runtime alias's 0.1 and creative-writer's 0.9
temperature: 0.5,
// from 'base' alias
topP: 0.95,
// from 'creative-writer' alias
topK: 50,
// from runtime alias
maxOutputTokens: 8192,
// from 'core' agent override
stopSequences: ['AGENT_STOP'],
});
});
});