🪀 fix: Separate Workspace Admission and Transport Budgets (#16728)

* fix: Separate workspace admission and transport budgets

* fix: Validate workspace run reserves and retry test types

---------

Co-authored-by: Lia <lia@librechat.ai>
This commit is contained in:
lia-by-librechat[bot] 2026-10-03 21:22:30 -04:00 • committed by GitHub
parent 6298bfc920
commit 5674faaa01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 712 additions and 160 deletions

View file

@ -1308,3 +1308,55 @@ describe('createAttachedWorkspaceBashTool', () => {
]);
});
});
describe('attached command admission configuration', () => {
test('bounds the advertised command ceiling by the shorter overall run budget', () => {
expect(
resolveAttachedWorkspaceCommandTimeoutMax({
limits: {
maxCommandTimeoutMs: 100_000,
maxRequestTimeoutMs: 100_000,
maxRunTimeoutMs: 65_000,
},
}),
).toBe(45_000);
});
test('passes separate run and retry policies through the actual tool invocation', async () => {
const admission = {
queueWaitMs: 60_000,
initialDelayMs: 1_000,
maxDelayMs: 30_000,
multiplier: 2,
jitterRatio: 0.2,
};
const fetchImpl = jest.fn<ReturnType<CodeBridgeFetch>, Parameters<CodeBridgeFetch>>(
async () =>
new Response(
JSON.stringify({
protocolVersion: 1,
operation: 'execute_command',
workspaceId: 'primary',
exitCode: 0,
stdout: 'ready',
stderr: '',
timedOut: false,
truncated: false,
}),
),
);
const bash = createAttachedWorkspaceBashTool({
baseUrl: 'https://code.example/v1',
authHeaders: () => ({}),
workspaceId: 'primary',
fetchImpl,
maxRequestTimeoutMs: 100_000,
maxRunTimeoutMs: 180_000,
admission,
});
await bash.invoke({ command: 'echo ready' });
expect(
new Headers(fetchImpl.mock.calls[0][1]?.headers).get('X-LibreChat-Workspace-Queue-Wait-Ms'),
).toBe('60000');
});
});