DEV Community

LastBrowser
LastBrowser

Posted on

Our Local Title Generator Had a Cloud Fallback Nobody Asked For

A user reported that LastBrowser's Sidekick, running against a local Ollama model, seemed to be talking to a cloud provider anyway. Their report mentioned five chats, OpenRouter, and network traffic they had not expected from a "local" setup.

We could not reproduce their exact session, and we still don't know which route those five chats took. What we did find, by reading the code and then forcing the failure in a test, was a real path where snippets of a local conversation could leave the machine. Not in the chat itself, but in something most people never think about: the little title that appears in the sidebar after the first exchange.

This post is about how a well-meant fallback turned into that path, why our tests didn't catch it, and what we changed.

The symptom

The report boiled down to: "I picked a local model, and something still went to the cloud." That is a hard claim to check after the fact. We had no packet capture and no request log from the user's machine. So instead of trying to reconstruct their session, we asked a narrower question: is there any code path where a chat running on loopback Ollama hands conversation content to a non-local provider?

False trails

The first places we looked were the obvious ones, and they turned out to be working as designed (which is not the same as being unsurprising):

  • Automatic Quickchat can pick an eligible cloud provider. That is a deliberate mode, not a bug, but it means "I use Ollama" and "every chat uses Ollama" are not the same statement.
  • Settings refresh reads a cached model catalog and does not have to contact Ollama at all, so it was not the source of the extra requests either.
  • Startup downloads (ad-block filter lists, the Widevine component, update checks) explained some unexpected network activity, but none of it carries chat content. We fixed one real issue there in the same PR: a disabled ad-block shield still refreshed its filter lists. That is a separate story.

None of these explained conversation text leaving the machine. The title code did.

The cause: a fallback with good intentions

Sidekick generates a short title for each new chat. For local setups there is a small helper that asks Ollama for a title. Ollama is not always running, though: people stop it, the GPU is busy, or they only use cloud models. So someone (us) added a fallback. Here is the comment from the code before the fix:

    except Exception:
        # Local Ollama is not always running (e.g. a cloud-only setup, or the
        # GPU is reserved for something else).  Fall back to the auxiliary
        # cloud route so /api/chat sessions still get a real title instead of
        # the truncated first user message.
        return _generate_title_via_aux_fallback(messages)
Enter fullscreen mode Exit fullscreen mode

The fallback took the first user message and the first assistant reply, and sent them to the "auxiliary" client: the general helper we use for side tasks such as titles and context compression. Depending on configuration, that auxiliary route can resolve to a cloud provider, OpenRouter included.

Read in isolation, every piece makes sense. Ollama is down, so don't show an ugly title, ask another model. The problem is the context the fallback ignored: the user had chosen a local model, and the reason the local call failed (Ollama timing out) is exactly the situation where they would least expect a remote call.

The background title paths had the same shape. When a title request through the chat's own agent failed with llm_error, the code tried the auxiliary route next, without asking whether the agent was local in the first place.

There was one more, quieter version of the same problem in the auxiliary client itself. When a task had no explicit provider configured, resolution fell through to "auto", which follows a provider detection chain. It did not look at the endpoint the active chat was using. So a task like compression, running for a chat on http://127.0.0.1:11434, could be resolved independently of that choice.

Why the tests didn't catch it

We had tests for title generation, and they passed. They mostly checked that a title came back, and that it was sanitised and short. From that point of view the fallback was a success: Ollama fails, a title still appears. The tests asserted the outcome we wanted for usability, but nothing asserted the property we actually cared about here, which is where the request went.

Once we wrote that down as a test, it failed immediately. We simulated Ollama timing out and recorded every call to the auxiliary title generator. Before the patch, the recording was not empty.

The fix

We made three changes.

1. Local title generation fails locally. The cloud fallback in _generate_title_via_ollama is gone. If loopback Ollama does not answer, the function returns None, and the caller keeps its existing heuristic title built from the first message. Slightly uglier title, no remote call. The HTTP client for that call also ignores proxy environment variables and refuses redirects, so "localhost" stays localhost:

with httpx.Client(timeout=5, trust_env=False, follow_redirects=False) as client:
    response = client.post("http://localhost:11434/v1/chat/completions", json=payload)
Enter fullscreen mode Exit fullscreen mode

2. Background titles check where the agent lives first. Both background paths (initial title and later refresh) now go through one helper. If the active agent's endpoint is classified as local, it uses only that agent and never falls back to the auxiliary route:

if provider_deployment(
    provider, {'model': {'provider': provider, 'base_url': endpoint}}
) == 'local':
    return _generate_llm_session_title_for_agent(agent, user_text, assistant_text)
Enter fullscreen mode Exit fullscreen mode

The previous logic for non-local agents stays as it was.

3. Automatic auxiliary tasks follow the chat's loopback endpoint. When no explicit provider is configured for a task and the main runtime is a loopback Ollama or OpenAI-compatible endpoint, the auxiliary client now resolves to that same endpoint instead of "auto". In that case it also does not pick up a cloud API key from the environment. A user who explicitly configures a cloud provider for a task still gets it; this only changes the automatic default.

Each change has a test that records attempted calls instead of only checking the result. For example, the compression test makes the loopback endpoint refuse the connection and asserts that the error is raised and that the only attempt was the local one, with no "payment fallback" to another provider. The background title test runs with and without an auxiliary title provider configured and asserts that the auxiliary function is never called for a local agent.

What we still don't know

We want to be clear about the limits:

  • We showed that the title path could hand first-exchange snippets to a cloud provider after a local failure, and we reproduced it with a simulated timeout. We did not establish that this is what happened in the user's five chats.
  • Automatic Quickchat can still choose a cloud model by design. If you want everything local, choose a local model explicitly.
  • Without the user's request logs we could not verify the reported traffic volumes or endpoints.
  • The fix landed on our main branch on November 16, after our last stable release (0.1.60).

The lesson

Fallbacks are decisions made on the user's behalf, usually by someone thinking about a different user. "Ollama is down, so try another model" is a reasonable rule for someone who uses cloud models anyway. For someone who picked a local model, the same rule quietly breaks their choice.

Two practical takeaways for us:

  1. Any fallback that crosses a trust boundary (local to remote, one provider to another) needs to know why the primary was chosen, not just that it failed. Ours knew only the second.
  2. Test where requests go, not only what comes back. A test that only checks "we got a title" will happily reward a privacy regression.

This came up while working on LastBrowser, a desktop browser with a built-in AI assistant. The code is on GitHub.

Top comments (0)