Skip to content

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

address review (codex): use the fallback provider's own model when the Brain default is missing

[._.]/ Adam Eivyf24e39f88515
diff --git a/server/services/memorySummarizer.js b/server/services/memorySummarizer.js
index 7646193d91..05aba4db76 100644
--- a/server/services/memorySummarizer.js
+++ b/server/services/memorySummarizer.js
@@ -47,11 +47,21 @@ const clamp = (s, n) => (s.length > n ? s.slice(0, n) : s);
async function resolveSummarizer() {
const meta = await loadMeta().catch(() => null);
const providerId = meta?.defaultProvider || 'ollama';
- const provider = await getProviderById(providerId).catch(() => null)
- || await getProviderById('ollama').catch(() => null);
+
+ // Try the Brain default provider first. `meta.defaultModel` belongs to THIS
+ // provider, so it's only valid when this lookup succeeds.
+ let provider = await getProviderById(providerId).catch(() => null);
+ if (provider) {
+ const model = meta?.defaultModel || provider.defaultModel || PREFERRED_MODEL;
+ return { provider, model };
+ }
+
+ // Default provider is stale/removed — fall back to ollama, but use ITS own
+ // model (NOT meta.defaultModel, which named a model on the missing provider
+ // and would likely 404 against ollama).
+ provider = await getProviderById('ollama').catch(() => null);
if (!provider) return null;
- const model = meta?.defaultModel || provider.defaultModel || PREFERRED_MODEL;
- return { provider, model };
+ return { provider, model: provider.defaultModel || PREFERRED_MODEL };
}
/**
diff --git a/server/services/memorySummarizer.test.js b/server/services/memorySummarizer.test.js
index b79bc41dab..6f7b6fcd66 100644
--- a/server/services/memorySummarizer.test.js
+++ b/server/services/memorySummarizer.test.js
@@ -51,9 +51,11 @@ describe('memorySummarizer — summarizeForEmbedding', () => {
expect(runPromptThroughProvider.mock.calls[0][0].prompt).toContain('the combined memory text');
});
- it('falls back to the ollama provider when the Brain default does not resolve', async () => {
- loadMeta.mockResolvedValue({ defaultProvider: 'some-removed-provider', defaultModel: 'x' });
- // First lookup (the brain default) misses; the ollama fallback resolves.
+ it('falls back to the ollama provider AND its own model when the Brain default does not resolve', async () => {
+ // meta.defaultModel names a model on the now-missing provider — it must NOT
+ // be sent to the ollama fallback (would 404). The fallback uses ollama's
+ // own defaultModel instead.
+ loadMeta.mockResolvedValue({ defaultProvider: 'some-removed-provider', defaultModel: 'model-on-missing-provider' });
getProviderById.mockImplementation(async (id) =>
id === 'ollama' ? { id: 'ollama', type: 'api', endpoint: 'http://localhost:11434/v1', defaultModel: 'gpt-oss:20b' } : null
);
@@ -63,6 +65,10 @@ describe('memorySummarizer — summarizeForEmbedding', () => {
expect(getProviderById).toHaveBeenCalledWith('ollama');
expect(out).toBe('summary');
+ // The stale default-provider model must not leak into the fallback call.
+ const usedModel = runPromptThroughProvider.mock.calls[0][0].model;
+ expect(usedModel).toBe('gpt-oss:20b');
+ expect(usedModel).not.toBe('model-on-missing-provider');
});
it('returns null when no provider is configured (caller then truncates)', async () => {