// Monitor orchestrator performance, track prompt enhancement scores, detect workflow bottlenecks, and export metrics to PostgreSQL with WebSocket broadcasting. Keywords - monitoring, metrics, performance, observability, track metrics, workflow bottleneck, performance monitoring, orchestrator metrics
| name | orchestrator-observability |
| description | Monitor orchestrator performance, track prompt enhancement scores, detect workflow bottlenecks, and export metrics to PostgreSQL with WebSocket broadcasting. Keywords - monitoring, metrics, performance, observability, track metrics, workflow bottleneck, performance monitoring, orchestrator metrics |
| version | 1.0.0 |
Monitor the adaptive meta-orchestrator's performance, track prompt enhancement effectiveness, and provide real-time visibility into workflow optimizations for the Poneglyph System.
All metrics are exported to PostgreSQL events table:
-- Orchestrator metric event structure
INSERT INTO events (
event_type,
event_data,
severity,
created_at
) VALUES (
'orchestrator_metric',
'{
"metric_type": "prompt_enhancement_score",
"value": 85,
"task_id": "task-123",
"context": {
"language": "TypeScript",
"domain": "Backend",
"complexity": "Medium"
},
"patterns_applied": ["template", "chain-of-thought", "reflection"],
"token_reduction": 45
}'::jsonb,
'info',
NOW()
);
Metric Event Types:
orchestrator_metric:context_detection - Context analysis resultsorchestrator_metric:prompt_enhancement - Prompt quality scoresorchestrator_metric:workflow_speedup - Performance improvementsorchestrator_metric:multi_agent_decision - Agent routing decisionsorchestrator_metric:auto_documentation - Documentation triggersMetrics are broadcast in real-time via WebSocket to the Vue dashboard:
// WebSocket event format
{
type: 'orchestrator_metric',
room: 'orchestrator',
data: {
metric_type: 'prompt_enhancement_score',
value: 85,
timestamp: '2025-11-12T10:30:00Z',
task_id: 'task-123',
context: {
language: 'TypeScript',
domain: 'Backend',
complexity: 'Medium'
}
}
}
WebSocket Rooms:
orchestrator - Orchestrator-specific metricssystem - System-wide health metricstasks - Task execution eventsNew Dashboard Panel: "Orchestrator Health"
Location: frontend/src/components/OrchestratorHealth.vue
Displays:
Score starts at 100, deductions:
Context Detection Accuracy (max -30):
Prompt Enhancement Quality (max -30):
Workflow Performance (max -25):
Auto-Documentation Rate (max -15):
Detected when: accuracy < 80% (min 10 tasks)
Severity: High
Recommendation: Review context detection patterns, update keyword matching
Impact: Incorrect agent routing, suboptimal prompt enhancement
Detected when: avg_score < 70 (min 10 prompts)
Severity: Critical
Recommendation: Review Anthropic best practices, update pattern library
Impact: Lower model performance, increased token usage
Detected when: avg_speedup < 3x (min 10 tasks)
Severity: Medium
Recommendation: Increase parallel execution, optimize tool usage patterns
Impact: Slower task completion, reduced productivity
Detected when: documentation_rate < 70% (min 10 tasks)
Severity: Medium
Recommendation: Review documentation triggers, update AI_*.md templates
Impact: Poor cross-session learning, knowledge loss
Detected when: multi_agent_rate > 40% (should be ~10-20%)
Severity: Low
Recommendation: Increase single-agent capability, refine complexity scoring
Impact: Unnecessary coordination overhead
| Metric | Target | Current | Status |
|---|---|---|---|
| Context detection accuracy | > 90% | Track | 🎯 |
| Prompt enhancement score | > 85 | Track | 🎯 |
| Workflow speedup | 5-10x | Track | 🎯 |
| Token reduction | 30-60% | Track | 🎯 |
| Auto-documentation rate | > 80% | Track | 🎯 |
| Metric collection overhead | < 50ms | Track | 🎯 |
| PostgreSQL export latency | < 10ms | Track | 🎯 |
| WebSocket broadcast delay | < 5ms | Track | 🎯 |
# Track context detection accuracy
def track_context_detection(task_id, detected_context, actual_context):
accuracy = calculate_accuracy(detected_context, actual_context)
# Export to PostgreSQL
export_metric(
metric_type='context_detection',
value=accuracy,
task_id=task_id,
context=detected_context
)
# Broadcast via WebSocket
broadcast_metric(
room='orchestrator',
metric_type='context_detection',
value=accuracy
)
# Track prompt enhancement effectiveness
def track_prompt_enhancement(task_id, original_prompt, enhanced_prompt, patterns_applied):
score = calculate_enhancement_score(enhanced_prompt)
token_reduction = calculate_token_reduction(original_prompt, enhanced_prompt)
export_metric(
metric_type='prompt_enhancement',
value=score,
task_id=task_id,
patterns_applied=patterns_applied,
token_reduction=token_reduction
)
broadcast_metric(
room='orchestrator',
metric_type='prompt_enhancement_score',
value=score,
token_reduction=token_reduction
)
# Track workflow performance improvements
def track_workflow_speedup(task_id, baseline_time, actual_time):
speedup = baseline_time / actual_time
export_metric(
metric_type='workflow_speedup',
value=speedup,
task_id=task_id,
baseline_time=baseline_time,
actual_time=actual_time
)
broadcast_metric(
room='orchestrator',
metric_type='workflow_speedup',
value=speedup
)
-- Calculate current health score
WITH recent_metrics AS (
SELECT
event_data->>'metric_type' as metric_type,
(event_data->>'value')::float as value
FROM events
WHERE event_type = 'orchestrator_metric'
AND created_at > NOW() - INTERVAL '24 hours'
)
SELECT
100 -
CASE WHEN AVG(CASE WHEN metric_type = 'context_detection' THEN 100 - value ELSE 0 END) > 30 THEN 30
WHEN AVG(CASE WHEN metric_type = 'context_detection' THEN 100 - value ELSE 0 END) > 15 THEN 15
ELSE 0 END
as health_score
FROM recent_metrics;
-- Get prompt enhancement scores over time
SELECT
DATE_TRUNC('hour', created_at) as hour,
AVG((event_data->>'value')::float) as avg_score,
COUNT(*) as count
FROM events
WHERE event_type = 'orchestrator_metric'
AND event_data->>'metric_type' = 'prompt_enhancement'
AND created_at > NOW() - INTERVAL '7 days'
GROUP BY DATE_TRUNC('hour', created_at)
ORDER BY hour DESC;
-- Calculate multi-agent vs single-agent ratio
SELECT
CASE WHEN event_data->'decision'->>'multi_agent' = 'true' THEN 'Multi-Agent'
ELSE 'Single-Agent' END as decision_type,
COUNT(*) as count,
ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER (), 2) as percentage
FROM events
WHERE event_type = 'orchestrator_metric'
AND event_data->>'metric_type' = 'multi_agent_decision'
AND created_at > NOW() - INTERVAL '24 hours'
GROUP BY decision_type;
events tableevent_type = 'orchestrator_metric'event_data JSONB column<!-- frontend/src/components/OrchestratorHealth.vue -->
<template>
<div class="orchestrator-health">
<h2>Orchestrator Health</h2>
<!-- Health Score Gauge -->
<div class="health-score">
<gauge-chart :value="healthScore" :max="100" />
<p>Health Score: {{ healthScore }}/100</p>
<span :class="healthStatus">{{ healthStatusText }}</span>
</div>
<!-- Prompt Enhancement Score Chart -->
<div class="enhancement-chart">
<h3>Prompt Enhancement Score (24h)</h3>
<line-chart :data="enhancementScores" />
</div>
<!-- Workflow Speedup Bar Chart -->
<div class="speedup-chart">
<h3>Workflow Speedup</h3>
<bar-chart :data="speedupData" />
</div>
<!-- Recent Enhancements Table -->
<div class="recent-enhancements">
<h3>Recent Enhancements</h3>
<table>
<thead>
<tr>
<th>Task</th>
<th>Patterns</th>
<th>Token Reduction</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<tr v-for="item in recentEnhancements" :key="item.task_id">
<td>{{ item.task_id }}</td>
<td>{{ item.patterns.join(', ') }}</td>
<td>{{ item.token_reduction }}%</td>
<td>{{ item.score }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { useWebSocket } from '@/composables/useWebSocket';
const { socket, subscribe } = useWebSocket();
const healthScore = ref(0);
const enhancementScores = ref([]);
const speedupData = ref([]);
const recentEnhancements = ref([]);
// Subscribe to orchestrator metrics
const unsubscribe = subscribe('orchestrator', (data) => {
if (data.metric_type === 'prompt_enhancement_score') {
updateEnhancementScores(data);
} else if (data.metric_type === 'workflow_speedup') {
updateSpeedupData(data);
}
});
onMounted(() => {
loadInitialData();
});
onUnmounted(() => {
unsubscribe();
});
async function loadInitialData() {
// Fetch initial metrics from API
const response = await fetch('/api/metrics/orchestrator/health');
const data = await response.json();
healthScore.value = data.health_score;
enhancementScores.value = data.enhancement_scores;
speedupData.value = data.speedup_data;
recentEnhancements.value = data.recent_enhancements;
}
function updateEnhancementScores(data) {
enhancementScores.value.push({
timestamp: data.timestamp,
value: data.value
});
// Keep only last 100 points
if (enhancementScores.value.length > 100) {
enhancementScores.value.shift();
}
}
function updateSpeedupData(data) {
speedupData.value.push(data);
}
</script>
Observability Coverage:
Performance Targets:
Integration:
Use this skill to ensure the adaptive meta-orchestrator is performing optimally and continuously improving!