Skip to content

fix(subagents): correct duration display showing 5-6x inflated runtime#45700

Closed
jackjin1997 wants to merge 3 commits into
openclaw:mainfrom
jackjin1997:fix/subagent-duration-display
Closed

fix(subagents): correct duration display showing 5-6x inflated runtime#45700
jackjin1997 wants to merge 3 commits into
openclaw:mainfrom
jackjin1997:fix/subagent-duration-display

Conversation

@jackjin1997

@jackjin1997 jackjin1997 commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #45009.

Subagent interim status display shows runtime inflated ~6x (e.g. a 10-minute run displays as ~58 minutes). Final completion stats are correct — the bug is isolated to the polling/list display path.

Root cause

A duplicate formatDurationCompact in src/shared/subagents-format.ts divides milliseconds by 60,000 (jumping straight to minutes) instead of by 1,000 (converting to seconds first). The canonical implementation in src/infra/format-time/format-duration.ts handles the conversion correctly and already has full test coverage.

Fix

  • Replaced the buggy duplicate with a re-export of the canonical formatDurationCompact
  • Added ?? "n/a" fallback at two call sites where the old function returned "n/a" but the canonical version returns undefined
  • Bonus: subagent status now shows seconds-level granularity (45s) instead of always rounding up to 1m

Test plan

  • pnpm testsubagents-format.test.ts passes (4 cases: seconds granularity, minutes, hours, invalid input)
  • formatDurationCompact(5000)"5s" (previously "1m")
  • formatDurationCompact(600_000)"10m" (previously showed inflated value)
  • pnpm build and pnpm check pass locally
  • Manual: run a subagent task and confirm interim status shows realistic duration

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Mar 14, 2026
@greptile-apps

greptile-apps Bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a long-standing bug in subagent duration display where runtimes were shown as ~5–6× inflated (e.g., "1m" for a 5-second task). The root cause was a duplicate formatDurationCompact in src/shared/subagents-format.ts that divided milliseconds directly by 60,000 — skipping the ms→s conversion entirely — and also enforced a minimum of 1 minute via Math.max(1, ...).

The fix replaces the buggy local duplicate with a re-export of the canonical formatDurationCompact from src/infra/format-time/format-duration.ts, which correctly handles the full ms → s → m → h → d decomposition and provides seconds-level granularity. The two call sites in subagent-control.ts and commands-subagents/shared.ts are updated to add ?? "n/a" to preserve the original fallback display for invalid/zero inputs (the canonical function returns undefined rather than "n/a"). A third call site (action-info.ts) already had this fallback and required no change.

Key changes:

  • src/shared/subagents-format.ts: local formatDurationCompact replaced with re-export of canonical implementation
  • src/agents/subagent-control.ts & src/auto-reply/reply/commands-subagents/shared.ts: ?? "n/a" fallback added to match prior behavior for invalid inputs
  • src/shared/subagents-format.test.ts: regression tests added covering seconds, minutes, hours, and invalid-input cases

Confidence Score: 5/5

  • This PR is safe to merge — it is a targeted, well-tested bug fix with no risk of regressions.
  • The change is minimal and surgical: it removes a demonstrably broken local function (wrong divisor of 60,000) and replaces it with a re-export of the canonical, already-tested implementation. All three call sites that depend on a non-undefined return value have ?? "n/a" fallbacks. The new regression tests correctly verify seconds-level output as well as boundary behaviour for minutes, hours, and invalid inputs. No new logic is introduced.
  • No files require special attention.

Last reviewed commit: 1bee70d

fixes openclaw#45009)

The duplicate formatDurationCompact in subagents-format.ts divided
milliseconds by 60000 (treating input as minutes) instead of 1000.
Replace with a re-export of the canonical implementation from
infra/format-time which correctly converts ms to seconds first,
and now also shows seconds-level granularity.
@jackjin1997
jackjin1997 force-pushed the fix/subagent-duration-display branch from 1bee70d to aacfbe1 Compare March 14, 2026 04:49
@jackjin1997

Copy link
Copy Markdown
Contributor Author

Closing to free up PR queue — will resubmit if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Subagent runtime display shows incorrect duration (5-6x actual time)

1 participant