diff options
Diffstat (limited to 'modules/core/module-orchestrator.js')
| -rw-r--r-- | modules/core/module-orchestrator.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/core/module-orchestrator.js b/modules/core/module-orchestrator.js index b3b76cd..5e03b0b 100644 --- a/modules/core/module-orchestrator.js +++ b/modules/core/module-orchestrator.js @@ -1153,6 +1153,10 @@ class OrchestratorModule { // Single sub-task — fall through to normal path } + // Declared in function scope: the AI branch assigns it, but the return at the end of + // this method runs even when that branch never did. + let outboxResult = null; + // Find an idle agent and immediately stamp it busy (atomic claim) let agent = Object.values(this._agents).find(a => a.status === 'idle'); if (agent) { @@ -1241,7 +1245,7 @@ class OrchestratorModule { this.terminal.print(`✅ ${agent.id} completed task`, 'success'); // Return result for callers that await delegateTask - const outboxResult = typeof result === 'string' ? result : (result?.content || 'completed'); + outboxResult = typeof result === 'string' ? result : (result?.content || 'completed'); // Check restart policy — if always, set back to idle for next task if (agent.restartPolicy === 'always') { @@ -1252,6 +1256,7 @@ class OrchestratorModule { } } else { this.terminal.print(`ℹ️ AI module not available — task queued for ${agent.id}`, 'info'); + outboxResult = 'queued — AI module not loaded, nothing executed'; } } catch (e) { this._handleAgentFailure(agent.id, e.message); @@ -1267,7 +1272,7 @@ class OrchestratorModule { agent.status = 'idle'; agent.lastHeartbeat = Date.now(); } - return outboxResult || 'completed'; + return outboxResult || 'no result recorded'; } // ─── Recurring Scheduling ─── |