Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/lib/inference/local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,23 +619,22 @@ describe("local inference helpers", () => {
expect(result?.ok).toBe(expected);
});

it("reports a clear local provider outage when the host probe cannot connect", () => {
it.each([
{ curlStatus: 7, message: "Failed to connect", recoveryHint: false },
{ curlStatus: 28, message: "Operation timed out", recoveryHint: true },
])("reports local Ollama outage details for curl exit $curlStatus", ({ curlStatus, message, recoveryHint }) => {
const result = probeLocalProviderHealth("ollama-local", {
runCurlProbeImpl: () => ({
ok: false,
httpStatus: 0,
curlStatus: 7,
body: "",
stderr: "Failed to connect",
message: "curl failed (exit 7): Failed to connect",
}),
runCurlProbeImpl: () => ({ ok: false, httpStatus: 0, curlStatus, body: "", stderr: message, message }),
loadOllamaProxyTokenImpl: () => null,
});

expect(result?.ok).toBe(false);
expect(result?.detail).toContain("Local Ollama is selected for inference");
expect(result?.detail).toContain("Start Ollama and retry");
expect(result?.detail).toContain("http://127.0.0.1:11434/api/tags");
expect(result?.detail.includes("sudo systemctl restart ollama")).toBe(recoveryHint);
expect(result?.detail.includes("stale runner processes from a previous model")).toBe(recoveryHint);
expect(result?.detail.includes("holding GPU memory")).toBe(recoveryHint);
expect(result?.probeLabel).toBe("ollama backend");
});

Expand Down
9 changes: 7 additions & 2 deletions src/lib/inference/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,16 @@ function buildLocalProviderProbeDetail(
const label = getLocalProviderLabel(provider) || "Local inference provider";
if (result.httpStatus === 0) {
switch (provider) {
case "ollama-local":
case "ollama-local": {
const timeoutRecovery =
result.curlStatus === 28
? " If Ollama is running but the probe times out, stale runner processes from a previous model may be holding GPU memory; run 'sudo systemctl restart ollama' and retry."
: "";
return (
`${label} is selected for inference, but the host probe to ${endpoint} failed. ` +
`Start Ollama and retry. (${result.message})`
`Start Ollama and retry.${timeoutRecovery} (${result.message})`
);
}
case "vllm-local":
return (
`${label} is selected for inference, but the host probe to ${endpoint} failed. ` +
Expand Down
Loading