Browse Source

fix: respect user's default_agent config instead of overwriting (#176)

alvinreal 1 month ago
parent
commit
d3dd041d4a
3 changed files with 18 additions and 2 deletions
  1. 8 0
      oh-my-opencode-slim.schema.json
  2. 1 0
      src/config/schema.ts
  3. 9 2
      src/index.ts

+ 8 - 0
oh-my-opencode-slim.schema.json

@@ -5,6 +5,9 @@
     "preset": {
       "type": "string"
     },
+    "setDefaultAgent": {
+      "type": "boolean"
+    },
     "scoringEngineVersion": {
       "type": "string",
       "enum": [
@@ -377,6 +380,11 @@
           "type": "number",
           "minimum": 0
         },
+        "retryDelayMs": {
+          "default": 500,
+          "type": "number",
+          "minimum": 0
+        },
         "chains": {
           "default": {},
           "type": "object",

+ 1 - 0
src/config/schema.ts

@@ -151,6 +151,7 @@ export type FailoverConfig = z.infer<typeof FailoverConfigSchema>;
 // Main plugin config
 export const PluginConfigSchema = z.object({
   preset: z.string().optional(),
+  setDefaultAgent: z.boolean().optional(),
   scoringEngineVersion: z.enum(['v1', 'v2-shadow', 'v2']).optional(),
   balanceProviderUsage: z.boolean().optional(),
   manualPlan: ManualPlanSchema.optional(),

+ 9 - 2
src/index.ts

@@ -110,8 +110,15 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
     mcp: mcps,
 
     config: async (opencodeConfig: Record<string, unknown>) => {
-      (opencodeConfig as { default_agent?: string }).default_agent =
-        'orchestrator';
+      // Only set default_agent if not already configured by the user
+      // and the plugin config doesn't explicitly disable this behavior
+      if (
+        config.setDefaultAgent !== false &&
+        !(opencodeConfig as { default_agent?: string }).default_agent
+      ) {
+        (opencodeConfig as { default_agent?: string }).default_agent =
+          'orchestrator';
+      }
 
       // Merge Agent configs — per-agent shallow merge to preserve
       // user-supplied fields (e.g. tools, permission) from opencode.json