Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: remove obsolete automatic-model downgrade checks after explicit selection
[._.]/ Adam Eivyf028222b7ce0
diff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.jsindex 2c890e5695..d65c875e67 100644--- a/server/services/agentProviderResolution.js+++ b/server/services/agentProviderResolution.js@@ -92,38 +92,6 @@ export async function resolveAgentProviderAndModel(task) {return resolveOrdinaryProviderAndModel(task);}-/**- * Flags `modelSelection` when the learning system substituted a weaker tier- * than the provider's configured default for a task that never pinned one —- * shared by the ordinary and public-review resolution paths (#8148).- *- * Only a literal `medium`/`light` `tierToModel` pick counts as "weaker":- * `selectModelForTask`'s learning branches can also land on `heavy`/`high`/- * `xhigh` (a stronger tier proven out by history), which must NOT be flagged- * merely because its model id differs from `provider.defaultModel` — that- * would mislabel a legitimate upgrade as a downgrade.- *- * `selectedModel === modelSelection.model` guards against a DOWNSTREAM- * override (a fallback-provider model pin, or the invalid-model-list- * fallback in the ordinary path) silently inheriting this flag: those- * substitutions happen for reasons unrelated to learning, after- * `modelSelection` was already decided, and must not be reported as if the- * learning system chose them.- */-function flagLearningDowngrade(modelSelection, selectedModel, provider) {- const isWeakerLearningTier = modelSelection.tier === 'medium' || modelSelection.tier === 'light';- const downgradedFromDefault = !!modelSelection.isLearningTierOverride- && isWeakerLearningTier- && !!provider.defaultModel- && selectedModel === modelSelection.model- && selectedModel !== provider.defaultModel;- if (downgradedFromDefault) {- modelSelection.downgradedFromDefault = true;- modelSelection.configuredDefault = provider.defaultModel;- }- return downgradedFromDefault;-}-/*** Provider + model for a public-review stage. A stage's own provider/model/* effort pins (`metadata.provider` / `metadata.model`, set by the pipeline@@ -172,15 +140,10 @@ async function resolvePublicReviewAgentProvider(task, posture) {const selectedModel = honorPin? pinnedModel: (modelSelection.model || provider.defaultModel || null);- const downgradedFromDefault = flagLearningDowngrade(modelSelection, selectedModel, provider);- const logMessage = `Public-review stage (${posture}) resolved to provider ${provider.id}${selectedModel ? ` model ${selectedModel}` : ''}`;- emitLog(downgradedFromDefault ? 'warn' : 'info', downgradedFromDefault- ? `${logMessage} — differs from provider's configured default "${provider.defaultModel}" (learning system substituted this model)`- : logMessage, {+ emitLog('info', `Public-review stage (${posture}) resolved to provider ${provider.id}${selectedModel ? ` model ${selectedModel}` : ''}`, {taskId: task.id,providerId: provider.id,model: selectedModel,- ...(downgradedFromDefault && { downgradedFromDefault: true, configuredDefault: provider.defaultModel })});return { ok: true, provider, selectedModel, modelSelection };}@@ -408,30 +371,11 @@ async function resolveOrdinaryProviderAndModel(task) {}}- // The learning-based tiers can pick a weaker model than the provider's- // configured default without the task ever asking for that — surface it- // loudly rather than let "ran on the configured default" and "the learning- // system downgraded it" collapse into the same quiet info log (#8148). The- // fallback-model-pin and invalid-model-list branches above can still change- // `selectedModel` after `modelSelection` was decided, which is exactly what- // `flagLearningDowngrade`'s `selectedModel === modelSelection.model` guard- // excludes.- const downgradedFromDefault = flagLearningDowngrade(modelSelection, selectedModel, provider);-- const logMessage = modelSelection.learningReason- ? `Model selection: ${selectedModel} (${modelSelection.reason} - ${modelSelection.learningReason})`- : `Model selection: ${selectedModel} (${modelSelection.reason})`;- const logLevel = downgradedFromDefault ? 'warn' : 'info';- const logText = downgradedFromDefault- ? `${logMessage} — differs from provider's configured default "${provider.defaultModel}" (learning system substituted this model)`- : logMessage;- emitLog(logLevel, logText, {+ emitLog('info', `Model selection: ${selectedModel} (${modelSelection.reason})`, {taskId: task.id,model: selectedModel,tier: modelSelection.tier,reason: modelSelection.reason,- ...(modelSelection.learningReason && { learningReason: modelSelection.learningReason }),- ...(downgradedFromDefault && { downgradedFromDefault: true, configuredDefault: provider.defaultModel })});return { ok: true, provider, selectedModel, modelSelection };diff --git a/server/services/agentProviderResolution.test.js b/server/services/agentProviderResolution.test.jsindex ce52da6040..444dbebec8 100644--- a/server/services/agentProviderResolution.test.js+++ b/server/services/agentProviderResolution.test.js@@ -73,78 +73,16 @@ describe('resolveAgentProviderAndModel', () => {expect(r.modelSelection.tier).toBe('medium');});- it('flags a learning-tier override that differs from the provider default and warns loudly (#8148)', async () => {- const provider = { id: 'p1', type: 'cli', defaultModel: 'claude-opus-5-5', models: ['claude-opus-5-5', 'claude-sonnet-5'] };+ it('resolves configured defaults and explicit tiers through the real selector without learning warnings', async () => {+ const actual = await vi.importActual('./agentModelSelection.js');+ selectModelForTask.mockImplementation(actual.selectModelForTask);+ selectModelForRole.mockImplementation(actual.selectModelForRole);+ const provider = { id: 'p1', type: 'cli', defaultModel: 'model-default', lightModel: 'model-light', models: ['model-default', 'model-light'] };getActiveProvider.mockResolvedValue(provider);- selectModelForTask.mockResolvedValue({ model: 'claude-sonnet-5', tier: 'medium', reason: 'learning-suggested', isLearningTierOverride: true, learningReason: '80% success on medium' });- const r = await resolveAgentProviderAndModel(TASK);- expect(r.ok).toBe(true);- expect(r.selectedModel).toBe('claude-sonnet-5');- expect(r.modelSelection.downgradedFromDefault).toBe(true);- expect(r.modelSelection.configuredDefault).toBe('claude-opus-5-5');- expect(emitLog).toHaveBeenCalledWith('warn', expect.stringContaining('differs from provider\'s configured default'), expect.objectContaining({- downgradedFromDefault: true,- configuredDefault: 'claude-opus-5-5',- }));- });-- it('does not flag a learning-tier override that already matches the provider default', async () => {- const provider = { id: 'p1', type: 'cli', defaultModel: 'claude-opus-5-5', models: ['claude-opus-5-5'] };- getActiveProvider.mockResolvedValue(provider);- selectModelForTask.mockResolvedValue({ model: 'claude-opus-5-5', tier: 'default', reason: 'learning-suggested', isLearningTierOverride: true });-- const r = await resolveAgentProviderAndModel(TASK);- expect(r.modelSelection.downgradedFromDefault).toBeUndefined();- expect(emitLog).toHaveBeenCalledWith('info', expect.any(String), expect.not.objectContaining({ downgradedFromDefault: true }));- });-- it('never flags a differing model unless the selection itself marked it a learning-tier override', async () => {- // A model differing from the default for a reason OTHER than the learning- // system (e.g. a heuristic "complex-task" heavy-tier pick, or a provider- // swap) must never be mislabeled as a silent downgrade — this pins that- // the resolver trusts `isLearningTierOverride`, not just "model !== default".- const provider = { id: 'p1', type: 'cli', defaultModel: 'claude-opus-5-5', models: ['claude-opus-5-5', 'claude-heavy-5'] };- getActiveProvider.mockResolvedValue(provider);- selectModelForTask.mockResolvedValue({ model: 'claude-heavy-5', tier: 'heavy', reason: 'complex-task' });-- const r = await resolveAgentProviderAndModel(TASK);- expect(r.modelSelection.downgradedFromDefault).toBeUndefined();- expect(emitLog).toHaveBeenCalledWith('info', expect.any(String), expect.not.objectContaining({ downgradedFromDefault: true }));- });-- it('never flags a learning-tier override that picked a STRONGER model than the default (codex #8148 review)', async () => {- // provider.defaultModel is a light/medium tier here; the learning system- // proved out the heavy tier for this task type — a legitimate upgrade,- // not a downgrade, even though the model id obviously differs from- // provider.defaultModel.- const provider = { id: 'p1', type: 'cli', defaultModel: 'claude-sonnet-5', heavyModel: 'claude-opus-5-5', models: ['claude-sonnet-5', 'claude-opus-5-5'] };- getActiveProvider.mockResolvedValue(provider);- selectModelForTask.mockResolvedValue({ model: 'claude-opus-5-5', tier: 'heavy', reason: 'learning-suggested', isLearningTierOverride: true, learningReason: 'proven high success at heavy' });-- const r = await resolveAgentProviderAndModel(TASK);- expect(r.selectedModel).toBe('claude-opus-5-5');- expect(r.modelSelection.downgradedFromDefault).toBeUndefined();- expect(emitLog).toHaveBeenCalledWith('info', expect.any(String), expect.not.objectContaining({ downgradedFromDefault: true }));- });-- it('never flags a downgrade when a downstream fallback-model pin replaced the learning selection (codex #8148 review)', async () => {- // selectModelForTask picks a weaker learning tier, but the provider is- // unavailable and its configured "Fallback Model" pin (a user choice on- // the FALLBACK provider) overrides selectedModel afterward — that- // substitution is unrelated to learning and must not inherit the flag.- const provider = { id: 'fallback-p', type: 'cli', defaultModel: 'claude-opus-5-5', models: ['claude-opus-5-5', 'claude-sonnet-5', 'pinned-fallback-model'] };- getActiveProvider.mockResolvedValue({ id: 'primary-p', type: 'cli' });- isProviderAvailable.mockReturnValue(false);- getProviderStatus.mockReturnValue({ message: 'down', reason: 'down' });- getAllProviders.mockResolvedValue({ providers: [{ id: 'primary-p', type: 'cli' }, provider] });- getFallbackProvider.mockResolvedValue({ provider, source: 'provider-fallback', model: 'pinned-fallback-model' });- selectModelForTask.mockResolvedValue({ model: 'claude-sonnet-5', tier: 'medium', reason: 'learning-suggested', isLearningTierOverride: true });-- const r = await resolveAgentProviderAndModel(TASK);- expect(r.selectedModel).toBe('pinned-fallback-model');- expect(r.modelSelection.downgradedFromDefault).toBeUndefined();- expect(emitLog).toHaveBeenCalledWith('info', expect.stringContaining('pinned-fallback-model'), expect.not.objectContaining({ downgradedFromDefault: true }));+ expect(await resolveAgentProviderAndModel(TASK)).toMatchObject({ selectedModel: 'model-default', modelSelection: { reason: 'provider-default' } });+ expect(await resolveAgentProviderAndModel({ ...TASK, metadata: { model: 'light' } })).toMatchObject({ selectedModel: 'model-light', modelSelection: { reason: 'user-preference' } });+ expect(emitLog).not.toHaveBeenCalledWith('warn', expect.anything(), expect.anything());});it('fails with providerId + status when unavailable and no fallback exists', async () => {@@ -613,23 +551,14 @@ describe('resolveAgentProviderAndModel — public-review stages', () => {expect(r.error).toMatch(/no-tool/);});- it('also flags a learning-tier downgrade on the public-review stage path (codex #8148 review)', async () => {- // resolvePublicReviewAgentProvider is a separate resolution function from- // the ordinary ("ARCHITECT role") path — it must share the same downgrade- // detection rather than silently omitting it for unpinned review runs.- const REVIEW_PROVIDER = { id: 'grok-cli', type: 'cli', command: 'grok', defaultModel: 'grok-heavy', models: ['grok-heavy', 'grok-light'] };- getAllProviders.mockResolvedValue({ providers: [REVIEW_PROVIDER], activeProvider: null });- selectModelForTask.mockResolvedValue({ model: 'grok-light', tier: 'medium', reason: 'learning-suggested', isLearningTierOverride: true });+ it('resolves an unpinned public-review stage on the configured default through the real selector', async () => {+ const actual = await vi.importActual('./agentModelSelection.js');+ selectModelForTask.mockImplementation(actual.selectModelForTask);+ const provider = { id: 'grok-cli', type: 'cli', command: 'grok', defaultModel: 'model-default', models: ['model-default'] };+ getAllProviders.mockResolvedValue({ providers: [provider], activeProvider: null });- const r = await resolveAgentProviderAndModel(gateTask());- expect(r.ok).toBe(true);- expect(r.selectedModel).toBe('grok-light');- expect(r.modelSelection.downgradedFromDefault).toBe(true);- expect(r.modelSelection.configuredDefault).toBe('grok-heavy');- expect(emitLog).toHaveBeenCalledWith('warn', expect.stringContaining('differs from provider\'s configured default'), expect.objectContaining({- downgradedFromDefault: true,- configuredDefault: 'grok-heavy',- }));+ expect(await resolveAgentProviderAndModel(gateTask())).toMatchObject({ ok: true, selectedModel: 'model-default', modelSelection: { reason: 'provider-default' } });+ expect(emitLog).not.toHaveBeenCalledWith('warn', expect.anything(), expect.anything());});it('requires a maintained actions recipe for binary providers and rejects API spawns', async () => {