Browse Source

refactor: use name-based lookup instead of positional index for orchestrator def

Greptile PR #332 review: agentDefs[0] assumes orchestrator is always
first. Use .find() for resilience against ordering changes.
ReqX 3 months ago
parent
commit
fdd10abe9d
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/index.ts

+ 4 - 2
src/index.ts

@@ -569,10 +569,12 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
         );
         if (!alreadyInjected) {
           // Prepend the orchestrator prompt to the system array.
-          // agentDefs[0] is always the orchestrator — use its resolved prompt
+          // Use the resolved prompt from the orchestrator agent definition
           // (which includes any custom replacement or append from orchestrator.md / orchestrator_append.md)
           // Fall back to buildOrchestratorPrompt only if the resolved prompt is missing.
-          const orchestratorDef = agentDefs[0];
+          const orchestratorDef = agentDefs.find(
+            (a) => a.name === 'orchestrator',
+          );
           const orchestratorPrompt =
             typeof orchestratorDef?.config?.prompt === 'string'
               ? orchestratorDef.config.prompt