Skip to content

fix(runner): don't start a session for cards a starting session will claim - #111

Merged
Robbertvermeulen merged 1 commit into
mainfrom
fix/gate-starting-sessions
Oct 15, 2026
Merged

Robbertvermeulen merged 1 commit into
mainfrom
fix/gate-starting-sessions

Conversation

@Robbertvermeulen

Copy link
Copy Markdown
Owner

Follow-up to #110. Right after deploying it, three sessions started for one card: at 09:28:29 two UI actions each fired maybeAutorun() (#328, #329, trigger serve, 0.1 s apart) and at 09:28:37 the cron tick started #330. All three gated on the single ready card task_fa68: #110 only excludes cards already claimed by a live session, and an agent claims a few commands into its run.

Change

runnersAhead(slot): live runners that took their slot earlier (slot order breaks a tie) and whose session holds no doing card yet, i.e. sessions still starting up that will claim from the same ready pool. The gate starts a session only when cards.length > ahead. The earliest runner counts nobody ahead, so work is never left unstarted; a run with due routines always starts (routines are marked per runner, so they're exclusive).

New log reason: gate covered: N cards, M sessions starting.

Testing

npm run build passes. Isolated data dir, AGENTBOARD_MAX_SESSIONS=3, fake session that claims the first free ready card after 3 s (retrying the next one on a lost claim, per AGENT.md rule 15):

  • 1 ready card, 3 runners within 0.2 s → 1 session; the other two log gate covered: 1 cards, 1 sessions starting.
  • 3 ready cards, 3 runners within 0.2 s → 3 sessions, each claims a different card, in work, work-slot-1, work-slot-2, each hands back only its own card.
  • A session holding claimed card X, then a new ready card Y → a second session starts and takes Y.

🤖 Generated with Claude Code

…claim

A UI action (maybeAutorun) and the cron tick can start runners within
seconds of each other. Each gated on the same ready card, since nobody had
claimed it yet, so 3 sessions started for one card (#328-#330 on task_fa68).

The gate now leaves one card per live runner that started earlier and holds
no doing card yet. The earliest runner never defers, so work is never left
unstarted; due routines still always start a session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Robbertvermeulen
Robbertvermeulen merged commit 6caba83 into main Oct 15, 2026
2 checks passed
@Robbertvermeulen
Robbertvermeulen deleted the fix/gate-starting-sessions branch October 15, 2026 09:35
github-actions Bot pushed a commit that referenced this pull request Oct 15, 2026
## [0.22.2](v0.22.1...v0.22.2) (2026-10-15)

### Bug Fixes

* **runner:** don't start a session for cards a starting session will claim ([#111](#111)) ([6caba83](6caba83)), closes [#328](https://github.com/Robbertvermeulen/agentboard/issues/328) [#329](https://github.com/Robbertvermeulen/agentboard/issues/329) [#110](#110)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.22.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant