Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
docs: describe the endpoint fixes and correct three slips
trohitgf1375b21b340
diff --git a/CLAUDE.md b/CLAUDE.mdindex acd2a637..671520bd 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -60,7 +60,7 @@ This is a React Flow-based workflow automation platform implementing n8n-inspire| **[CLI Services Integration](./docs-internal/cli_services_integration.md)** | Guide for integrating CLI-based services (Temporal, etc.) with proper lifecycle management || **[Temporal Architecture](./docs-internal/TEMPORAL_ARCHITECTURE.md)** | Distributed workflow execution: activities, FIRST_COMPLETED scheduling, horizontal scaling || **[Native LLM SDK](./docs-internal/native_llm_sdk.md)** | Native SDK layer in `services/llm/`: protocol-based providers, config-driven base URLs, and 14 registered providers (11 cloud, Ollama / LM Studio, and `openai_compatible`, which serves any number of user-named endpoints — llama.cpp, vLLM, a LiteLLM proxy — added in the Credentials Modal with no code; xAI is agent-selectable without a standalone chat-model node). A JSON-driven `supports_model_listing: false` flag covers endpoints that speak the OpenAI chat wire format but ship no `/v1/models` route (Sarvam) — `OpenAIProvider.fetch_models` then serves the curated list and probes the key with a one-token completion. Every provider is native; `tests/llm/test_langchain_removed.py` locks the retired-dependency end state. |-| **[RFC-0003 — OpenAI-Compatible Provider Contract](./RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.md)** | Accepted, implemented. "OpenAI-compatible" is a family of divergent shapes with no spec behind it, so per-provider facts are **resolved at save time or declared**, never guessed. A configured `base_url` is copied **verbatim** from vendor docs and never rewritten (`/v1` is neither universal nor positionally predictable — DeepSeek is root-mounted, Groq is `/openai/v1`); a **user-supplied** URL is rooted by `services/llm/endpoints.py::resolve_base_url`, which sends the SDK's own `models.list()` to the URL then to it plus `/v1` and adopts only a body that **is an OpenAI list** — a status alone proves nothing, because LM Studio answers HTTP 200 to routes it does not serve. A failed save writes and broadcasts nothing. One `resolve_credential` sends the stored key or the vendor-documented placeholder (`auth.placeholder_key`) and never `None` (which would make the SDK read `OPENAI_API_KEY` and ship it to a third-party URL); no provider rewrites a key. A 2xx with no `choices` and an error body raises `PROTOCOL` naming the redacted URL. **Named endpoints (D13–D17)**: any server is a provider reference `openai_compatible:<slug>` stored exactly like Ollama (`{ref}` + `{ref}_proxy`), selectable from every agent (the `provider` field is a loader-driven `ProviderRef`, not a `Literal`), from the `openaiCompatibleChatModel` node (its field is `endpoint`, not `provider`, to dodge the panel's stored-key effect) and the global default picker; kind detected once from native routes by body shape; context and price from the server first (Ollama/LM Studio SDK probes, llama.cpp `/props`, vLLM `max_model_len`), then LiteLLM's table for generic servers only, then conservative defaults; local-model entries and the LiteLLM cache live under DATA_DIR, never in the tracked `config/model_registry.json`. RLM cannot route an endpoint and refuses one loudly. Gates AG1–AG20, `ProviderSpec` gains no field. |+| **[RFC-0003 — OpenAI-Compatible Provider Contract](./RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.md)** | Accepted, implemented. "OpenAI-compatible" is a family of divergent shapes with no spec behind it, so per-provider facts are **resolved at save time or declared**, never guessed. A configured `base_url` is copied **verbatim** from vendor docs and never rewritten (`/v1` is neither universal nor positionally predictable — DeepSeek is root-mounted, Groq is `/openai/v1`); a **user-supplied** URL is rooted by `services/llm/endpoints.py::resolve_base_url`, which sends the SDK's own `models.list()` to the URL then to it plus `/v1` and adopts only a body that **is an OpenAI list** — a status alone proves nothing, because LM Studio answers HTTP 200 to routes it does not serve. A failed save writes and broadcasts nothing. One `resolve_credential` sends the stored key or the vendor-documented placeholder (`auth.placeholder_key`) and never `None` (which would make the SDK read `OPENAI_API_KEY` and ship it to a third-party URL); no provider rewrites a key. A 2xx with no `choices` and an error body raises `PROTOCOL` naming the redacted URL. **Named endpoints (D13–D17)**: any server is a provider reference `openai_compatible:<slug>` stored exactly like Ollama (`{ref}` + `{ref}_proxy`), selectable from every agent (the `provider` field is a loader-driven `ProviderRef`, not a `Literal`), from the `openaiCompatibleChatModel` node (its field is `endpoint`, not `provider`, to dodge the panel's stored-key effect) and the global default picker; kind detected once from native routes by body shape; context and price from the server first (Ollama/LM Studio SDK probes, llama.cpp `/props`, vLLM `max_model_len`), then LiteLLM's table for generic servers only, then conservative defaults; local-model entries and the LiteLLM cache live under DATA_DIR, never in the tracked `config/model_registry.json`. RLM cannot route an endpoint and refuses one loudly. Gates AG1–AG20 (AG5 retired), `ProviderSpec` gains no field. || **[Event Waiter System](./docs-internal/event_waiter_system.md)** | In-memory asyncio.Future waiter for push-based trigger nodes on the canvas-Run path (WhatsApp, Telegram, Webhook, Chat, Task completion). Deployed triggers ride the Temporal canary path; the Redis-Streams backend was retired in Wave 15.3 || **[Credentials Encryption](./docs-internal/credentials_encryption.md)** | Fernet + PBKDF2 encryption pipeline, separate credentials.db, two credential systems (OAuth vs API keys), multi-backend abstraction || **[Status Broadcaster](./docs-internal/status_broadcaster.md)** | WebSocket-first communication: StatusBroadcaster singleton, live count via `len(MESSAGE_HANDLERS) + len(get_ws_handlers())`, broadcast message types, Android two-state model |@@ -2765,7 +2765,7 @@ This function:- **`outputMode: "terminal"` uiHint — spec-driven CLI output rendering**: the output panel (`components/output/OutputPanel.tsx`, the active renderer — `ui/OutputDisplayPanel.tsx` is legacy/unimported) renders string responses through ReactMarkdown by default, which whitespace-collapses CLI text. CLI-wrapper plugins (`githubAction`, `vercelAction`, `shell`) declare `ui_hints = {"outputMode": "terminal"}`; the panel resolves the spec via `useNodeSpec(selectedNode?.type)` and renders their text in a `<pre>` on the per-theme `--code-*` surface, routes wholly-JSON strings to the JSON tree via the shared `tryParseJson` (`utils/formatters.ts`), and surfaces object/array `result` payloads (server-side-parsed CLI JSON; arrays survive `unwrap` un-peeled) in the Response section. Pair with the `_shape` convention: parsed JSON in `result` OR text in `stdout` — never both — empty keys omitted. Locked by `client/src/components/__tests__/OutputPanel.test.tsx` (render tests: real `\n`/`\t` preserved) + the uiHints known-set in `test_node_spec.py`. Cache note: nodeSpecs are session-sticky (`staleTime: FOREVER`, revision-busted at page load) — after a backend restart a hard browser reload is needed before new uiHints reach an open canvas.- **`--action-X-hover` triplet + ActionButton zero-arithmetic**: each of the 6 action roles (`run`/`stop`/`save`/`config`/`secret`/`tools`) now exposes a `-hover` variant (0.25 alpha) alongside the existing `-soft` (0.15) and `-border` (0.6). ActionButton's CVA reads `hover:bg-action-X-hover` directly; disabled state is the shadcn-idiomatic `disabled:opacity-50` on the base class. No per-token `/25`, `/40`, `/10` opacity arithmetic at any call site. Credential-modal panels (`OAuthConnect`, `EmailPanel`, `QrPairingPanel`) and the skill editor (`MasterSkillEditor`) consume `<ActionButton intent="...">` directly. `ActionDef` carries an `intent` key; the catalogue adapter maps server-sent `theme_color` palette strings to intents via `SERVER_COLOR_TO_INTENT`.- **Credentials: DB as single source of truth + symmetric broadcasts + cache dedup**: `CredentialsDatabase` (encrypted SQLite) is canonical; every other layer is a derived cache with explicit invalidation. Backend `AuthService._memory_cache + _models_cache` collapsed into one `_api_key_cache: Dict[str, ApiKeyCacheEntry]` dataclass — single write/evict site. Per RFC 9700 (OAuth 2.0 BCP, 2024) the `_oauth_cache` no longer carries `refresh_token`; new `get_oauth_refresh_token(provider, customer)` reads from the encrypted DB on every call. `validate_api_key`, `save_api_key`, `delete_api_key`, `twitter_logout`, `google_logout` now broadcast symmetrically: `update_api_key_status` (in-memory map) + `broadcast_credential_event(...)` (refetch signal) wrapping `WorkflowEvent` (CloudEvents v1.0 from `services/events/envelope.py`, the same envelope the Wave 12 EventSource framework uses). The dead-letter `credential_catalogue_updated` event is finally emitted by the backend. Frontend retired the 200-LOC `client/src/components/credentials/providers.tsx` static fallback — `useCatalogueQuery` is the only source; cold-boot renders `<Skeleton>`, server-unreachable shows an explicit error state. `ApiKeyStatus.hasKey` mirror dropped (duplicated catalogue's `provider.stored`); two new selector hooks (`useProviderStored`, `useStoredProviderCount`) read the catalogue. Pytest invariant `test_credential_broadcasts.py` (17 tests) locks the broadcast contract via `inspect.getsource` introspection + the CloudEvents v1.0 envelope shape + AuthService DB-write-then-cache-update ordering + the no-refresh-token-in-cache rule.-- **Local-LLM provider routing + per-model context**: Ollama and LM Studio are first-class providers. Chat-model node detection is `detect_ai_provider` in `server/constants.py`, which MUST list `ollama` / `lmstudio` or those nodes silently fall through to `'openai'`; agents need no edit, because their `provider` field is the loader-driven `ProviderRef` (`nodes/agent/_provider.py`, `aiProviders` loader). Saving (`nodes/model/_local_validator.py::save_llm_server`, shared with named endpoints) first roots the URL through the OpenAI surface (`services/llm/endpoints.py::resolve_base_url`, body must be an OpenAI list), writes nothing on failure, and then probes via the official SDKs (`ollama.AsyncClient.ps()` for typed `ProcessResponse.Model`, `lmstudio.AsyncClient.llm.list_loaded()` for typed `LlmInstanceInfo`) — reads only typed fields (`context_length`, `max_context_length`, `vision`, `trained_for_tool_use`, `architecture`, `params_string`, `format`, plus Ollama's `details.{family,parameter_size,quantization_level}`). No regex, no Modelfile-parameters parsing, no `/api/show` modelinfo dict-key hunting. Per-model params persist in `EncryptedAPIKey.models["model_params"]` (via `store_api_key(model_params=...)`) AND via `register_local_model()`, which keeps them apart from the OpenRouter snapshot and persists them under DATA_DIR (`local_models.json`) — sync `get_context_length()` / `get_max_output_tokens()` find real values without async DB lookups, entries survive process restart, an OpenRouter refresh cannot wipe them, and user model names never land in the tracked `config/model_registry.json`. `is_model_valid_for_provider` returns `True` for providers that declare `"open_world_models": true` (openrouter / groq / ollama / lmstudio / openai_compatible) so local model names like `qwen/qwen3.6-27b` aren't rejected by the cloud-style pattern check. Runtime path is `OpenAIProvider(base_url={resolved URL})` with the stored key or the vendor's declared placeholder (`resolve_credential`) — no provider rewrites a key, and traffic stays on `localhost`.+- **Local-LLM provider routing + per-model context**: Ollama and LM Studio are first-class providers. Chat-model node detection is `detect_ai_provider` in `server/constants.py`, which MUST list `ollama` / `lmstudio` or those nodes silently fall through to `'openai'`; agents need no edit, because their `provider` field is the loader-driven `ProviderRef` (`nodes/agent/_provider.py`, `aiProviders` loader). Saving (`nodes/model/_local_validator.py::save_llm_server`, shared with named endpoints) first roots the URL through the OpenAI surface (`services/llm/endpoints.py::resolve_base_url`, body must be an OpenAI list), writes nothing on failure, and then probes via the official SDKs (`ollama.AsyncClient.ps()` for typed `ProcessResponse.Model`, `lmstudio.AsyncClient.llm.list_loaded()` for typed `LlmInstanceInfo`) — reads only typed fields (`context_length`, `max_context_length`, `vision`, `trained_for_tool_use`, `architecture`, `params_string`, `format`, plus Ollama's `details.{family,parameter_size,quantization_level}`). No regex, no Modelfile-parameters parsing, no `/api/show` modelinfo dict-key hunting. Per-model params persist in `EncryptedAPIKey.models["model_params"]` (via `store_api_key(model_params=...)`) AND via `register_local_model()`, which keeps them apart from the OpenRouter snapshot and persists them under DATA_DIR (`local_models.json`) — sync `get_context_length()` / `get_max_output_tokens()` find real values without async DB lookups, entries survive process restart, an OpenRouter refresh cannot wipe them, and user model names never land in the tracked `config/model_registry.json`. `is_model_valid_for_provider` returns `True` for providers that declare `"open_world_models": true` (openrouter / groq / ollama / lmstudio / openai_compatible) so local model names like `qwen/qwen3.6-27b` aren't rejected by the cloud-style pattern check. Runtime path passes the resolved URL to `OpenAIProvider` as `proxy_url` (it wins over the JSON `base_url`) with the stored key or the vendor's declared placeholder (`resolve_credential`) — no provider rewrites a key, and traffic stays on `localhost`.- **Typed SDK error → `LLMError` → `NodeUserError`**: Native providers normalize SDK failures into structured `LLMError` values carrying category, retryability, HTTP status, provider code, request ID, and retry-after metadata. `ChatUnifier` translates them at the execution boundary into a user-safe `NodeUserError`; `BaseNode.execute()` logs that at WARN with one line and no stack trace. Unexpected exceptions retain the full-traceback path. In-process agent turns retry only errors marked retryable, while Temporal owns activity retries and disables the inner retry loop.- **Plugin extraction (Wave 11.I)**: every plugin's WS handlers, OAuth client, FastAPI router, and lifecycle service live entirely under `nodes/<plugin>/`. Eight plugin domains migrated this round (whatsapp / twitter / google-workspace / android / browser / email / code / credential-validation-scaffold for maps+apify+ollama+lmstudio) follow the telegram pattern. `routers/websocket.py` shrunk from ~3,785 to ~2,977 LOC (-808). Three plugin routers (`routers/twitter.py`, `routers/google.py`, `routers/android.py`) moved into `nodes/<plugin>/_router.py` and mount via the plugin-router loop in `main.py`; the explicit `app.include_router(<plugin>.router)` calls and `from routers import <plugin>` imports in `main.py` are gone. **`register_router(router, name=...)` is the new sibling helper to `register_ws_handlers` (same file: `services/ws_handler_registry.py`)** — the generic registry set has since grown to 18 (see the Plugin System row at the top of this file). **`Credential.validate(data) -> dict` + `Credential._probe(api_key) -> ProbeResult` is the new shared validator scaffold** in `services/plugin/credential.py` — replaces the per-router `_SPECIAL_PROVIDER_VALIDATORS` dict; one `_LLMApiKey._probe` method serves all 10 cloud LLM providers, dedicated `_probe` overrides handle Maps + Apify, `_LocalLLM.validate` overrides for Ollama / LM Studio's 2-storage edge case. **`tests/test_plugin_self_containment.py` locks the contract** with 10 invariant classes (forbidden-imports / no-router-outside-nodes / per-plugin self-registration / registry-API sanity / stale-paths-absent / main.py-does-not-mount / WS_HANDLERS-non-empty / plugin-folder-has-node-file / typed-event-factories / package-imports-cleanly); same `inspect.getsource` introspection style as `test_credential_broadcasts.py`. Wire format unchanged — frontend WS message-type strings (`whatsapp_status`, `twitter_oauth_login`, `google_oauth_status`, `android_relay_connect`, etc.) and HTTP route paths (`/api/twitter/callback`, `/api/google/callback`, `/api/android/*`) are byte-identical post-migration.- **Typed CloudEvents factory pattern for new broadcasts** (b6aecd3): every new server→FE lifecycle broadcast follows the recipe locked by `broadcast_credential_event`, `broadcast_agent_progress`, and `broadcast_agent_capability`. (1) Add a typed factory — convention: `source = "opencompany://services/<area>"`, reverse-DNS `type = "com.opencompany.<area>.<event>"`, and `subject = <exact primary entity id>`. Put snake_case workflow/execution scope inside `data`; CloudEvents extension attribute names MUST be lowercase-alphanumeric, so the historical top-level `workflow_id`/`trigger_node_id`/`correlation_id` fields are compatibility debt and are forbidden on new contracts. (2) Add a broadcaster wrapper that emits `broadcast({type: "<wire_key>", data: event.model_dump(mode="json", exclude_none=True)})`. (3) FE validates `specversion`, ID/source/type, subject ownership, and event-specific payload invariants, deduplicates by `(source,id)`, then writes only the exact scoped entity. (4) Add contract tests in `test_events.py` and keep `tests/test_status_broadcasts.py`'s raw-callsite allowlist empty. Raw `node_status` remains allowed only as the established high-frequency latest-state/reconnect projection paired with a typed lifecycle occurrence; it is not the event of record.diff --git a/RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.md b/RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.mdindex 7dd9f7d4..00aca6b2 100644--- a/RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.md+++ b/RFC-0003-OPENAI-COMPATIBLE-PROVIDER-CONTRACT.md@@ -220,11 +220,12 @@ is the module's justification for existing.### 6.2 Kind (D14)For a named endpoint only, detected against the host (the resolved base with a-trailing `/v1` stripped), 3 s per route, each route accepted **by body shape**:+trailing `/v1` stripped). The three routes are asked at once with a 3 s timeout,+and each is accepted **by body shape**:| Route | Accepted when the body | Kind ||---|---|---|-| `GET /props` | has a `default_generation_settings` object | `llamacpp` (asked first: llama.cpp also mimics some Ollama routes) |+| `GET /props` | has a `default_generation_settings` object | `llamacpp` (wins when several answer: llama.cpp also mimics some Ollama routes) || `GET /api/v1/models` | has a `models` list | `lmstudio` (LM Studio's current native REST API; v0 is legacy) || `GET /api/version` | has a `version` string | `ollama` || otherwise | | `generic` |@@ -250,7 +251,18 @@ Only after rooting and describing succeed: write `{ref}_proxy` (the resolvedURL), then `{ref}` (key or placeholder, model ids, per-model params, and areserved `_endpoint` entry holding the label, the **redacted** URL and thekind — that JSON column is not encrypted), then register the models, then-broadcast. Otherwise nothing (D5).+broadcast. Otherwise nothing (D5). A write the credential store rejects fails+the save too, and a rejected `{ref}` write puts the `{ref}_proxy` row back as it+was.++### 6.5 Time budget++A save runs inside one WebSocket request, so every step after rooting is+bounded: the native routes 3 s (asked at once), the Ollama and LM Studio SDK+probes 10 s, and an on-demand LiteLLM fetch 8 s in total, not retried for 10+minutes after a failure. The worst case is about 33 s; the client waits 60 s+(`CREDENTIAL_PROBE_REQUEST_TIMEOUT`) for `validate_api_key`, so a slow save is+not cut off and then completed behind the user's back.## 7. Credential resolution@@ -283,8 +295,9 @@ are issued without a resolved key.`split_provider_ref(ref) -> (name, slug)` is the only parser. The slug comesfrom the label via `python-slugify` (`[a-z0-9-]`, at most 24 characters, so`openai_compatible:<slug>_proxy` fits the 50-character provider column), or-from the URL's host and port when no label is given. An existing label is-rejected, not auto-suffixed.+from the URL's host and port when no label is given (never the whole network+location, which can carry a username and password; a URL with no host and no+label is refused). An existing label is rejected, not auto-suffixed.The reference is keyed like any provider, which is why endpoints do not use theDiscord `session_id` scoping: every LLM key lookup in the tree is keyed by@@ -323,6 +336,17 @@ with no URL row ("not configured") rather than let the SDK default toapi.openai.com. The client cache already keys on the URL and the keyfingerprint, so two endpoints never share a client unless they share both.+A removed or never-chosen endpoint usually shows up earlier, as a missing key:+saving always stores one, so its absence means the rows are gone. Wherever it+is found first, the user gets the same words from+`endpoints.py::unconfigured_endpoint_message` ("The OpenAI-compatible endpoint+'<slug>' is not configured", or "Choose an OpenAI-compatible endpoint" for the+bare id): the in-process agents and chat model raise it as a `NodeUserError`,+the Temporal activities as a non-retryable `MissingAgentProviderCredential`.+The workflow validator's MISSING_CREDENTIAL asks `Credential.is_configured`+with the node's parameters, so an endpoint node is checked against the+endpoint it names, not the bare id, which never holds a row.+### 8.4 Alignment (D17)| LiteLLM | OpenRouter | Here |@@ -383,7 +407,10 @@ that would have made the original bug self-diagnosing.Every failure logs `url` (redacted by `redact_url`: no userinfo, query orfragment) and `url_source` (`proxy`, `llm_defaults` or `sdk_default`, recorded-by `OpenAIProvider` when it is built). The key is never logged. Per the repo's+by `OpenAIProvider` when it is built), under the provider reference the call+was made with. The unifier logs before deciding whether to translate the+error, so agent steps, which take it untranslated to keep its structure, log it+too. The key is never logged. Per the repo's`NodeUserError` contract, a routing or credential failure is user-correctable:one WARN line, no traceback.@@ -451,8 +478,8 @@ key on the LM Studio row with LM Studio's own placeholder.| AG17 | `openai_compatible` is registered once, `OpenAIProvider`, no `base_url` | `tests/llm/test_provider_self_registration.py` || AG18 | Refresh keeps local models; caches under DATA_DIR only; LiteLLM trimming and matching | `tests/services/test_model_registry_caches.py` || AG19 | Every agent `provider` field is loader-driven and offers every registered provider except the bare endpoint id | `tests/llm/test_plugin_shape.py` |-| AG20 | RLM refuses a provider it cannot route; the node, loaders and `ProviderRef` validation | `tests/nodes/test_openai_compatible_node.py` |-| FE | The endpoint list renders rows and hands the clicked row back | `client/.../panels/__tests__/EndpointList.test.tsx` |+| AG20 | RLM refuses a provider it cannot route, as its own or a connected chat model's; the node, loaders and `ProviderRef` validation | `tests/nodes/test_openai_compatible_node.py` |+| FE | The endpoint list renders rows and hands the clicked row back; the panel's add, refresh and remove payloads and the probe budget | `client/.../panels/__tests__/EndpointList.test.tsx`, `ApiKeyPanel.test.tsx` |AG5 (three verdict states rendered) is retired with D4.@@ -490,7 +517,11 @@ Servers the user runs:**RLM** builds its own clients from `services/rlm/constants.py` for sixproviders and never reads a user base URL, so it cannot use a local server ora named endpoint. It now refuses such a provider with a clear message instead-of sending the request to api.openai.com; routing it properly is separate work.+of sending the request to api.openai.com, both as the agent's own provider and+as a chat model connected to it (whose provider comes from+`detect_ai_provider`: chat-model nodes carry no `provider` field, and reading+one sent every connected chat model to the OpenAI backend). Routing it properly+is separate work.## 16. Referencesdiff --git a/docs-internal/frontend_architecture.md b/docs-internal/frontend_architecture.mdindex af3826f5..99f9b403 100644--- a/docs-internal/frontend_architecture.md+++ b/docs-internal/frontend_architecture.md@@ -361,7 +361,7 @@ components/credentials/CredentialsModal.tsx- **idb-keyval** cache seeds first paint — opened modal renders from IndexedDB in <50 ms before the WS roundtrip completes.- **`requestIdleCallback`** writes back to IDB so saves don't block first paint.- **DB is the single source of truth.** The retired `providers.tsx` static fallback is gone — `useCatalogueQuery` is the only source. Cold-boot with no IDB cache renders a `<Skeleton>` palette while the WS catalogue arrives; server-unreachable shows an explicit error state, never stale fallback data.-- **`provider.stored` is the canonical "do we have a credential for X?".** The retired `apiKeyStatuses[id].hasKey` mirror duplicated this answer with no synchronisation contract. Two new selector hooks (`useProviderStored(id)`, `useStoredProviderCount()`) read the catalogue. `apiKeyStatuses[id]` now narrowly carries the validation result (`valid`, `models`, `message`, `timestamp`).+- **`provider.stored` is the canonical "do we have a credential for X?".** The retired `apiKeyStatuses[id].hasKey` mirror duplicated this answer with no synchronisation contract. Two new selector hooks (`useProviderStored(id)`, `useStoredProviderCount()`) read the catalogue; `useStoredCredentialSignature()` adds each named endpoint and its model count, for re-fetches a count would miss (the toolbar's global model list). `apiKeyStatuses[id]` now narrowly carries the validation result (`valid`, `models`, `message`, `timestamp`).**App-wide query persistence ([client/src/lib/queryPersist.ts](../client/src/lib/queryPersist.ts)):** the QueryClient is wrapped in `<PersistQueryClientProvider>` ([main.tsx](../client/src/main.tsx)) with a localStorage persister + `__APP_VERSION__` buster + 24h SWR window. Only queries with key prefixes `nodeSpec` / `nodeGroups` are dehydrated -- high-frequency / per-session queries stay in-memory. Hard refresh paints from cached specs **before** the WebSocket connects, so canvas nodes never flash placeholder icons. The credentials catalogue uses its own dedicated `idb-keyval` warm-start (above) because its payload is large enough that localStorage's 5-10MB cap is a real constraint. **Decrypted credential values are NOT persisted** (was the retired `'credentialValues'` prefix) per OWASP HTML5 Security Cheat Sheet / ASVS V9.9 — plaintext API keys in `localStorage` are readable via DevTools on shared / compromised browsers; the in-memory TanStack Query cache (`gcTime: ∞`) keeps the form populated for the session lifetime, on reload the panel refetches via WS.diff --git a/docs-internal/native_llm_sdk.md b/docs-internal/native_llm_sdk.mdindex ec891f35..3e6a9bc7 100644--- a/docs-internal/native_llm_sdk.md+++ b/docs-internal/native_llm_sdk.md@@ -74,7 +74,7 @@ user-named endpoints, each its own provider reference `openai_compatible:<slug>`| `deepseek` | `providers/_compat.py` + base_url | `openai` | OpenAI-compatible at `api.deepseek.com` (root-mounted, no `/v1`) || `kimi` | `providers/_compat.py` + base_url | `openai` | Moonshot AI, OpenAI-compatible || `mistral` | `providers/_compat.py` + base_url | `openai` | OpenAI-compatible |-| `ollama` | `providers/_compat.py` + `{provider}_proxy` URL | `openai` (chat) + `ollama` (probe) | Local server. Saving roots the URL through the OpenAI surface, then `ollama.AsyncClient.ps()` gives the typed `context_length` of each loaded model. Runtime uses `OpenAIProvider` with `base_url={resolved URL}` so traffic stays on `localhost`. |+| `ollama` | `providers/_compat.py` + `{provider}_proxy` URL | `openai` (chat) + `ollama` (probe) | Local server. Saving roots the URL through the OpenAI surface, then `ollama.AsyncClient.ps()` gives the typed `context_length` of each loaded model. Runtime passes the resolved URL to `OpenAIProvider` as `proxy_url` (it wins over the `llm_defaults.json` `base_url`), so traffic stays on `localhost`. || `lmstudio` | `providers/_compat.py` + `{provider}_proxy` URL | `openai` (chat) + `lmstudio` (probe) | Local server. Same save path; `lmstudio.AsyncClient.llm.list_loaded()` gives the typed `LlmInstanceInfo.context_length`. Same OpenAI-compat runtime path as Ollama. || `openai_compatible` | `providers/_compat.py` (no `base_url`) + one `{ref}_proxy` URL per endpoint | `openai` | Named endpoints: llama.cpp, vLLM, a LiteLLM proxy, a second Ollama host. Added in the Credentials Modal; see "Named OpenAI-compatible endpoints". || `groq` | `providers/_compat.py` + base_url | `openai` | OpenAI-compatible |@@ -135,7 +135,9 @@ Ollama and LM Studio expose an OpenAI-compatible `/v1` HTTP API, so they ride th- **LM Studio**: `lmstudio.AsyncClient.llm.list_loaded()` returns `AsyncModelHandle` per loaded model; `handle.get_info()` is a typed `LlmInstanceInfo` (`context_length`, `max_context_length`, `vision`, `trained_for_tool_use`, `architecture`, `params_string`, `format`).3. **Persist only on success**: `{provider}_proxy` gets the resolved URL, then `{provider}` gets the vendor's documented placeholder key (`auth.placeholder_key` in `llm_defaults.json`, resolved by `services/llm/config.py::resolve_credential`), the model list and `model_params`. The params are also registered with `model_registry.register_local_model()`, which keeps them apart from the OpenRouter snapshot and persists them under DATA_DIR (`local_models.json`), so the sync `get_context_length()` / `get_max_output_tokens()` lookups honour the **real n_ctx the server is currently serving**, an OpenRouter refresh cannot wipe them, and user model names never land in the tracked `config/model_registry.json`.-A failed save writes nothing and broadcasts nothing: a typo in a re-Fetch leaves a working configuration in force. **Both servers must have a model loaded** for the probe to return entries; "no models loaded" is a failed save.+A failed save writes nothing and broadcasts nothing: a typo in a re-Fetch leaves a working configuration in force. That includes a write the credential store rejects: a rejected key row puts the URL row back as it was. **Both servers must have a model loaded** for the probe to return entries; "no models loaded" is a failed save.++Every step after rooting is bounded so a save fits its WebSocket request: native routes 3 s (asked at once), the SDK probes 10 s, an on-demand LiteLLM fetch 8 s (not retried for 10 minutes after a failure). The client waits 60 s for `validate_api_key` (`CREDENTIAL_PROBE_REQUEST_TIMEOUT` in `WebSocketContext.tsx`), above the worst case of about 33 s.**Runtime path** — `ChatUnifier` reads `{provider}_proxy` and passes it to theregistered provider factory. `OpenAIProvider` uses it as `base_url` and sends@@ -155,7 +157,8 @@ Modal under **OpenAI-compatible** with a Base URL (with or without `/v1`), anoptional label and an optional key. No code. RFC-0003 D13–D17 is the contract.- **Identity.** Each endpoint is the provider reference- `openai_compatible:<slug>` (slug from the label, else from the host and port).+ `openai_compatible:<slug>` (slug from the label, else from the host and port,+ never from userinfo in the URL).It is stored exactly like Ollama: `{ref}` holds the key (or the placeholder`sk-no-key-required`), the model list and per-model params; `{ref}_proxy`holds the resolved URL. The reference travels as the ordinary `provider`@@ -163,8 +166,9 @@ optional label and an optional key. No code. RFC-0003 D13–D17 is the contract.everything read from `llm_defaults.json` or `pricing.json` resolves it to theshared `openai_compatible` block through `split_provider_ref`.- **Saving** runs the same path as Ollama, plus a one-time kind detection from- native routes by body shape (`/props` → llama.cpp, `/api/v1/models` → LM- Studio, `/api/version` → Ollama, else generic). Context and price come from the+ native routes by body shape, asked at once (`/props` → llama.cpp, which wins+ when several answer; `/api/v1/models` → LM Studio; `/api/version` → Ollama;+ else generic). Context and price come from theserver first (Ollama / LM Studio SDK probes, llama.cpp `/props` `n_ctx`, vLLM`max_model_len`), then — for generic servers only — LiteLLM's`model_prices_and_context_window.json` (fetched by `ModelRegistryService` on@@ -174,12 +178,19 @@ optional label and an optional key. No code. RFC-0003 D13–D17 is the contract.registered providers. The `openaiCompatibleChatModel` node picks one in its`endpoint` field — deliberately not `provider`, which would trigger theparameter panel's stored-key effect — and its `model` dropdown lists that- endpoint's models. The global default-model picker lists each endpoint too.+ endpoint's models; changing the endpoint moves the model to one the new+ endpoint serves. The global default-model picker lists each endpoint too.- **Removing** goes through `delete_api_key` with the reference, which alsoclears the URL row and the registered models. A workflow still pointing at a- removed endpoint fails with "not configured", never a call to OpenAI.+ removed endpoint fails with "The OpenAI-compatible endpoint '<slug>' is not+ configured" (`endpoints.py::unconfigured_endpoint_message`, on every path),+ never a call to OpenAI, and the workflow validator flags the node, because+ `Credential.is_configured` checks the endpoint the node names.+- **Failures** log the redacted URL and `url_source` under the endpoint's+ reference, on agent steps as well as direct chat.- **RLM** builds its own clients and cannot use an endpoint (or a local- server); it refuses one with a clear message.+ server); it refuses one with a clear message, whether it is the agent's+ provider or a chat model connected to it.## Provider Protocoldiff --git a/docs-internal/node-logic-flows/ai_chat_models/openaiCompatibleChatModel.md b/docs-internal/node-logic-flows/ai_chat_models/openaiCompatibleChatModel.mdindex dac61cc5..16e32956 100644--- a/docs-internal/node-logic-flows/ai_chat_models/openaiCompatibleChatModel.md+++ b/docs-internal/node-logic-flows/ai_chat_models/openaiCompatibleChatModel.md@@ -26,7 +26,7 @@ Chat with any OpenAI-compatible server the user has saved as a named endpoint un| `endpoint` | string | `""` | yes | - | The saved endpoint, as its reference `openai_compatible:<slug>`. Options from the `openaiCompatibleEndpoints` loader; rendered first || `prompt` | string | `""` | yes | - | User message || `system_prompt` | string | `""` | no | - | System prompt |-| `model` | string | `""` (first option) | no | - | Options from the `openaiCompatibleModels` loader: the models stored when the endpoint was saved or refreshed. Reloads when `endpoint` changes. Open-world: the name is not pattern-checked |+| `model` | string | `""` (first option) | no | - | Options from the `openaiCompatibleModels` loader: the models stored when the endpoint was saved or refreshed. Reloads when `endpoint` changes, and moves to the first model the new endpoint serves when the old one is not among them. Open-world: the name is not pattern-checked || `temperature` | number\|null | `null` | no | - | 0-2 || `max_tokens` | number\|null | `null` | no | - | 1-200000. Unset: the model's registered max output (a quarter of its context, 512-4096, when only the context is known), else 2048 || `top_p` | number\|null | `1.0` | no | - | |@@ -77,7 +77,7 @@ flowchart TD## Decision Logic-- **Provider routing**: `detect_ai_provider` recognises this node type before the `lmstudio` / `ollama` tokens and returns `parameters["endpoint"]`. With no endpoint chosen it returns the bare `openai_compatible`, which holds no key, so the run stops before any request is sent.+- **Provider routing**: `detect_ai_provider` recognises this node type before the `lmstudio` / `ollama` tokens and returns `parameters["endpoint"]`. With no endpoint chosen it returns the bare `openai_compatible`, which holds no key, so the run stops before any request is sent, asking the user to choose an endpoint.- **Base URL**: the URL resolved when the endpoint was saved (`services/llm/endpoints.py::resolve_base_url`); nothing is probed at call time. A call whose `{ref}_proxy` row is missing is refused instead of going to the SDK's default, api.openai.com.- **Key**: the stored key, or the declared placeholder `sk-no-key-required` (`auth.placeholder_key` in `llm_defaults.json`); never `None`, so the SDK never falls back to `OPENAI_API_KEY`.- **Open-world model name**: `openai_compatible` declares `open_world_models: true`, so `is_model_valid_for_provider` accepts any model id.@@ -102,7 +102,7 @@ flowchart TD- **The model list is a snapshot**: it is read when the endpoint is saved or refreshed. A model the server loads later appears only after Refresh in the Credentials panel.- **Sizing**: the kind is detected once at save time. An endpoint detected as Ollama or LM Studio is sized by their SDK probes, llama.cpp by `n_ctx` from `/props`; any other server by vLLM's `max_model_len` on the model list, then LiteLLM's model table by model id. Failing all of these the `openai_compatible` defaults apply (8192 context, 2048 output).-- **Removed endpoint**: a node that still names it has no key row, so the run fails before any request is sent. Pick another endpoint, or add it again.+- **Removed endpoint**: a node that still names it has no key row, so the run fails before any request is sent, with "The OpenAI-compatible endpoint '<slug>' is not configured", and the workflow validator flags the node (MISSING_CREDENTIAL checks the endpoint it names). Pick another endpoint, or add it again.- **Error boundary**: typed OpenAI SDK failures become user-safe `NodeUserError` values in `ChatUnifier`, which `BaseNode.execute()` turns into the standard failure envelope.## Relateddiff --git a/docs-internal/node-logic-flows/specialized_agents/rlm_agent.md b/docs-internal/node-logic-flows/specialized_agents/rlm_agent.mdindex 6bdebce4..e91dc560 100644--- a/docs-internal/node-logic-flows/specialized_agents/rlm_agent.md+++ b/docs-internal/node-logic-flows/specialized_agents/rlm_agent.md@@ -93,7 +93,9 @@ flowchart TD## External Dependencies- **Credentials**: `auth_service.get_api_key(<provider>)` for big LM, and- optionally the small-LM provider wired as a connected chat-model node.+ optionally the small-LM provider wired as a connected chat-model node. That+ node's provider comes from its type (or its `endpoint`), and one RLM cannot+ route (Ollama, LM Studio, a named endpoint) is refused like the agent's own.- **Services**: `RLMService`, `StatusBroadcaster`, `PricingService`.- **Python packages**: the `rlm` package plus the native OpenCompany LLMconfiguration and tool-bridge helpers.diff --git a/docs-internal/rlm_service.md b/docs-internal/rlm_service.mdindex 0f02196d..bdbcc764 100644--- a/docs-internal/rlm_service.md+++ b/docs-internal/rlm_service.md@@ -146,7 +146,7 @@ BackendAdapter.adapt("groq", "llama-3.3-70b-versatile", "gsk-...")### ChatModelExtractor-Scans `tool_data` (nodes connected to `input-tools`) for `AI_CHAT_MODEL_TYPES` nodes. Extracts their provider/model/api_key and converts via `BackendAdapter` into RLM's `other_backends` format.+Scans `tool_data` (nodes connected to `input-tools`) for `AI_CHAT_MODEL_TYPES` nodes. Takes each node's provider from `detect_ai_provider` (chat-model nodes carry no `provider` field: the type names it, or the `endpoint` parameter for an OpenAI-compatible node) plus its model and api_key, and converts them via `BackendAdapter` into RLM's `other_backends` format. A provider missing from the mapping above (Ollama, LM Studio, xAI, a named endpoint, ...) is refused with a clear error rather than sent to the OpenAI backend, since RLM never reads a user base URL.Currently RLM supports one `other_backend` (for depth>=1 calls). If multiple chat model nodes are connected, only the first is used.diff --git a/server/tests/llm/test_rfc0003_source_contract.py b/server/tests/llm/test_rfc0003_source_contract.pyindex 9f0f5ec4..eb8974bd 100644--- a/server/tests/llm/test_rfc0003_source_contract.py+++ b/server/tests/llm/test_rfc0003_source_contract.py@@ -24,7 +24,7 @@ V1_ALLOWED_FILES = {ENDPOINTS_PY}V1_ALLOWED_FUNCTIONS = {(LOCAL_VALIDATOR_PY, "_strip_v1_path")}# Keys in llm_defaults.json that nothing reads. Listed so a NEW dead key-# fails AG9; tracked for removal in RFC-0003 §12.+# fails AG9; tracked for removal in RFC-0003 §14.KNOWN_DEAD_JSON_KEYS = {"api_key_param", "max_tokens_param"}