Nikhil dee3086a48 feat(server): cache klavis createStrata to unblock /chat hot path (#654)
* feat(server): cache klavis createStrata to unblock /chat hot path

Conversation creation in /chat was blocking on a Worker-proxied
klavisClient.createStrata round-trip every time the user had any
managed Klavis app connected. The 5s KLAVIS_TIMEOUT_MS in the
ai-worker proxy existed specifically to bound this latency, but
the same cap also caused user-visible 504s on /klavis/servers/remove
since Strata DELETE operations routinely take >5s. Without caching
we couldn't raise the timeout without regressing chat creation.

This adds an in-process cache for Strata createStrata responses,
keyed by (browserosId, hashed sorted-server-set) and gated by a 1h
TTL. The cache stores only immutable JSON metadata (strataServerUrl,
strataId, addedServers); per-session MCP clients continue to be
opened and disposed by AiSdkAgent exactly as before, which keeps
the cache concurrency-safe by construction.

Cache invalidation has two layers: (a) the cache key embeds the
server set, so adding/removing apps naturally produces a different
key; (b) POST /klavis/servers/add and DELETE /klavis/servers/remove
explicitly call invalidate(browserosId) after their underlying
Klavis API call succeeds, as defense-in-depth.

Other changes:
- Consolidates klavis-related services into a new
  apps/server/src/api/services/klavis/ directory; moves
  register-klavis-mcp.ts -> strata-proxy.ts and adds strata-cache.ts
  there. lib/clients/klavis/ stays unchanged.
- Refactors KlavisClient.removeServer into a low-level
  deleteServersFromStrata(strataId, servers) primitive. The
  cache-lookup + delete + invalidate orchestration moves up into
  routes/klavis.ts where it belongs, eliminating the lib->api
  layering inversion the original removeServer would have introduced.
- Uses Bun.hash (xxhash64) for fixed-width 16-hex-char keys, with
  serverKey verified on read to make collision risk strictly zero.
- Dedupes concurrent fetches via in-flight Promise sharing, with
  identity-checks before delete to avoid races between invalidate()
  and a racing replacement insert.

Follow-up (separate PR): bump KLAVIS_TIMEOUT_MS to 30000 in
ai-worker/wrangler.toml so /klavis/servers/remove stops 504-ing.

* fix: address greptile review comments for klavis strata cache

- Drop dead `invalidated` field on InflightEntry. It was added to
  support a "discard post-resolution if invalidated" check that I
  later replaced with identity-checked deletes during self-review,
  but I forgot to remove the field and the misleading comment
  referencing it. Simplify Map<string, InflightEntry> to plain
  Map<string, Promise<CacheEntry>>.
- Lower cache miss log from info to debug. Misses fire on every new
  conversation; matching the existing debug-level for hits.
- Stop routing the /klavis/servers/remove handler through
  klavisStrataCache.getOrFetch. The chat hot path keys its cache by
  the user's full enabled-server set (e.g. hash('Gmail,Linear')),
  so a single-server lookup here (hash('Gmail')) is guaranteed to
  miss, write a spurious entry, and then have it immediately
  cleared by invalidate() on the next line. Call createStrata
  directly to recover the strataId, mirroring the original
  removeServer flow.
2026-04-07 11:11:41 -07:00
2026-03-17 19:01:10 +05:30
2025-09-13 18:04:54 +05:30
2026-01-06 16:24:19 -08:00
2025-09-30 12:54:03 -07:00
2025-06-18 17:48:04 -07:00
2026-04-02 13:00:11 -07:00

BrowserOS is an open-source Chromium fork that runs AI agents natively. The privacy-first alternative to ChatGPT Atlas, Perplexity Comet, and Dia.

Use your own API keys or run local models with Ollama. Your data never leaves your machine.

Documentation · Discord · Slack · Twitter · Feature Requests

Quick Start

  1. Download and install BrowserOS — macOS · Windows · Linux (AppImage) · Linux (Debian)
  2. Import your Chrome data (optional) — bookmarks, passwords, extensions all carry over
  3. Connect your AI provider — Claude, OpenAI, Gemini, ChatGPT Pro via OAuth, or local models via Ollama/LM Studio

Features

Feature Description Docs
AI Agent 53+ browser automation tools — navigate, click, type, extract data, all with natural language Guide
MCP Server Control the browser from Claude Code, Gemini CLI, or any MCP client Setup
Workflows Build repeatable browser automations with a visual graph builder Docs
Cowork Combine browser automation with local file operations — research the web, save reports to your folder Docs
Scheduled Tasks Run agents on autopilot — daily, hourly, or every few minutes Docs
Memory Persistent memory across conversations — your assistant remembers context over time Docs
SOUL.md Define your AI's personality and instructions in a single markdown file Docs
LLM Hub Compare Claude, ChatGPT, and Gemini responses side-by-side on any page Docs
40+ App Integrations Gmail, Slack, GitHub, Linear, Notion, Figma, Salesforce, and more via MCP Docs
Vertical Tabs Side-panel tab management — stay organized even with 100+ tabs open Docs
Ad Blocking uBlock Origin + Manifest V2 support — 10x more protection than Chrome Docs
Cloud Sync Sync browser config and agent history across devices Docs
Skills Custom instruction sets that shape how your AI assistant behaves Docs
Smart Nudges Contextual suggestions to connect apps and use features at the right moment Docs

Demos

BrowserOS agent in action

BrowserOS agent in action

Install BrowserOS as MCP and control it from claude-code

https://github.com/user-attachments/assets/c725d6df-1a0d-40eb-a125-ea009bf664dc



Use BrowserOS to chat

https://github.com/user-attachments/assets/726803c5-8e36-420e-8694-c63a2607beca



Use BrowserOS to scrape data

https://github.com/user-attachments/assets/9f038216-bc24-4555-abf1-af2adcb7ebc0



Install browseros-cli

Use browseros-cli to launch and control BrowserOS from the terminal or from AI coding agents like Claude Code.

macOS / Linux:

curl -fsSL https://cdn.browseros.com/cli/install.sh | bash

Windows:

irm https://cdn.browseros.com/cli/install.ps1 | iex

After install, run browseros-cli init to connect the CLI to your running BrowserOS instance.

LLM Providers

BrowserOS works with any LLM. Bring your own keys, use OAuth, or run models locally.

Provider Type Auth
Kimi K2.5 Cloud (default) Built-in
ChatGPT Pro/Plus Cloud OAuth
GitHub Copilot Cloud OAuth
Qwen Code Cloud OAuth
Claude (Anthropic) Cloud API key
GPT-4o / o3 (OpenAI) Cloud API key
Gemini (Google) Cloud API key
Azure OpenAI Cloud API key
AWS Bedrock Cloud IAM credentials
OpenRouter Cloud API key
Ollama Local Setup
LM Studio Local Setup

How We Compare

BrowserOS Chrome Brave Dia Comet Atlas
Open Source
AI Agent
MCP Server
Visual Workflows
Cowork (files + browser)
Scheduled Tasks
Bring Your Own Keys
Local Models (Ollama)
Local-first Privacy
Ad Blocking (MV2)

Detailed comparisons:

Architecture

BrowserOS is a monorepo with two main subsystems: the browser (Chromium fork) and the agent platform (TypeScript/Go).

BrowserOS/
├── packages/browseros/              # Chromium fork + build system (Python)
│   ├── chromium_patches/            # Patches applied to Chromium source
│   ├── build/                       # Build CLI and modules
│   └── resources/                   # Icons, entitlements, signing
│
├── packages/browseros-agent/        # Agent platform (TypeScript/Go)
│   ├── apps/
│   │   ├── server/                  # MCP server + AI agent loop (Bun)
│   │   ├── agent/                   # Browser extension UI (WXT + React)
│   │   ├── cli/                     # CLI tool (Go)
│   │   ├── eval/                    # Benchmark framework
│   │   └── controller-ext/          # Chrome API bridge extension
│   │
│   └── packages/
│       ├── agent-sdk/               # Node.js SDK (npm: @browseros-ai/agent-sdk)
│       ├── cdp-protocol/            # CDP type bindings
│       └── shared/                  # Shared constants
Package What it does
packages/browseros Chromium fork — patches, build system, signing
apps/server Bun server exposing 53+ MCP tools and running the AI agent loop
apps/agent Browser extension — new tab, side panel chat, onboarding, settings
apps/cli Go CLI — control BrowserOS from the terminal or AI coding agents
apps/eval Benchmark framework — WebVoyager, Mind2Web evaluation
agent-sdk Node.js SDK for browser automation with natural language
cdp-protocol Type-safe Chrome DevTools Protocol bindings

Contributing

We'd love your help making BrowserOS better! See our Contributing Guide for details.

Agent development (TypeScript/Go) — see the agent monorepo README for setup instructions.

Browser development (C++/Python) — requires ~100GB disk space. See packages/browseros for build instructions.

Credits

  • ungoogled-chromium — BrowserOS uses some patches for enhanced privacy. Thanks to everyone behind this project!
  • The Chromium Project — at the core of BrowserOS, making it possible to exist in the first place.

License

BrowserOS is open source under the AGPL-3.0 license.

Copyright © 2026 Felafax, Inc.

Stargazers

Thank you to all our supporters!

Star History Chart

Built with ❤️ from San Francisco

Description
No description provided
Readme AGPL-3.0 18 GiB
Languages
TypeScript 65.6%
C++ 24%
Go 6.5%
C 1.5%
Objective-C++ 1%
Other 1.3%