diff --git a/ui/src/components/AgentConfigForm.render.test.tsx b/ui/src/components/AgentConfigForm.render.test.tsx
index 3e851cbe1c5..a8126b20fcc 100644
--- a/ui/src/components/AgentConfigForm.render.test.tsx
+++ b/ui/src/components/AgentConfigForm.render.test.tsx
@@ -398,6 +398,7 @@ describe("AgentConfigForm environment selector", () => {
expect(result.container.textContent).toContain("Advanced runtime");
expect(result.container.textContent).toContain("runtime adapter fields");
+ expect(runtime?.compareDocumentPosition(environment as Node) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(runtime?.textContent).not.toContain("Environment variables");
expect(runtime?.textContent).not.toContain("Working directory (deprecated)");
expect(environment?.parentElement?.textContent).toContain("Environment variables");
diff --git a/ui/src/components/AgentConfigForm.tsx b/ui/src/components/AgentConfigForm.tsx
index 76bc4011347..99bc1f75eeb 100644
--- a/ui/src/components/AgentConfigForm.tsx
+++ b/ui/src/components/AgentConfigForm.tsx
@@ -1091,104 +1091,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
)}
- {/* ---- Execution ---- */}
- {configurationShell && sectionVisible("environment") ? (
-
@@ -1563,6 +1465,104 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
)}
+ {/* ---- Execution ---- */}
+ {configurationShell && sectionVisible("environment") ? (
+
+ ) : null}
+ {sectionVisible("environment") && (forcedKubernetes ? (
+ // Instance execution policy forces the managed Kubernetes sandbox
+ // (executionMode=kubernetes): never offer local / non-Kubernetes targets.
+ // Render the environment read-only instead of the selectable picker.
+
+ {cards
+ ?
Environment
+ :
Environment
+ }
+
+
+ {kubernetesEnvironment ? (
+
+ {kubernetesEnvironment.name} · Kubernetes sandbox
+
+ ) : (
+
+ This instance requires the Kubernetes sandbox, but no managed Kubernetes
+ environment is available for this company yet. Configure one before creating
+ agents; execution will not fall back to local.
+
+ )}
+
+
+
+ ) : showEnvironmentOverrideControl ? (
+
+ {cards
+ ?
Environment
+ :
Environment
+ }
+
+
+
+ {
+ const nextValue = event.target.value;
+ if (isCreate) {
+ set!({ defaultEnvironmentId: nextValue });
+ return;
+ }
+ mark("identity", "defaultEnvironmentId", nextValue || null);
+ }}
+ >
+ Default: {inheritedEnvironmentLabel}
+ {environmentOptions.map((environment) => (
+
+ {environment.name} · {environment.driver}
+
+ ))}
+
+
+
+
+
+ ) : null)}
+
+ {configurationShell && sectionVisible("environment") && isLocal && (
+
+
+ )
+ : eff("adapterConfig", "env", (config.env ?? EMPTY_ENV) as Record)
+ }
+ secrets={availableSecrets}
+ userSecretDefinitions={userSecretDefinitions}
+ onCreateSecret={async (name, value) => createSecret.mutateAsync({ name, value })}
+ onChange={(env) =>
+ isCreate
+ ? set!({ envBindings: env ?? {}, envVars: "" })
+ : mark("adapterConfig", "env", env)
+ }
+ />
+
+ {!isCreate && (
+
+
+
+ )}
+
+ )}
+
{/* ---- Run Policy ---- */}
{sectionVisible("schedule") && (isCreate && showCreateRunPolicySection ? (
diff --git a/ui/src/components/agent-configuration-shell.test.ts b/ui/src/components/agent-configuration-shell.test.ts
index c1f061c756b..5abd7232382 100644
--- a/ui/src/components/agent-configuration-shell.test.ts
+++ b/ui/src/components/agent-configuration-shell.test.ts
@@ -8,7 +8,7 @@ import {
describe("agent configuration shell", () => {
it("matches both section names and field labels", () => {
- expect([...filterAgentConfigurationSections("")].slice(0, 2)).toEqual(["environment", "runtime"]);
+ expect([...filterAgentConfigurationSections("")].slice(0, 2)).toEqual(["runtime", "environment"]);
expect([...filterAgentConfigurationSections("heartbeat")]).toEqual(["schedule"]);
expect([...filterAgentConfigurationSections("API Keys")]).toEqual(["keys"]);
expect([...filterAgentConfigurationSections("sandbox")]).toEqual(["danger"]);
diff --git a/ui/src/components/agent-configuration-shell.tsx b/ui/src/components/agent-configuration-shell.tsx
index 4ef25d41cd3..f0e9824faa8 100644
--- a/ui/src/components/agent-configuration-shell.tsx
+++ b/ui/src/components/agent-configuration-shell.tsx
@@ -20,8 +20,8 @@ export const agentConfigurationSections: ReadonlyArray<{
instant?: boolean;
fields: string[];
}> = [
- { id: "environment", label: "Environment", fields: ["execution environment", "environment override", "variables", "secrets"] },
{ id: "runtime", label: "Runtime", fields: ["adapter", "model", "effort", "turns", "command", "arguments", "engine", "timeout", "chrome"] },
+ { id: "environment", label: "Environment", fields: ["execution environment", "environment override", "variables", "secrets"] },
{ id: "schedule", label: "Schedule & Runs", fields: ["heartbeat", "wake on demand", "cooldown", "concurrent runs", "continuation"] },
{ id: "access", label: "Access & Governance", instant: true, fields: ["trust preset", "boundary", "create agents", "create skills", "assign tasks"] },
{ id: "keys", label: "API Keys", instant: true, fields: ["credentials", "create key", "revoke key"] },
diff --git a/ui/src/pages/AgentDetail.tsx b/ui/src/pages/AgentDetail.tsx
index ecee10502c0..42a44e51002 100644
--- a/ui/src/pages/AgentDetail.tsx
+++ b/ui/src/pages/AgentDetail.tsx
@@ -1779,11 +1779,11 @@ function AgentConfigurePage({
});
const effectiveChips: Array<{ label: string; value: string; section: AgentConfigurationSectionId; inherited?: boolean }> = [
- { label: "Environment", value: effectiveConfig.environment, section: "environment", inherited: effectiveConfig.environmentInherited },
- { label: "Variables", value: String(effectiveConfig.environmentVariableCount), section: "environment" },
{ label: "Adapter", value: effectiveConfig.adapter, section: "runtime" },
{ label: "Model", value: effectiveConfig.model, section: "runtime", inherited: effectiveConfig.modelInherited },
{ label: "Cost saver", value: effectiveConfig.cheapModel, section: "runtime", inherited: effectiveConfig.cheapInherited },
+ { label: "Environment", value: effectiveConfig.environment, section: "environment", inherited: effectiveConfig.environmentInherited },
+ { label: "Variables", value: String(effectiveConfig.environmentVariableCount), section: "environment" },
{ label: "Heartbeat", value: effectiveConfig.cadence, section: "schedule" },
{ label: "Trust", value: effectiveConfig.trust, section: "access" },
{ label: "API keys", value: String(effectiveConfig.apiKeyCount), section: "keys" },