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

improve(cos): add missing error patterns and unknown error tracking

Adam Eivyc22effec61da
diff --git a/.changelog/v0.18.12.md b/.changelog/v0.18.12.md
index 14b7bff4b0..770acab9ad 100644
--- a/.changelog/v0.18.12.md
+++ b/.changelog/v0.18.12.md
@@ -61,6 +61,12 @@ Continued reliability improvements and codebase hardening.
- S5 (Socket.IO validation): Zod schemas in `lib/socketValidation.js` for all socket events
- S6 (error context secrets): `sanitizeContext()` strips sensitive fields before broadcast
+### Improve agent error categorization with missing API patterns and unknown error tracking
+- Added error patterns for API 400 (bad request / invalid_request_error) and API 403 (forbidden) responses — previously these fell through to the "unknown" category, inflating the 70-error unknown count in the learning system
+- Unknown errors now store recent samples (last 20) in learning data with message, details, task type, and timestamp — making them diagnosable through the dashboard instead of being a black hole of lost information
+- New "Recent Uncategorized Errors" section in the Learning tab's Error Patterns panel shows the last 10 unknown error messages, helping identify missing patterns that should be added
+- This directly improves the CoS adaptive learning system's ability to make routing and cooldown decisions — 60% of failures were previously categorized as "unknown", limiting the system's ability to learn from its mistakes
+
### Fix text enrichment answers not updating Twin Confidence / Soul Health
- Text-based enrichment answers (boundaries, decision heuristics, etc.) were saved to documents but never recalculated confidence scores — only scale (Likert) questions triggered the confidence boost and metadata save
- Added category-to-dimension mapping so each enrichment category boosts the correct confidence dimension (e.g., `non_negotiables` → `boundaries`, `decision_heuristics` → `decision_making`)
diff --git a/client/src/components/cos/tabs/LearningTab.jsx b/client/src/components/cos/tabs/LearningTab.jsx
index e06a0854b8..d17f67feb0 100644
--- a/client/src/components/cos/tabs/LearningTab.jsx
+++ b/client/src/components/cos/tabs/LearningTab.jsx
@@ -622,20 +622,51 @@ export default function LearningTab() {
</span>
</button>
{expandedSections.errors && (
- <div className="bg-port-card border border-port-border rounded-lg divide-y divide-port-border">
- {learning.insights.commonErrors.map((error, idx) => (
- <div key={idx} className="p-3">
- <div className="flex items-center justify-between mb-1">
- <span className="text-sm text-port-error font-medium">{error.category}</span>
- <span className="text-xs text-gray-500">{error.count} occurrences</span>
- </div>
- {error.affectedTypes?.length > 0 && (
- <div className="text-xs text-gray-500">
- Affects: {error.affectedTypes.join(', ')}
+ <div className="space-y-3">
+ <div className="bg-port-card border border-port-border rounded-lg divide-y divide-port-border">
+ {learning.insights.commonErrors.map((error, idx) => (
+ <div key={idx} className="p-3">
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-sm text-port-error font-medium">{error.category}</span>
+ <span className="text-xs text-gray-500">{error.count} occurrences</span>
</div>
- )}
+ {error.affectedTypes?.length > 0 && (
+ <div className="text-xs text-gray-500">
+ Affects: {error.affectedTypes.join(', ')}
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+
+ {/* Recent Unknown Error Samples */}
+ {learning.insights?.recentUnknownErrors?.length > 0 && (
+ <div className="bg-port-card border border-port-warning/30 rounded-lg overflow-hidden">
+ <div className="px-4 py-2 bg-port-warning/10 border-b border-port-border">
+ <span className="text-sm font-medium text-port-warning flex items-center gap-2">
+ <AlertTriangle size={14} />
+ Recent Uncategorized Errors ({learning.insights.recentUnknownErrors.length})
+ </span>
+ <p className="text-xs text-gray-500 mt-1">
+ Errors that didn&apos;t match known patterns — useful for identifying missing error categories
+ </p>
+ </div>
+ <div className="divide-y divide-port-border max-h-64 overflow-y-auto">
+ {learning.insights.recentUnknownErrors.slice(-10).reverse().map((err, idx) => (
+ <div key={idx} className="p-3">
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-xs text-gray-500 font-mono">{err.taskType}</span>
+ <span className="text-xs text-gray-600">{new Date(err.recordedAt).toLocaleDateString()}</span>
+ </div>
+ <div className="text-sm text-gray-300 font-mono break-all">{err.message || 'No message'}</div>
+ {err.details && (
+ <div className="text-xs text-gray-500 mt-1 font-mono break-all line-clamp-2">{err.details}</div>
+ )}
+ </div>
+ ))}
+ </div>
</div>
- ))}
+ )}
</div>
)}
</div>
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 37e5771400..58f4da4bdb 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -520,6 +520,27 @@ const ERROR_PATTERNS = [
};
}
},
+ {
+ pattern: /API Error: 400|invalid_request_error|bad.?request/i,
+ category: 'bad-request',
+ actionable: true,
+ extract: (match, output) => {
+ const msgMatch = output.match(/"message":\s*"([^"]{1,150})"/);
+ return {
+ message: `Bad request${msgMatch ? `: ${msgMatch[1]}` : ''}`,
+ suggestedFix: 'API rejected the request as invalid. Check prompt formatting, tool names, and parameter sizes.'
+ };
+ }
+ },
+ {
+ pattern: /API Error: 403|forbidden/i,
+ category: 'forbidden',
+ actionable: true,
+ extract: () => ({
+ message: 'API access forbidden',
+ suggestedFix: 'API key lacks permission for this operation. Check API key permissions and provider configuration.'
+ })
+ },
{
pattern: /API Error: 5\d{2}|server error|internal error/i,
category: 'server-error',
diff --git a/server/services/taskLearning.js b/server/services/taskLearning.js
index b09199ff6a..f91f463774 100644
--- a/server/services/taskLearning.js
+++ b/server/services/taskLearning.js
@@ -226,6 +226,24 @@ export async function recordTaskCompletion(agent, task) {
data.errorPatterns[errorCategory].taskTypes[taskType] = 0;
}
data.errorPatterns[errorCategory].taskTypes[taskType]++;
+
+ // Store recent unknown error samples for diagnosability
+ // This helps identify missing patterns that should be added to ERROR_PATTERNS
+ if (errorCategory === 'unknown') {
+ const errorAnalysis = agent.result?.errorAnalysis || {};
+ if (!data.recentUnknownErrors) data.recentUnknownErrors = [];
+ data.recentUnknownErrors.push({
+ taskType,
+ message: (errorAnalysis.message || '').substring(0, 200),
+ details: (errorAnalysis.details || '').substring(0, 500),
+ agentId: agent.agentId || agent.id,
+ recordedAt: new Date().toISOString()
+ });
+ // Keep only last 20 samples to avoid unbounded growth
+ if (data.recentUnknownErrors.length > 20) {
+ data.recentUnknownErrors = data.recentUnknownErrors.slice(-20);
+ }
+ }
}
// Update totals
@@ -321,7 +339,8 @@ export async function getLearningInsights() {
completed: t.completed
})),
commonErrors,
- modelEffectiveness
+ modelEffectiveness,
+ recentUnknownErrors: data.recentUnknownErrors || []
},
recommendations: generateRecommendations(data, bestPerforming, worstPerforming, commonErrors)
};