🐛 fix: Keep the system default when the upload provider is unresolved

An upload reports the agents endpoint when the agent's real provider cannot be
resolved, as for ephemeral agents with no persisted record. Judging capability
from that container downgraded PDF, audio, and video to text even where the
actual provider delivers them natively. An unresolved provider now keeps the
system default rather than being treated as incapable.
This commit is contained in:
Danny Avila 2026-08-31 10:35:35 -04:00
parent 012499e7f4
commit 999dc26891
2 changed files with 15 additions and 1 deletions

View file

@ -189,6 +189,15 @@ describe('resolveDefaultLLMDeliveryPath', () => {
);
});
it('keeps the system default when the provider is unresolved (agents container)', () => {
expect(resolveDefaultLLMDeliveryPath('audio/mpeg', undefined, undefined, 'agents')).toBe(
'provider',
);
expect(resolveDefaultLLMDeliveryPath('application/pdf', undefined, undefined, 'agents')).toBe(
'provider',
);
});
it('should export SYSTEM_LLM_DELIVERY_DEFAULTS with correct shape', () => {
expect(SYSTEM_LLM_DELIVERY_DEFAULTS.fallback).toBe('text');
expect(SYSTEM_LLM_DELIVERY_DEFAULTS.overrides).toEqual({

View file

@ -70,7 +70,12 @@ export function resolveDefaultLLMDeliveryPath(
/** Only the system default is capability-gated: an explicit config above is the
* admin's decision. A known endpoint that cannot encode documents or media would
* otherwise accept the upload and hand the model nothing at all. */
if (systemDefault === 'provider' && endpoint != null && !isProviderCapable(mimeType, endpoint)) {
/** `agents` is a container, not a provider: it is what an upload reports when the
* agent's real provider could not be resolved, as for ephemeral agents. Judging
* capability from it would downgrade media the actual provider can deliver, so an
* unresolved provider keeps the system default. */
const providerKnown = endpoint != null && endpoint !== EModelEndpoint.agents;
if (systemDefault === 'provider' && providerKnown && !isProviderCapable(mimeType, endpoint)) {
return 'text';
}