Skip to content

LibreChat v0.8.8 connects to the assistant toolset with each person's own token - #237

Merged
zlareb1 merged 1 commit into
mainfrom
feat/i160-librechat
Nov 4, 2026
Merged

zlareb1 merged 1 commit into
mainfrom
feat/i160-librechat

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Related: #160

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

LibreChat v0.8.8 can serve as a chat client for Loom's assistant toolset: integrations/librechat/ holds a configuration in which each person's tool calls carry their own Loom viewer token, a local compose file, and a qualification harness. The guide lists what LibreChat stores and how it is deleted.

Why

Issue 160 asks for a qualified optional chat client next to the dashboard's deterministic Assistant page, and for a comparison on the same labeled cases. The comparison here is the same reads over HTTP with no model; the inventory, inspect and tune cases are the Assistant page's own reads, the memory cases use memory.search, which that page does not call. LibreChat v0.8.8 (MIT) supports streamable-HTTP MCP servers with per-user credentials, so a person's chat can read Loom through the assistant toolset under that person's own token, with no shared service token and no database credentials anywhere near the model. This PR ships that configuration, measures it against the direct Loom reads, and documents what LibreChat keeps, since Loom's erasure saga cannot reach it.

Scope and risk

  • New files: integrations/librechat/ (librechat.yaml, docker-compose.yml, .env.example, README.md, qualification/{qualify.py,cases.json,fixture.json}), docs/features/integrations/librechat.md, tests/unit/test_librechat_integration.py; one row each in docs/features/integrations/index.md and integrations/README.md; llms.txt regenerated for the new page; the assistant toolset row in docs/reference/mcp.md now lists memory.inspect and namespace.tune, which the roster serves.
  • No server, wire, schema or plugin change. Loom's authorization is unchanged; the integration relies on the assistant toolset as it is on main and on the token checked on every call.
  • Decisions:
    • Credential: customUserVars (LOOM_TOKEN) in an Authorization: Bearer {{LOOM_TOKEN}} header, not apiKey: {source: admin} (one key for everyone) and not {{LIBRECHAT_OPENID_ACCESS_TOKEN}} (needs a shared identity provider, not qualified here).
    • LibreChat memory off (memory.disabled: true, writes answer 403), Meilisearch, the RAG API and its vector database not deployed (SEARCH=false), sharing and user-created MCP servers off.
    • interface.retentionMode: all with generalChatRetention: 720: the UI path stores every tool call's full Loom result in messages.content[].tool_call.output, with no expiry by default.
    • remoteAgents (the agents API) on, because the harness drives it; the config comments how to turn it off.
    • The harness lives in integrations/librechat/qualification/, not bench/: it qualifies this client, is small, and is run by hand.
    • README step 1 starts Loom with LOOM_AUTH_REQUIRED=true LOOM_BIND_HOST=0.0.0.0 LOOM_PUBLIC_BASE_URL=http://host.docker.internal:7777 make server after writing a private LOOM_JWT_SECRET to .env and setting it to mode 0600: make server and loom serve bind loopback, a container reaches the host through the Docker bridge, and Loom refuses a non-loopback bind without LOOM_PUBLIC_BASE_URL or with the dev signing secret (server/boot.py). The same recipe was started on another port, answered /v1/health from a container through host.docker.internal, and refused /mcp without a token (401). The README says this exposes Loom on the host's other interfaces and names the bridge gateway as the narrower choice. Every step names its working directory: LibreChat's .env and compose project live in integrations/librechat (steps 2 and 3), so they never replace Loom's own, and step 4 mints with .venv/bin/loom back in the checkout under the secret step 1 wrote. The bind applies to Docker Engine on Linux, where the run was made; Docker Desktop was not tested. The file steps (the secret line, cp, the portable sed lines, chmod 600 on both files, checked with stat) and docker compose config were run in a scratch copy of the checkout. The prerequisites point at CONTRIBUTING.md's development setup.
  • Residual risk, stated in the guide: LibreChat holds every person's Loom token encrypted with one deployment key (CREDS_KEY); short --ttl-days viewer tokens bound it.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none for Loom. Using LibreChat is opt-in and needs Loom serving ?toolset=assistant on every replica.
  • Rollback: revert; nothing persists in Loom.

