Programmatic Tool Calling replay reuses one CodeAPI executionId across multiple stateless MicroVM iterations. The stateless MicroVM client token was derived only from the execution ID and launch configuration.
After LibreChat returned an MCP result, CodeAPI persisted it to Redis and launched the next replay iteration with an updated sandbox payload containing _ptc_history.json. Because the launch configuration was unchanged, the worker reused the prior AWS clientToken.
AWS rejected the second launch with:
The provided clientToken was used with different request parameters.
This caused LibreChat to report the generic Bash programmatic execution failed: Code execution failed.
I made a change that includes the sandbox request body in the stateless client-token fingerprint. Each replay iteration now receives a distinct token when its replay payload changes, while identical requests remain deterministic for idempotency.
I added to lamda-microvm.ts and calling it in the VM launch of executeStateless:
function statelessLaunchClientToken(
executionId: string,
config: LambdaMicrovmBackendConfig,
maxDurationSeconds: number,
request: SandboxTransportRequest,
): string {
const requestFingerprint = JSON.stringify({
imageArn: config.imageArn,
imageVersion: config.imageVersion,
executionRoleArn: config.executionRoleArn,
logGroup: config.logGroup,
ingressConnectorArns: config.ingressConnectorArns,
egressConnectorArns: config.egressConnectorArns,
maximumDurationSeconds: maxDurationSeconds,
body: request.body,
});
const suffix = createHash('sha256').update(requestFingerprint, 'utf8').digest('hex').slice(0, 16);
return `exec-${executionId}-${suffix}`;
}
Programmatic Tool Calling replay reuses one CodeAPI
executionIdacross multiple stateless MicroVM iterations. The stateless MicroVM client token was derived only from the execution ID and launch configuration.After LibreChat returned an MCP result, CodeAPI persisted it to Redis and launched the next replay iteration with an updated sandbox payload containing
_ptc_history.json. Because the launch configuration was unchanged, the worker reused the prior AWSclientToken.AWS rejected the second launch with:
This caused LibreChat to report the generic
Bash programmatic execution failed: Code execution failed.I made a change that includes the sandbox request body in the stateless client-token fingerprint. Each replay iteration now receives a distinct token when its replay payload changes, while identical requests remain deterministic for idempotency.
I added to
lamda-microvm.tsand calling it in the VM launch ofexecuteStateless: