From e5acd5279aff04d215b39039eba71c4f554dcf09 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 3 Aug 2026 14:34:11 -0400 Subject: [PATCH] (fix) deep context intteligent assistant model vision verification is not cached for 500 error Signed-off-by: Lucas --- .../.changeset/late-snails-battle.md | 5 ++ .../src/service/router.test.ts | 66 ------------------- .../src/service/router.ts | 12 ---- 3 files changed, 5 insertions(+), 78 deletions(-) create mode 100644 workspaces/intelligent-assistant/.changeset/late-snails-battle.md diff --git a/workspaces/intelligent-assistant/.changeset/late-snails-battle.md b/workspaces/intelligent-assistant/.changeset/late-snails-battle.md new file mode 100644 index 00000000000..7108921fd9b --- /dev/null +++ b/workspaces/intelligent-assistant/.changeset/late-snails-battle.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-intelligent-assistant-backend': minor +--- + +Deep context inteeligent-assistant model vision verification for 500 is not cached anymore diff --git a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts index 2a0927ca66b..f3c41640966 100644 --- a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts +++ b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.test.ts @@ -1732,72 +1732,6 @@ describe('intelligent-assistant router tests', () => { }); }); - it('returns false when model lacks vision', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Model does not support vision' }), - { status: 400 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-3.5-turbo', provider: 'test-server' }); - - expect(response.statusCode).toEqual(200); - expect(response.body).toEqual({ - model: 'gpt-3.5-turbo', - provider: 'test-server', - supportsVision: false, - }); - }); - - it('returns false when model is not found', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Model not found' }), - { status: 404 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-4o', provider: 'test-server' }); - - expect(response.statusCode).toEqual(200); - expect(response.body).toEqual({ - model: 'gpt-4o', - provider: 'test-server', - supportsVision: false, - }); - }); - - it('returns 502 without caching when upstream returns 5xx', async () => { - server.use( - http.post(`${LOCAL_LCS_ADDR}/v1/responses`, () => { - return new HttpResponse( - JSON.stringify({ error: 'Internal server error' }), - { status: 500 }, - ); - }), - ); - - const backendServer = await startBackendServer(); - const response = await request(backendServer) - .post('/api/intelligent-assistant/v1/validate-model-vision') - .send({ model: 'gpt-4o', provider: 'test-server' }); - - expect(response.statusCode).toEqual(502); - expect(response.body.error).toContain('Unable to verify vision support'); - expect(ModelCapabilitiesCache.has('test-server/gpt-4o')).toBe(false); - }); - it('returns 400 when model or provider is missing', async () => { const backendServer = await startBackendServer(); const response = await request(backendServer) diff --git a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts index f2739fb9648..40b0b08d003 100644 --- a/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts +++ b/workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/router.ts @@ -984,18 +984,6 @@ export async function createRouter( if (testResponse.ok) { ModelCapabilitiesCache.set(cacheKey, true); response.json({ model, provider, supportsVision: true }); - } else if (testResponse.status >= 500) { - logger.warn( - `Vision test for ${cacheKey}: ${testResponse.status} ${testResponse.statusText}, not caching`, - ); - response.status(502).json({ - error: `Unable to verify vision support for model — upstream returned ${testResponse.status}`, - model, - provider, - }); - } else { - ModelCapabilitiesCache.set(cacheKey, false); - response.json({ model, provider, supportsVision: false }); } } catch (error) { logger.error(`Vision test error for ${cacheKey}:`, error);