Tests

  • pytest tests/unit/test_librechat_integration.py (31 tests: a table for score, native_score, check_citations and pct with a leaking answer, wrong and near-miss counts, the old rate limit, a non-zero tune answer, a stale cited version, a two-key citation and a repeated key whose second version is stale; a cancel-probe row without a first token; the direct path sending the assistant toolset's forced memory.search arguments; the count labels checked against fixture.json; and the MCP entry uses the assistant toolset and a per-user token with no admin key, memory and sharing off, retention on, the compose file pins v0.8.8 and MongoDB by digest with no search service and no MongoDB host port, no credential committed, every case labeled against the fixture, harness --help runs offline), tests/unit/test_public_copy.py, tests/unit/test_doc_links.py, tests/unit/test_docs_reference.py; make format-check, make lint.

  • Qualification, one run: Loom from this branch with auth on (fake embedder, fake LLM provider in Loom), LibreChat v0.8.8 (registry.librechat.ai/librechat-ai/librechat:v0.8.8@sha256:5b706bce…) and MongoDB 8.0.20 in local containers, model claude-haiku-4-5-20251001 through LibreChat's agents API. Loom ran with LOOM_AUTH_REQUIRED=true, LOOM_EMBEDDING_MODEL=fake-ngram-1024, LOOM_LLM_PROVIDER=fake, LOOM_BACKGROUND_WORKERS=off. Reproduce with the commands in integrations/librechat/README.md.

  • Results (LibreChat = model through LibreChat; native = the same reads over HTTP with no model, memory.search with the assistant toolset's forced auto_touch: false and explain: false). The LibreChat answers are from one run, scored against the current cases.json by qualify.py rescore; citations are as checked during that run. The native side is from a later run --native-only on a fresh seed (no model, no LibreChat, no spend), after the baseline was changed to send the forced arguments; native correctness is unchanged and latency moved from p50 0.07 / p95 0.23 s to 0.08 / 0.24 s. The direct path cites the search hit itself, so its citations are reported as not checked:

    case kind LibreChat correct cited (invalid) tool calls latency s TTFT s native correct native s
    memory-freeze memory yes 1 (0) 1 3.2 0.6 yes 0.36
    memory-db-version memory yes 1 (0) 1 3.9 0.7 yes 0.08
    memory-oncall memory yes 1 (0) 1 3.1 0.6 yes 0.08
    memory-webhook-retries memory yes 1 (0) 2 4.5 0.6 yes 0.08
    memory-backups memory yes 1 (0) 1 2.6 0.6 yes 0.07
    memory-revised-rate-limit memory yes 1 (0) 1 3.0 0.5 yes 0.08
    inventory-count inventory yes 0 (0) 1 2.4 0.5 yes 0.04
    inventory-top-agent inventory yes 0 (0) 1 2.3 0.5 yes 0.04
    inspect-agent inspect yes 3 (0) 1 4.5 0.5 yes 0.19
    tune-drafts tune yes 0 (0) 1 3.2 0.6 yes 0.24
    cross-tenant refusal yes 0 (0) 1 3.1 0.5 yes 0.01
    revoked-token refusal yes 0 (0) 0 9.0 0.5 yes 0.01
    abstain-wifi abstain yes 0 (0) 1 3.4 0.5 yes 0.06
    abstain-cfo abstain yes 0 (0) 3 6.8 0.5 yes 0.08

    librechat: correct 14/14; citations 9/9 valid, expected key cited 6/6; abstained 2/2 where it should, 0 false abstentions; latency p50 3.18s p95 6.84s; TTFT p50 0.55s p95 0.58s; tool calls 16

    native: correct 14/14; citations -, expected key cited 6/6; abstained 2/2 where it should, 0 false abstentions; latency p50 0.08s p95 0.24s; TTFT p50 0.08s p95 0.24s; tool calls 14

    model claude-haiku-4-5-20251001: 394424 prompt + 2874 completion tokens, $0.409 at list price counting every prompt token; per answer mean $0.029, max $0.064
    cancel probe: first token 0.53 s, 0 Loom calls, 0 after the client disconnected

    Notes on the columns: TTFT is the first streamed delta, which is the model's one-line preamble before its first tool call, not the answer. The revoked case shows 0 tool calls because Loom refuses the MCP request at authentication, before a ledger row is written. p95 over 14 cases is close to the maximum.

    Cost: 394,424 prompt + 2,874 completion tokens for the 14 answers, $0.41 counting every prompt token at list price: mean $0.029 and max $0.064 per answer. The max (abstain-cfo, three searches before abstaining) misses the $0.05 per-answer target, and the guide says so. About 11,000 prompt tokens per model call are the assistant roster's 27 tool schemas and instructions.

  • Findings from the run (qualification findings, not worked around):

    • The agents API compresses its stream when the client accepts compression, and a compressed stream arrives only when the answer is complete (time to first token equalled total latency, 3.6 s, until the harness sent Accept-Encoding: identity; then 0.6 s). The chat UI path streams incrementally.
    • UI-path generation runs server-side apart from the browser connection: a started answer whose stream was never read still made its Loom call; POST /api/agents/chat/abort stopped one before any Loom call. On the agents API, disconnecting after the first token left 0 Loom calls in the next 20 s; that rests on one probe.
    • A revoked token: Loom answers the MCP POST with unauthenticated: token jti '…' is revoked; LibreChat retries the connection three times (the case took 9.0 s against a 3.2 s median), then the model reports the failure. LibreChat's log carries the token's jti, never the token.
    • A user who has not stored a token gets no connection and no Loom tools (missing_custom_user_vars), so a placeholder is never sent.
    • The cross-tenant case returned NAMESPACE_NOT_ACCESSIBLE to the model: it named only the other namespace, and the org came from the token. No canary text reached the answer. A call that also names the other org answers ORG_MISMATCH over MCP; that was not exercised, only its HTTP counterpart (AUTH_INSUFFICIENT, 403) on the direct path.
    • Limitation, stated in the guide and not tested: a follow-up in an existing chat sends the earlier tool outputs back to the model, which can answer from them after the token is revoked or a row erased. The guide says to delete those chats (or let retention expire them) and start new ones.
    • Agent sharing with another user was not exercised (sharing is off); from the source, LibreChat resolves customUserVars for the requesting user.
    • Every answer re-sends the 27 tool schemas; the roster's size, not the reads, sets the per-answer token cost.
  • LibreChat v0.8.8 facts verified against its source at tag v0.8.8 (commit e8f3be08623663d4ad7f7241e693c94469b63bb0) and at runtime:

    • customUserVars, apiKey.source, requiresOAuth, serverInstructions, startup: packages/data-provider/src/mcp.ts.
    • Placeholder resolution order (env vars before user values, {{VAR}} from customUserVars): packages/api/src/utils/env.ts (processSingleValue).
    • Per-user values read for the requesting user: packages/api/src/mcp/auth.ts (getUserMCPAuthMap); stored encrypted: api/server/services/PluginService.js (updateUserPluginAuth), set through POST /api/user/plugins (api/server/routes/user.js).
    • mcpSettings.allowedAddresses, interface.retentionMode / generalChatRetention / temporaryChatRetention, memory.disabled, interface.remoteAgents: packages/data-provider/src/config.ts, librechat.example.yaml.
    • TTL indexes on expiredAt: packages/data-schemas/src/schema/{message,convo,toolCall}.ts; log rotation 14 days: packages/data-schemas/src/config/winston.ts.
    • Account deletion cascade: api/server/controllers/UserController.js (deleteUserController); ALLOW_ACCOUNT_DELETION: api/server/middleware/canDeleteAccount.js.
    • The agents API: api/server/routes/agents/openai.js; the UI stream and abort: api/server/routes/agents/index.js; JWT routes refuse a non-browser user agent: api/server/middleware/uaParser.js.
    • License MIT: LICENSE. Images: registry.librechat.ai/librechat-ai/librechat:v0.8.8 (the upstream compose file uses :latest dev images).
  • Not covered here: a Postgres authority deployment, document questions (the fixture has none yet), load and multi-tenant fairness.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Every LibreChat claim was checked against the v0.8.8 source and, where marked, observed against running containers.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: llms.txt (python scripts/codegen/docs_reference.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (none)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (no plugin file changed)
  • The frontend builds and its tests pass, if frontend/ changed. (unchanged)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/i160-librechat branch 3 times, most recently from a32f105 to e0b4041 Compare November 4, 2026 00:37
… own token

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/i160-librechat branch from e0b4041 to 7f241ce Compare November 4, 2026 01:44
@zlareb1
zlareb1 merged commit eedec52 into main Nov 4, 2026
17 of 18 checks passed
@zlareb1
zlareb1 deleted the feat/i160-librechat branch November 4, 2026 01:46
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant