Skip to content

The open-source app everyone uses to manage agents at work

fix(server): preserve adapter-agnostic keys when changing adapter type

Cody (Radius Red)ce8d9eb3234f
diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts
index 2ad85e6313..c2cacfe492 100644
--- a/server/src/routes/agents.ts
+++ b/server/src/routes/agents.ts
@@ -1772,6 +1772,18 @@ export function agentRoutes(db: Db) {
rawEffectiveAdapterConfig = { ...existingAdapterConfig, ...requestedAdapterConfig };
}
if (changingAdapterType) {
+ // Preserve adapter-agnostic keys (env, cwd, etc.) from the existing config
+ // when the adapter type changes. Without this, a PATCH that includes
+ // adapterConfig but omits these keys would silently drop them.
+ const ADAPTER_AGNOSTIC_KEYS = [
+ "env", "cwd", "timeoutSec", "graceSec",
+ "promptTemplate", "bootstrapPromptTemplate",
+ ] as const;
+ for (const key of ADAPTER_AGNOSTIC_KEYS) {
+ if (rawEffectiveAdapterConfig[key] === undefined && existingAdapterConfig[key] !== undefined) {
+ rawEffectiveAdapterConfig = { ...rawEffectiveAdapterConfig, [key]: existingAdapterConfig[key] };
+ }
+ }
rawEffectiveAdapterConfig = preserveInstructionsBundleConfig(
existingAdapterConfig,
rawEffectiveAdapterConfig,