Skip to content

session: a wall with a task out never ends the run, because the only reader of the clock is the end of a turn #614

Closed

Description

@santoshkumarradha

What happened

dev@dbe4a44b, 2026-09-03, canary on deepseek/deepseek-v4-flash:

aforge chat -yolo -max-hours 0.2333    # 840s wall, inside a 900s rig clock

Cells astroid, build, sphinx of table postmerge/20260903T222849Z-21688b793 (canary #407). Each session handed its work to a task 1–2 minutes before its own wall, then sat at 1 running with the status line idle until the rig killed it at 902–903s. No wall line on screen, no row after the ceiling row in the store, no "hours ran out" ending. The wall passed and nothing happened.

Replication

Deterministic (no model). Unit shape in internal/session: build a Steward with Budget{Wall: 2 * time.Second}, hand it a task that never returns, and wait 4 seconds. Today nothing is written — Steward.Decide is never called, so Budget.Exhausted() is never asked — and the run only ends when the caller is killed. Expected: an ending row inside the wall.

Field (real models). The canary cell above, OPENROUTER_API_KEY, ~15 min and a few cents: aforge chat -yolo -max-hours 0.2333 on any issue whose plan hands over to a task in the last two minutes. Control: the same wall with no task out — that one does end, because a stopped turn reaches Decide.

Where

Budget.Exhausted (internal/session/principal.go:128) has exactly one caller, Steward.Decide (internal/session/principal.go:969 → stopSpent, principal.go:634), and Decide under a steward is reached only at the end of a turn — decideRemains (internal/session/checkpoint.go:2692), decideHandover (checkpoint.go:3764), decideOverTheChecks (checkpoint.go:2753). Nothing else in the build reads the clock against the wall: Budget.Wall is otherwise read only by pastTurnWallShare (internal/session/turnwall.go:158,162), which bounds one turn's inline stretch and never ends a run. So a session that has handed over and is watching, or that is idle with a task running, never Decides until the task returns, and the wall passes with no ending.

The wall is wired --max-hours → chatBudget (cmd/aforge/chatv3.go:654-663, seeded at chatv3.go:269) → Config.Budget (internal/session/session.go:1742) → NewSteward (internal/session/principal_wire.go:63, started off the session clock at principal_wire.go:73). The money ceiling's own ending road is stopSpent → Decision.Spent → endTurnUnderSteward (internal/session/checkpoint.go:3596 seals over moving work, checkpoint.go:3606 writes checkpointStoppedNote and checkpointCeilingStopped).

The task runner's only leash is taskDeadline (internal/session/task_run.go:105, 60 minutes, applied at task_run.go:1992 and task_child_run.go:117) — unrelated to the wall, and longer than every wall a canary uses.

The fix

At the seam: the steward arms one timer at Wall, from its own start. When it fires with work still out, the run ends through the same road a spent money ceiling takes — running tasks are stopped, the work is left where it is, the ending row reads "the 14 minutes this was given are up", and the door is closed. A session with nothing out keeps ending exactly where it does now; the timer is the floor, not a second policy.

And a task started under a wall inherits min(taskDeadline, what is left of the wall) as its deadline, so its own check has a bound it can meet rather than a 60-minute leash inside a 14-minute run (relates to #609).

Acceptance

  • e2e: the canary cell above on deepseek/deepseek-v4-flash ends on its own, with the hours-up row in the store and on screen, before the rig clock; the rig does not have to kill it.
  • e2e: the control — the same wall with no task out — still ends exactly as it does today, one ending row, same wording.
  • Unit: a Steward with a 2-second wall and a task that never returns writes its ending row within the wall; and every road that ends a run on the budget goes through stopSpent.
  • The manual page that covers --max-hours (internal/manual/chat/) says the wall ends a run whether or not work is out, and the change entry's invalidates names the belief that the wall is only read at the end of a turn.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    area:session
    on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:sessionbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions