agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

Background task elapsed time restarts after a restart for non-Claude harnesses

Open Annieeeee11 opened this issue 2 weeks ago • 5 comments

PR #7550 shows how long each background task has run, in the tab above the chat composer. For every harness except Claude Code, that time counts from when Orchestrator first saw the task, not from when the task started. When the daemon restarts or the chat reconnects, the same task shows a fresh time ("0s", then counting) even though it has been running all along.

Why it happens

  • The ACP harnesses, Codex and Unreal Agent keep their tasks in the shared tracker (backend/internal/adapters/chatdriver/backgroundtasks/tracker.go). The tracker stamps StartedAt the first time it records a task.
  • The tracker lives only in memory, inside the driver's conversation. After a restart or reconnect it is rebuilt from provider replay or a fresh native read, so every task is "first seen" again and gets a new start time.
  • Claude Code is not affected: AO's runtime projection records the task's own task_started time and keeps it for the life of that run.

Steps to reproduce

  1. Start a Codex chat and have it run a long background command (for example sleep 900).
  2. Wait a few minutes. The tab shows the elapsed time, for example "4m".
  3. Restart the app, or let the chat controller reconnect.
  4. The same task now shows "0s" and counts up from there.

Ways to fix it

  • Use a real start time where the provider sends one, for example the timestamp of Codex's item/started for the exec item, or the ACP tool call that launched the job.
  • Otherwise, persist the first-seen time per task (keyed by session, task id and run id), so a restart keeps it instead of stamping a new one.
  • If neither is known, report no start time. The tab already hides the elapsed time when startedAt is missing, which is better than showing a wrong number.

Done when

The elapsed time for a running Codex or ACP task stays the same across a daemon restart and a chat reconnect, and a new run of the same task id still starts from zero.

Annieeeee11 avatar Nov 13 '26 13:11 Annieeeee11

@Annieeeee11 are u actively working on this one or would like to pass ?

bhushan4work avatar Nov 15 '26 15:11 bhushan4work

Triage note: this bug is in the unmerged #7550, not on main (main has no background-task tracker yet). The fix belongs in #7550 before it merges. I've left the details there.

nikhilachale avatar Nov 19 '26 22:11 nikhilachale

@Annieeeee11 are u actively working on this one or would like to pass ?

@bhushan4work you can pick this up

Annieeeee11 avatar Nov 22 '26 15:11 Annieeeee11

@nikhilachale now that #7550 is merged, can you confirm whether #8326 still reproduces on main i.e., should i open a new pr for the elapsed-time fix, or is it already resolved?

bhushan4work avatar Nov 22 '26 15:11 bhushan4work

@bhushan4work yes it still exists on the main so can take a deep dive in it and fix it properly

nikhilachale avatar Nov 24 '26 09:11 nikhilachale