🗿 feat: Add Attached Stateful Code Environments (#15352)

* feat: add attached stateful code environments

* fix: include code environment in lazy agent type

* fix: harden stateful environment routing

* fix: complete code environment route isolation

* fix: declare code environment map type

* fix: preserve configured code execution routes

* fix: harden stateful environment updates

* test: assert route-scoped sandbox readiness

* fix: harden stateful environment lifecycle

* fix: isolate migrated code sessions

* test: assert route-qualified code sessions
This commit is contained in:
Danny Avila 2026-08-30 15:38:45 -04:00 committed by GitHub
parent dc77b78d3e
commit c1cb591d49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
59 changed files with 1433 additions and 103 deletions

View file

@ -785,6 +785,8 @@ async function loadToolDefinitionsWrapper({
enabledCapabilities.has(AgentCapabilities.stateful_code_sessions) &&
agent.stateful_code_sessions === true,
environment: agent.stateful_code_environment,
environmentId: agent.code_environment_id,
environments: req.config?.endpoints?.agents?.statefulCodeSessions?.environments,
userId: req.user.id,
agentId: agent.id,
conversationId: runtimeRequestBody?.conversationId,
@ -1392,6 +1394,7 @@ async function loadToolDefinitionsWrapper({
agentResourceType,
codeApiBaseUrl: resolvedCodeExecutionContext.baseUrl,
executionProfile: resolvedCodeExecutionContext.executionProfile,
executionRouteKey: resolvedCodeExecutionContext.executionRouteKey,
});
if (toolContext) {
dynamicToolContextMap[Tools.execute_code] = toolContext;
@ -1642,6 +1645,8 @@ async function loadAgentTools({
resolveCodeExecutionContext({
statefulSessions: statefulCodeSessions,
environment: agent.stateful_code_environment,
environmentId: agent.code_environment_id,
environments: req.config?.endpoints?.agents?.statefulCodeSessions?.environments,
userId: req.user.id,
agentId: agent.id,
conversationId: requestBody?.conversationId ?? req.body?.conversationId,
@ -2022,6 +2027,8 @@ async function loadToolsForExecution({
const codeExecutionContext = resolveCodeExecutionContext({
statefulSessions: statefulCodeSessions,
environment: agent?.stateful_code_environment,
environmentId: agent?.code_environment_id,
environments: req.config?.endpoints?.agents?.statefulCodeSessions?.environments,
userId: req.user.id,
agentId: agent?.id,
conversationId: conversationId ?? runtimeRequestBody?.conversationId,