[🐞 BUG] Custom AI provider settings are regularly lost
Describe the bug Custom AI provider settings are regularly lost. When I open the settings, the entire list of providers disappears, including my custom provider, and my custom prompt is also missing. After adding a custom provider again, the previously filled custom prompts reappear.
To Reproduce Steps to reproduce the behavior:
- Go to Preferences → AI Enhancements → Providers and Prompts & Advanced
- Add custom provider and custom Dictation Prompt
- After few successful dictations Fluid starts act without those settings and if you open Preferences → AI Enhancements again it will be empty (even without predefined providers)
Expected behavior Stable AI Enhancements settings
Screenshots
Environment:
- macOS Version: Sequoia 15.7.3 (24G419)
- App Version: v1.5.5
- Architecture: Apple Silicon
Additional context Add any other context about the problem here.
Logs
[18:04:10.516] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.
[18:04:18.522] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.
[18:04:18.537] [DEBUG] [AISettingsView] testAPIConnection: provider=openrouter, model=anthropic/claude-sonnet-4.5, baseURL=https://openrouter.ai/api/v1, fullURL=https://openrouter.ai/api/v1/chat/completions
Oh wow. This is a pretty crazy bug for sure. Is this random? Do the builtin ones ever come back after disappearing? Can you reproduce it? I have never seen this till now. If you could help me some way to reproduce it, it would be amazing! Thanks
Oh wow. This is a pretty crazy bug for sure. Is this random? Do the builtin ones ever come back after disappearing? Can you reproduce it? I have never seen this till now. If you could help me some way to reproduce it, it would be amazing! Thanks
It's 100% stable — after any moves away from AI Enhancement window (close settings or switching tab). I suspect my custom Russian prompt, since it's the first "unusual" thing in whole setup... Could you also made logs more informative about: "[18:04:10.516] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid."? Which exactly parameters?
I can reproduce/trace the log:
[SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.
This comes from SettingsStore.providerAPIKeys setter calling persistProviderAPIKeys(_:), which delegates to Keychain.
Relevant code:
SettingsStore.providerAPIKeyssetter →persistProviderAPIKeys(newValue)[1]SettingsStore.persistProviderAPIKeys(_:)→try self.keychain.storeAllKeys(trimmed)[1]
In KeychainService.saveStoredKeys, the errSecDuplicateItem branch uses SecItemUpdate with an update “dictionary” that looks malformed and can return errSecParam (“One or more parameters…”) on some systems:
case errSecDuplicateItem:
let updateStatus = SecItemUpdate(
aggregatedQuery() as CFDictionary,
[kSecValueData as String: data] as CFDictionary
)
Possible fix: pass a properly typed [String: Any] attributes dictionary (and keep kSecAttrAccessible consistent with the SecItemAdd path):
case errSecDuplicateItem:
let update: [String: Any] = [
kSecValueData as String: data,
kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlock
]
let updateStatus = SecItemUpdate(
aggregatedQuery() as CFDictionary,
update as CFDictionary
)
guard updateStatus == errSecSuccess else {
throw KeychainServiceError.unhandledOSStatus(updateStatus)
}
Also, for easier debugging, it might help to log the raw OSStatus (nsError.code) in the catch inside SettingsStore.persistProviderAPIKeys(_:) (right now it logs only localizedDescription).