Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix(review): address Copilot review feedback on API error skip logic

[._.]/ Adam Eivyba23987a3d40
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index d1d641aeeb..e797c5c32b 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -972,7 +972,7 @@ Review the error, fix the configuration or code issue, and retry the original ta
return investigationTask;
}
-// Error categories where the LLM API itself is unavailable — spawning an
+// Error categories where LLM API access is blocked or denied — spawning an
// investigation agent would fail for the same reason, so skip it.
const API_ACCESS_ERROR_CATEGORIES = new Set([
'auth-error',
@@ -981,7 +981,10 @@ const API_ACCESS_ERROR_CATEGORIES = new Set([
]);
async function maybeCreateInvestigationTask(agentId, task, analysis) {
- if (API_ACCESS_ERROR_CATEGORIES.has(analysis?.category)) return;
+ if (API_ACCESS_ERROR_CATEGORIES.has(analysis?.category)) {
+ emitLog('debug', `⏭️ Skipping investigation task for ${task.id}: API access error (${analysis.category})`, { agentId, taskId: task.id, category: analysis.category });
+ return;
+ }
await createInvestigationTask(agentId, task, analysis).catch(err => {
emitLog('warn', `Failed to create investigation task: ${err.message}`, { agentId });
});
diff --git a/server/services/subAgentSpawner.test.js b/server/services/subAgentSpawner.test.js
index f50ab4ae0f..863cf5b823 100644
--- a/server/services/subAgentSpawner.test.js
+++ b/server/services/subAgentSpawner.test.js
@@ -654,4 +654,49 @@ describe('Task Failure Retry Logic', () => {
expect(result.status).toBe('blocked');
});
});
+
+ describe('API access error categories skip investigation', () => {
+ const API_ACCESS_ERROR_CATEGORIES = new Set([
+ 'auth-error',
+ 'forbidden',
+ 'usage-limit',
+ ]);
+
+ function shouldSkipInvestigation(analysis) {
+ return API_ACCESS_ERROR_CATEGORIES.has(analysis?.category);
+ }
+
+ it('should skip investigation for auth-error category', () => {
+ const analysis = { actionable: true, category: 'auth-error', message: 'Auth failed' };
+ expect(shouldSkipInvestigation(analysis)).toBe(true);
+ });
+
+ it('should skip investigation for forbidden category', () => {
+ const analysis = { actionable: true, category: 'forbidden', message: 'Forbidden' };
+ expect(shouldSkipInvestigation(analysis)).toBe(true);
+ });
+
+ it('should skip investigation for usage-limit category', () => {
+ const analysis = { actionable: true, category: 'usage-limit', message: 'Limit reached' };
+ expect(shouldSkipInvestigation(analysis)).toBe(true);
+ });
+
+ it('should NOT skip investigation for other actionable categories', () => {
+ const analysis = { actionable: true, category: 'model-not-found', message: 'Model not found' };
+ expect(shouldSkipInvestigation(analysis)).toBe(false);
+ });
+
+ it('should NOT skip investigation for non-actionable categories', () => {
+ const analysis = { actionable: false, category: 'rate-limit', message: 'Rate limited' };
+ expect(shouldSkipInvestigation(analysis)).toBe(false);
+ });
+
+ it('should NOT skip investigation for null analysis', () => {
+ expect(shouldSkipInvestigation(null)).toBe(false);
+ });
+
+ it('should NOT skip investigation for analysis without category', () => {
+ expect(shouldSkipInvestigation({ actionable: true })).toBe(false);
+ });
+ });
});