fix(confidence-engine): extend reconstruction chat timeout

This commit is contained in:
2026-09-06 06:16:36 +01:00
parent 7070342fb1
commit 726746f22d
3 changed files with 10 additions and 1 deletions
+6
View File
@@ -98,6 +98,12 @@
- This skipped schema-constrained reconstruction `/api/chat` and used unconstrained `/api/generate`. Response-body disposal now uses Fetch-compatible consumption without changing capability or fallback semantics. - This skipped schema-constrained reconstruction `/api/chat` and used unconstrained `/api/generate`. Response-body disposal now uses Fetch-compatible consumption without changing capability or fallback semantics.
- Next boundary: one fresh-process fixed-scenario production observation. - Next boundary: one fresh-process fixed-scenario production observation.
## Reconstruction chat timeout
- Capability detection/body disposal was fixed at `7070342`. Fresh runtime evidence then proved the real schema-constrained `/api/chat` request was attempted but Confidence Engine aborted it after 60 seconds while Qwen was still generating.
- Fallback `/api/generate` completed but produced structurally invalid reconstruction. The real reconstruction `/api/chat` timeout is now 300 seconds, matching `/api/generate`; fallback, schema, prompt, and reasoning semantics are unchanged.
- Next boundary: one fresh-process fixed-scenario production observation.
## Current product architecture ## Current product architecture
Three distinct routes, not a single page: Three distinct routes, not a single page:
+1 -1
View File
@@ -134,7 +134,7 @@ class OllamaLlmProvider {
if (chatSupported) { if (chatSupported) {
try { try {
const controller = new AbortController(); const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 60000); const timeout = setTimeout(() => controller.abort(), 300000); // 5 min for reconstruction
apiUsed = "/api/chat"; apiUsed = "/api/chat";
providerExecution.chatRequestAttempted = true; providerExecution.chatRequestAttempted = true;
+3
View File
@@ -10,6 +10,7 @@ describe("OllamaLlmProvider chat capability detection", () => {
ok: true, ok: true,
json: async () => ({ message: { content: "{}" } }), json: async () => ({ message: { content: "{}" } }),
}); });
const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");
vi.stubGlobal("fetch", fetchSpy); vi.stubGlobal("fetch", fetchSpy);
process.env.OLLAMA_BASE_URL = "http://ollama.test"; process.env.OLLAMA_BASE_URL = "http://ollama.test";
@@ -24,6 +25,7 @@ describe("OllamaLlmProvider chat capability detection", () => {
expect(fetchSpy.mock.calls[0][0]).toBe("http://ollama.test/api/chat"); expect(fetchSpy.mock.calls[0][0]).toBe("http://ollama.test/api/chat");
expect(fetchSpy.mock.calls[1][0]).toBe("http://ollama.test/api/chat"); expect(fetchSpy.mock.calls[1][0]).toBe("http://ollama.test/api/chat");
expect(fetchSpy.mock.calls[1][0]).not.toContain("/api/generate"); expect(fetchSpy.mock.calls[1][0]).not.toContain("/api/generate");
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), 300000);
const chatRequest = JSON.parse(fetchSpy.mock.calls[1][1].body); const chatRequest = JSON.parse(fetchSpy.mock.calls[1][1].body);
expect(chatRequest).toMatchObject({ expect(chatRequest).toMatchObject({
model: "configured-model", model: "configured-model",
@@ -46,6 +48,7 @@ describe("OllamaLlmProvider chat capability detection", () => {
}, },
}); });
} finally { } finally {
setTimeoutSpy.mockRestore();
vi.unstubAllGlobals(); vi.unstubAllGlobals();
if (originalBaseUrl === undefined) delete process.env.OLLAMA_BASE_URL; if (originalBaseUrl === undefined) delete process.env.OLLAMA_BASE_URL;
else process.env.OLLAMA_BASE_URL = originalBaseUrl; else process.env.OLLAMA_BASE_URL = originalBaseUrl;