You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow an operator to run two Code API execution profiles concurrently and route the built-in code tools per agent:
Default profile: the existing HTTP/libkrun sandbox, with no AWS account, configuration, or runtime dependency.
Stateful profile: an opt-in AWS Lambda MicroVM deployment using affinity and a stable conversation session hint.
The existing LibreChat Stateful code sessions toggle should select the stateful profile. Agents without that opt-in must continue using the default HTTP profile.
This should be the first post-#16 product follow-up because it creates the routing boundary needed for session-scope controls, an ephemeral escape hatch, environment/image selection, and cost/quota policy.
Current behavior
PR #16 introduced a SandboxBackend seam, but each Code API process still selects one process-wide singleton through CODEAPI_SANDBOX_BACKEND=http|lambda-microvm.
Within a Lambda deployment, runtime_session_hint only selects between:
a warm stateful Lambda MicroVM, and
a fresh one-shot Lambda MicroVM.
It never selects the legacy HTTP/libkrun backend.
The Agents/LibreChat stateful toggle currently controls only whether runtime_session_hint is sent. The remote Code API base URL remains global. In mixed multi-agent runs, stateful enablement can also be promoted to run scope rather than remaining scoped to the agent that requested it.
Queued Code API jobs carry runtime-session mode and identity, but no backend/profile target. Therefore HTTP and Lambda workers cannot safely consume the same existing BullMQ queues: selection would be nondeterministic, and an HTTP worker correctly rejects a stateful job it cannot honor.
Desired behavior
agent.stateful_code_sessions != true
-> default Code API endpoint/profile
-> HTTP/libkrun worker pool
-> no AWS operational dependency
agent.stateful_code_sessions == true
-> stateful Code API endpoint/profile
-> Lambda MicroVM affinity worker pool
-> stable conversation-scoped runtime session hint
Code API remains the control-plane protocol in both cases. Lambda MicroVM is a sandbox backend behind one execution profile, not a replacement for Code API.
Recommended first slice
Use two isolated Code API deployments/worker queues and add a trusted, server-configured profile/endpoint selector in Agents + LibreChat:
Configure a default remote Code API profile and an optional stateful remote profile.
Make the Code API endpoint/transport injectable per agent/run instead of resolving one module-global remote base URL.
Derive the selected profile server-side from the admin capability and the agent's stateful_code_sessions setting. Do not accept an arbitrary model- or client-supplied URL.
Propagate the selected profile consistently through execute_code, bash_tool, file-authoring/read tools, background code execution, and agent handoffs.
Keep queues/worker pools isolated unless Code API later adds an explicit trusted backend target and backend-specific queues.
A future single-front-door hybrid router is possible, but is not required for the first useful version.
Cross-repository work
ClickHouse/code-interpreter: queue namespace/isolation support, profile-aware observability, and two-profile deployment documentation.
@librechat/agents: a trusted request/run-scoped Code API endpoint override propagated through every remote code-tool execution path.
LibreChat: configuration and capability gating, resolution for the agent actually executing the tool, and propagation through prewarm, file operations, background work, and handoffs.
Acceptance criteria
A normal installation can run the default HTTP/libkrun profile without AWS credentials, AWS resources, or Lambda configuration.
Operators can configure and run the HTTP and Lambda profiles concurrently.
Toggle off routes all code-session tools only to the default HTTP profile and sends no runtime-session hint.
Toggle on routes all code-session tools only to the Lambda profile and sends a stable conversation-scoped hint.
Selection is genuinely per agent. Two agents with different settings in the same graph/run do not promote one another to a shared execution profile.
Background executions and handoffs preserve the originating agent's selected profile.
If the stateful profile is not configured or healthy, the toggle is unavailable or the request fails clearly. It must not claim statefulness while using the default profile.
A request belonging to an established stateful workspace never silently falls back to HTTP. An explicit switch starts a fresh workspace and communicates that boundary.
Persisted/harvested artifacts can be supplied after an explicit profile transition; live workspace-only state is documented as non-portable.
Metrics/logs identify the selected execution profile and actual backend without exposing user-controlled high-cardinality values.
Summary
Allow an operator to run two Code API execution profiles concurrently and route the built-in code tools per agent:
The existing LibreChat Stateful code sessions toggle should select the stateful profile. Agents without that opt-in must continue using the default HTTP profile.
This should be the first post-#16 product follow-up because it creates the routing boundary needed for session-scope controls, an ephemeral escape hatch, environment/image selection, and cost/quota policy.
Current behavior
PR #16 introduced a
SandboxBackendseam, but each Code API process still selects one process-wide singleton throughCODEAPI_SANDBOX_BACKEND=http|lambda-microvm.Within a Lambda deployment,
runtime_session_hintonly selects between:It never selects the legacy HTTP/libkrun backend.
The Agents/LibreChat stateful toggle currently controls only whether
runtime_session_hintis sent. The remote Code API base URL remains global. In mixed multi-agent runs, stateful enablement can also be promoted to run scope rather than remaining scoped to the agent that requested it.Queued Code API jobs carry runtime-session mode and identity, but no backend/profile target. Therefore HTTP and Lambda workers cannot safely consume the same existing BullMQ queues: selection would be nondeterministic, and an HTTP worker correctly rejects a stateful job it cannot honor.
Desired behavior
Code API remains the control-plane protocol in both cases. Lambda MicroVM is a sandbox backend behind one execution profile, not a replacement for Code API.
Recommended first slice
Use two isolated Code API deployments/worker queues and add a trusted, server-configured profile/endpoint selector in Agents + LibreChat:
stateful_code_sessionssetting. Do not accept an arbitrary model- or client-supplied URL.execute_code,bash_tool, file-authoring/read tools, background code execution, and agent handoffs.A future single-front-door hybrid router is possible, but is not required for the first useful version.
Cross-repository work
Acceptance criteria
Non-goals for v1
Follow-ups enabled by this seam
Related work