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: use P80 duration estimates for task progress bars instead of average

Adam Eivyda4c4520695d
diff --git a/.changelog/v0.11.x.md b/.changelog/v0.11.x.md
index 5c7b16f073..12aacd41e3 100644
--- a/.changelog/v0.11.x.md
+++ b/.changelog/v0.11.x.md
@@ -194,3 +194,10 @@ This release focuses on security improvements, bug fixes for the AI runner syste
- **Implementation detail filter**: Both LLM classifier and pattern-based fallback now reject file paths, CSS values, port numbers, architecture descriptions, status assessments, and other trivially-discoverable code facts
- **Removed noise patterns**: Eliminated pattern extractors for "no issues found", "already well-optimized", conclusion sections, and positive assessments — these were generating the bulk of low-value 0% confidence approval requests
- **Key test**: Every candidate memory now passes the question "Would a brand-new agent benefit from knowing this even with full code access?" — if it's about code, reject; if it's about the user, keep
+
+### Task Progress Bars Use P80 Estimates Instead of Average
+- **More accurate progress**: Task progress bars now use a P80 (80th percentile approximation) estimate instead of the simple average duration, preventing progress bars from hitting 100% when only ~50% through a task
+- **Variance tracking**: The learning system now tracks `maxDurationMs` per task type and computes `p80DurationMs` (avg + 60% of the gap to max) for more realistic progress estimates
+- **ETAs reflect variance**: Running agent ETAs and pending task time estimates are based on the P80 value, giving users a more honest picture of when tasks will complete
+- **Learning tab shows both**: The Duration Estimates table now displays both average and estimated (P80) columns so users can see the range
+- **Backward compatible**: Existing learning data without max/P80 fields gracefully falls back to using the average
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index 058cb22137..28f891a57a 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -101,6 +101,7 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
};
// Calculate duration estimate for running agents
+ // Uses P80 (80th percentile approximation) for progress bars to prevent premature 100%
const durationEstimate = useMemo(() => {
if (completed || !durations) return null;
@@ -110,7 +111,8 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
if (typeData && typeData.avgDurationMs) {
return {
- estimatedMs: typeData.avgDurationMs,
+ estimatedMs: typeData.p80DurationMs || typeData.avgDurationMs,
+ avgMs: typeData.avgDurationMs,
basedOn: typeData.completed,
taskType,
isTypeSpecific: true
@@ -119,7 +121,8 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
if (overallData && overallData.avgDurationMs) {
return {
- estimatedMs: overallData.avgDurationMs,
+ estimatedMs: overallData.p80DurationMs || overallData.avgDurationMs,
+ avgMs: overallData.avgDurationMs,
basedOn: overallData.completed,
taskType: 'all tasks',
isTypeSpecific: false
@@ -129,14 +132,14 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
return null;
}, [completed, durations, agent.metadata?.taskDescription]);
- // Calculate progress percentage
+ // Calculate progress percentage using P80-based estimate
const progress = useMemo(() => {
if (!durationEstimate) return null;
const percent = Math.min(100, Math.round((duration / durationEstimate.estimatedMs) * 100));
return percent;
}, [duration, durationEstimate]);
- // Calculate remaining time (ETA)
+ // Calculate remaining time (ETA) based on P80 estimate
const remainingTime = useMemo(() => {
if (!durationEstimate || completed) return null;
const remaining = durationEstimate.estimatedMs - duration;
@@ -253,7 +256,7 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
{!completed && durationEstimate ? (
<span
className="flex items-center gap-1.5 text-gray-500 whitespace-nowrap"
- title={`Based on ${durationEstimate.basedOn} completed ${durationEstimate.taskType} tasks`}
+ title={`Based on ${durationEstimate.basedOn} completed ${durationEstimate.taskType} tasks (avg: ${formatDuration(durationEstimate.avgMs)}, est: ${formatDuration(durationEstimate.estimatedMs)})`}
>
<Clock size={12} aria-hidden="true" className="flex-shrink-0" />
<span className="font-mono">{formatDuration(duration)}</span>
diff --git a/client/src/components/cos/tabs/LearningTab.jsx b/client/src/components/cos/tabs/LearningTab.jsx
index 3b7cdfdffb..e7b9cd0c04 100644
--- a/client/src/components/cos/tabs/LearningTab.jsx
+++ b/client/src/components/cos/tabs/LearningTab.jsx
@@ -399,7 +399,8 @@ export default function LearningTab() {
<thead className="bg-port-bg">
<tr>
<th className="text-left p-3 text-gray-500 font-medium">Task Type</th>
- <th className="text-right p-3 text-gray-500 font-medium">Avg Duration</th>
+ <th className="text-right p-3 text-gray-500 font-medium">Avg</th>
+ <th className="text-right p-3 text-gray-500 font-medium" title="P80 estimate used for progress bars">Est</th>
<th className="text-right p-3 text-gray-500 font-medium hidden sm:table-cell">Samples</th>
<th className="text-right p-3 text-gray-500 font-medium hidden sm:table-cell">Success</th>
</tr>
@@ -408,9 +409,12 @@ export default function LearningTab() {
{sortedDurations.map(([taskType, data], idx) => (
<tr key={idx} className="border-t border-port-border">
<td className="p-3 text-gray-300 truncate max-w-[200px]">{taskType}</td>
- <td className="p-3 text-right text-cyan-400 font-mono">
+ <td className="p-3 text-right text-gray-500 font-mono">
{formatDuration(data.avgDurationMs)}
</td>
+ <td className="p-3 text-right text-cyan-400 font-mono" title="P80 estimate used for progress bars and ETAs">
+ {formatDuration(data.p80DurationMs || data.avgDurationMs)}
+ </td>
<td className="p-3 text-right text-gray-500 hidden sm:table-cell">
{data.completed}
</td>
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsx
index dd1a2853e8..2ea2192785 100644
--- a/client/src/components/cos/tabs/TaskItem.jsx
+++ b/client/src/components/cos/tabs/TaskItem.jsx
@@ -112,6 +112,7 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
const editModels = editProvider?.models || [];
// Calculate duration estimate for pending tasks
+ // Uses P80 estimate when available for more realistic time predictions
const durationEstimate = useMemo(() => {
if (!durations || task.status !== 'pending') return null;
@@ -120,8 +121,10 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
const overallData = durations._overall;
if (typeData && typeData.avgDurationMin) {
+ const p80Min = typeData.p80DurationMs ? Math.round(typeData.p80DurationMs / 60000) : typeData.avgDurationMin;
return {
- estimatedMin: typeData.avgDurationMin,
+ estimatedMin: p80Min,
+ avgMin: typeData.avgDurationMin,
basedOn: typeData.completed,
taskType,
successRate: typeData.successRate,
@@ -130,8 +133,10 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
}
if (overallData && overallData.avgDurationMin) {
+ const p80Min = overallData.p80DurationMs ? Math.round(overallData.p80DurationMs / 60000) : overallData.avgDurationMin;
return {
- estimatedMin: overallData.avgDurationMin,
+ estimatedMin: p80Min,
+ avgMin: overallData.avgDurationMin,
basedOn: overallData.completed,
taskType: 'all tasks',
successRate: overallData.successRate,
diff --git a/server/services/taskLearning.js b/server/services/taskLearning.js
index 21925017f1..7f05dff382 100644
--- a/server/services/taskLearning.js
+++ b/server/services/taskLearning.js
@@ -143,6 +143,8 @@ export async function recordTaskCompletion(agent, task) {
failed: 0,
totalDurationMs: 0,
avgDurationMs: 0,
+ maxDurationMs: 0,
+ p80DurationMs: 0,
lastCompleted: null,
successRate: 0
};
@@ -169,6 +171,12 @@ export async function recordTaskCompletion(agent, task) {
}
typeMetrics.totalDurationMs += duration;
typeMetrics.avgDurationMs = Math.round(typeMetrics.totalDurationMs / typeMetrics.completed);
+ typeMetrics.maxDurationMs = Math.max(typeMetrics.maxDurationMs || 0, duration);
+ // P80 estimate: avg + 60% of the gap between avg and max
+ // This provides a realistic upper-bound for progress bars so they don't hit 100% too early
+ typeMetrics.p80DurationMs = Math.round(
+ typeMetrics.avgDurationMs + 0.6 * (typeMetrics.maxDurationMs - typeMetrics.avgDurationMs)
+ );
typeMetrics.lastCompleted = new Date().toISOString();
typeMetrics.successRate = Math.round((typeMetrics.succeeded / typeMetrics.completed) * 100);
@@ -211,6 +219,10 @@ export async function recordTaskCompletion(agent, task) {
}
data.totals.totalDurationMs += duration;
data.totals.avgDurationMs = Math.round(data.totals.totalDurationMs / data.totals.completed);
+ data.totals.maxDurationMs = Math.max(data.totals.maxDurationMs || 0, duration);
+ data.totals.p80DurationMs = Math.round(
+ data.totals.avgDurationMs + 0.6 * ((data.totals.maxDurationMs || data.totals.avgDurationMs) - data.totals.avgDurationMs)
+ );
await saveLearningData(data);
@@ -732,6 +744,12 @@ export async function resetTaskTypeLearning(taskType) {
data.totals.avgDurationMs = data.totals.completed > 0
? Math.round(data.totals.totalDurationMs / data.totals.completed)
: 0;
+ // Recalculate max from remaining task types (we can't subtract a max)
+ const remainingTypes = Object.entries(data.byTaskType).filter(([t]) => t !== taskType);
+ data.totals.maxDurationMs = remainingTypes.reduce((max, [, m]) => Math.max(max, m.maxDurationMs || 0), 0);
+ data.totals.p80DurationMs = data.totals.completed > 0
+ ? Math.round(data.totals.avgDurationMs + 0.6 * ((data.totals.maxDurationMs || data.totals.avgDurationMs) - data.totals.avgDurationMs))
+ : 0;
// Clean up error patterns referencing this task type
for (const [category, pattern] of Object.entries(data.errorPatterns)) {
@@ -787,6 +805,7 @@ export async function getTaskDurationEstimate(taskDescription) {
return {
estimatedDurationMs: metrics.avgDurationMs,
estimatedDurationMin: Math.round(metrics.avgDurationMs / 60000),
+ p80DurationMs: metrics.p80DurationMs || metrics.avgDurationMs,
confidence: metrics.completed >= 10 ? 'high' : metrics.completed >= 5 ? 'medium' : 'low',
basedOn: metrics.completed,
taskType,
@@ -799,6 +818,7 @@ export async function getTaskDurationEstimate(taskDescription) {
return {
estimatedDurationMs: data.totals.avgDurationMs,
estimatedDurationMin: Math.round(data.totals.avgDurationMs / 60000),
+ p80DurationMs: data.totals.p80DurationMs || data.totals.avgDurationMs,
confidence: 'low',
basedOn: data.totals.completed,
taskType: 'all',
@@ -828,9 +848,12 @@ export async function getAllTaskDurations() {
for (const [taskType, metrics] of Object.entries(data.byTaskType)) {
if (metrics.completed >= 1) {
+ const p80 = metrics.p80DurationMs || metrics.avgDurationMs;
durations[taskType] = {
avgDurationMs: metrics.avgDurationMs,
avgDurationMin: Math.round(metrics.avgDurationMs / 60000),
+ p80DurationMs: p80,
+ maxDurationMs: metrics.maxDurationMs || metrics.avgDurationMs,
completed: metrics.completed,
successRate: metrics.successRate
};
@@ -839,9 +862,12 @@ export async function getAllTaskDurations() {
// Add overall average
if (data.totals.completed >= 1) {
+ const overallP80 = data.totals.p80DurationMs || data.totals.avgDurationMs;
durations._overall = {
avgDurationMs: data.totals.avgDurationMs,
avgDurationMin: Math.round(data.totals.avgDurationMs / 60000),
+ p80DurationMs: overallP80,
+ maxDurationMs: data.totals.maxDurationMs || data.totals.avgDurationMs,
completed: data.totals.completed,
successRate: Math.round((data.totals.succeeded / data.totals.completed) * 100)
};