Skip to content

start stuck task - #29

Merged
ayyshim merged 12 commits into
mainfrom
canopy/start-stuck-task
Nov 22, 2026
Merged

ayyshim merged 12 commits into
mainfrom
canopy/start-stuck-task

Conversation

@ayyshim

@ayyshim ayyshim commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Handover: start stuck task (G-32)

What you asked for

Tasks were getting stuck in "todo" while their owner looked idle. T-200 and T-202 on G-31 are two examples. Nobody could see why, and there was no way to push them to start.

What changed

There are 12 small commits on branch canopy/start-stuck-task, 18 files in total. There is no database change.

1. Every stuck todo task now says why it isn't starting. (T-208)

  • The task card on the board shows "Not starting: ". So does the task side panel.
  • Possible reasons:
    • the owner is asleep or missing
    • the owner is busy on another task for this goal
    • waiting for a person to answer an approval request
    • the owner's session is in error
    • the goal is done or stopped
    • the computer is offline, or has hit its daily cap or usage limit
    • waiting for folder access
    • a folder hasn't synced yet
  • The scheduler and the board use the same check, so the reason shown is the real one.
  • Code: hub/internal/orch/schedule.go (startBlocker, recordBlockers). The reason is also returned as blocked_reason by the board and by GET /tasks/{id}.

2. Tasks stuck behind a dead session now restart on their own. (T-209)

  • This was the main bug. A task went back to "todo" after an error retry, an owner change or a goal move. If its owner's session was still marked error or gate but no question was open any more, the task never started again.
  • Now the scheduler ends that dead session. The task then starts in a fresh session.
  • The goal's history shows "Restarted “” after its session got stuck".
  • A session is left alone while another task is still running in it (fixed in review, T-212).
  • Code: hub/internal/orch/schedule.go (stuckSession, restartStuck).

3. A "Start now" button. (T-210 and T-211)

  • The button is in the task side panel, on any todo task that shows a reason. The board card shows the reason but has no button, because cards have no menu.
  • Pressing it does three things:
    1. It closes the task's open error card as "retry".
    2. It ends a dead session.
    3. It tries to start the task right away.
  • If the task starts, the goal history shows "Started by ".
  • If it still can't start, a message shows the reason, for example "Waiting for Laptop".
  • It never wakes a sleeping staff member and never gives extra folder access.
  • Only workspace admins and the person who created the goal can use it. A task with no goal is admin-only.
  • Code: hub/internal/orch/startnow.go and hub/internal/api/agents.go (handleStartTask). The route is POST /api/v1/tasks/{id}/start, documented in shared/openapi.yaml.

How to check it

Automated tests. The full Go test suite and the system tests passed. They ran against a temporary database, because the local Postgres rejected the canopy login. The new tests are:

  • hub/internal/orch/blocker_test.go: each reason and the order they are checked in, plus TestStuckSession and TestStuckSessionSkippedWhileBusy.
  • e2e/system/stuck_test.go → TestTodoTaskBehindDeadGateRestarts. This failed before the fix and passes now.
  • hub/internal/api/start_task_test.go: starting after a dead session, the offline computer case, non-todo tasks, and privacy (another org gets "not found").

By hand. Nobody has tried this in the running app yet. To try it:

  1. Merge, run make hub and make web, and open the board.
  2. Look at a todo task that isn't moving. T-200 or T-202 should do once they are on this code. Its card should say "Not starting: …".
  3. Open the task. Press Start now. It should either move to Doing, or show a message with the reason.
  4. If the reason was a dead error or gate session, the task should restart on its own within one scheduler pass. Check the goal's history for "Restarted …".

What isn't done or is risky

  • Not tested in the real app. No one clicked the button or saw the reason line in a browser, and there is no screenshot. Only the automated tests cover it.
  • The reason line can disappear until you reload. Other updates to a task (an edit, a reassignment) send it to the board without the reason. The card then loses the "Not starting" line and the Start now button. They come back on page reload, or when the reason changes. This is a small follow-up fix.
  • A restarted task starts a fresh conversation. The plan said to resume the old one. The restart ends the dead session and gives the agent its usual handoff text, the same as an error retry does today. The agent may redo a little work.
  • Everyone sees the Start now button. People who aren't allowed to use it get a "not allowed" message when they press it. The board doesn't yet know who created the goal, so it can't hide the button.
  • One permission case has no test. That case is a workspace member who can see the task but didn't create the goal. They should be refused. The rule is in the code but untested.
  • Reasons are kept in memory. After a hub restart they are blank until the next scheduler pass, which takes seconds.
  • Build tooling. make gen fails at its pnpm step on this machine, and pnpm-lock.yaml looks broken. The API types were generated another way. The lockfile needs a separate fix.
  • G-31 overlap. G-31's own stuck detection (T-187) and sleep and spending limits aren't merged yet. They touch the same scheduler code, so expect merge conflicts in schedule.go. There are no migration clashes, because this goal adds none.
  • A timing test can fail under heavy load. TestHugeInputsStayBounded can fail when the tests run with -race on a busy machine. It is unrelated to this change.

What you need to decide

  1. Auto-restart. Should dead sessions keep restarting on their own, as built? The other choice is to only show the reason and wait for someone to press Start now. I recommend keeping auto-restart, since this was the bug.

  2. Who can press Start now. Right now it is admins and the goal's creator. Should the goal's manager agent or other workspace members also be allowed?

  3. Follow-ups. Should I plan a small follow-up for these?

    • keep the reason line on live updates
    • hide the button from people who can't use it
    • add the missing permission test
    • resume the old conversation on restart

    The first one is the most visible.

@ayyshim
ayyshim merged commit 2e9d75b into main Nov 22, 2026
2 checks passed
@ayyshim
ayyshim deleted the canopy/start-stuck-task branch November 22, 2026 06:54
@ayyshim ayyshim mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant