🛁 feat: Apply Host Provider-Text Protection to Remote SDK Runs (#18240)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Backend Unit Tests / backend (push) Blocked by required conditions
Channel Gateway / gateway (push) Waiting to run
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Frontend Unit Tests / frontend (push) Blocked by required conditions
Playwright E2E Tests / Codegraph select (push) Waiting to run
Playwright E2E Tests / Shard timings (push) Waiting to run
Playwright E2E Tests / e2e () (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 1) (push) Blocked by required conditions
Playwright E2E Tests / MCP list_changed (replica count 2) (push) Blocked by required conditions
Playwright E2E Tests / MCP Apps (browser and server) (push) Waiting to run
Playwright E2E Tests / e2e (push) Blocked by required conditions
Playwright Shard Timings / Record shard timings (push) Waiting to run

* feat: bridge host provider-text policy to remote SDK runs

* build: consume published agents 4.2.7 for remote policy services
This commit is contained in:
Danny Avila 2026-11-16 22:37:13 -05:00 • committed by GitHub
parent 62fd38813e
commit 2b828ca2c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 870 additions and 35 deletions

View file

@ -130,3 +130,17 @@ Run `npm run test:cache-integration:sdk --workspace=@librechat/api` against loca
fault-injection tests, and the Redis Playwright lane's `remote-sdk-recovery.spec.ts` for a real
LibreChat custom-graph approval, wire outage, reconnection and saved-history test. Set
`SDK_RUNTIME_RECOVERY=true` for `benchmark.cjs` to include Redis journal overhead.
## Protected provider-text benchmark
With SDK 4.2.7 and this bridge on both sides, run
`SDK_BENCHMARK_PROTECTION=true node examples/sdk-runtime/benchmark.cjs` against the
example worker. Add `SDK_RUNTIME_RECOVERY=true` to include Redis recovery. Both
local and remote executions use the same deterministic pass-through output policy;
the remote path adds host inspection through the SDK contract. This benchmark does
not implement a production PII detector or enable protected saved-agent chat.
See [host provider-text services](../../docs/sdk/agents.md#host-provider-text-service)
for admission ownership, encrypted journal payloads, and the remaining model/input
policy guards. The existing factories retain `input.config`, including the new
provider-text protection adapter, for both the minimal and custom-graph examples.

View file

@ -4,6 +4,7 @@ const { Run, Providers } = require('@librechat/agents');
const { AIMessageChunk, HumanMessage } = require('@librechat/agents/langchain/messages');
const { tool } = require('@librechat/agents/langchain/tools');
const { FakeChatModel } = require('@langchain/core/utils/testing');
const { ChatGenerationChunk } = require('@langchain/core/outputs');
const {
Annotation,
StateGraph,
@ -89,6 +90,15 @@ async function createExampleRun(input, { complex = true, stepDelayMs = 0 } = {})
},
],
});
model._streamResponseChunks = async function* (messages) {
const { generations } = await this._generate(messages);
for (const generation of generations) {
yield new ChatGenerationChunk({
...generation,
text: typeof generation.message.content === 'string' ? generation.message.content : '',
});
}
};
run.Graph.overrideModel = model;
}
if (complex) {

View file

@ -1,10 +1,34 @@
const { performance } = require('node:perf_hooks');
const { randomUUID } = require('node:crypto');
const { GraphEvents, Providers } = require('@librechat/agents');
const {
GraphEvents,
Providers,
ProviderTextAdmission,
createHostProviderTextService,
} = require('@librechat/agents');
const { HumanMessage } = require('@librechat/agents/langchain/messages');
const { createRemoteSdkRun } = require('@librechat/api/sdk');
const { createExampleRun } = require('./agent.cjs');
const protectedOutput = process.env.SDK_BENCHMARK_PROTECTION === 'true';
const admission = new ProviderTextAdmission({
maxConcurrentInspections: 4,
maxBufferedBytes: 4194304,
});
// A deterministic pass-through policy measures bridge cost, not production PII detection.
const policy = {
version: 1,
timeoutMs: 10000,
maxAttemptBytes: 1048576,
maxBufferedBytes: 4194304,
classify: () => 'prose',
inspect: ({ content }) => ({
version: 1,
ok: true,
value: { content, replacements: 0, categories: [] },
}),
};
async function measure(remote) {
const identity = {
runtimeId: process.env.SDK_RUNTIME_ID || 'remote-example',
@ -17,6 +41,7 @@ async function measure(remote) {
const started = performance.now();
const config = {
runId: identity.runId,
...(protectedOutput && { providerTextProtection: policy }),
returnContent: true,
tokenCounter: () => 1,
customHandlers: {
@ -36,6 +61,16 @@ async function measure(remote) {
? await createRemoteSdkRun({
config,
identity,
...(protectedOutput && {
hostServices: {
providerText: createHostProviderTextService({
identity,
policy,
admission,
inspectionTimeoutMs: 5000,
}),
},
}),
remote: {
url: process.env.SDK_RUNTIME_URL || 'ws://127.0.0.1:8804/sdk',
secret: process.env.SDK_RUNTIME_SECRET || '',
@ -74,6 +109,7 @@ async function main() {
JSON.stringify(
{
mode: 'deterministic custom graph, five warm samples',
protectedOutput,
local,
remote,
median: {