Skip to content

Report swarm agents as running once they claim a parallel slot - #383

Merged
neich merged 1 commit into
mainfrom
fix/swarm-running-agents
Nov 16, 2026
Merged

neich merged 1 commit into
mainfrom
fix/swarm-running-agents

Conversation

@neich

@neich neich commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Summary

Swarm agents in a parallel tier, loop pass, or runtime for were never reported as running before they finished, so the SWARM panel showed them as queued for their whole run. Units now report running once they claim a max_parallel slot, and "queued" means "waiting for a slot".

Changes

  • Add claim_slot in swarm/pipeline.rs. It acquires the semaphore permit in the dispatcher, then emits AgentStatus::Running. The permit is passed into the spawned task, so the dispatcher never holds one while it waits.
  • Use claim_slot at the parallel-tier and loop-pass spawn sites. The old in-task sem.acquire().unwrap() is removed. A closed semaphore is now an error instead of a panic.
  • In the dynamic-unit runner (runtime for clones and map_reduce workers), report all units as queued up front, then running as each takes a slot. The per-unit queued report that came after the slot is gone.
  • Report the runtime for template row as running (N item(s)) while its clones run, since it acts as the barrier.
  • Add tests with a RecordingObserver:
    • swarm_parallel_dispatch.rs: 3 units in a tier with 2 slots, and a parallel loop where every pass reports running.
    • swarm_runtime_for.rs: 3 clones with 2 slots, plus the template row.

Testing

  • git diff --check origin/main...HEAD
  • cargo test was not run (skipped in this run). The new tests were added but not executed here.

Risks / Notes

  • The dispatcher now blocks on a slot before spawning the next unit. This is the intended behaviour, but it changes where waiting happens in the dispatch loop.
  • Behaviour change: a closed semaphore now returns an error rather than panicking in the task.
  • No generated files are included.

🤖 Generated with Claude Code

The dispatcher now acquires the max_parallel permit before spawning each
unit and then reports it running, instead of the spawned task acquiring
it silently. Units stay queued while they wait for a slot, runtime-for
clones and their template row are reported correctly, and the tests
check the pending, running, completed sequence.
@neich
neich merged commit 86297df into main Nov 16, 2026
@neich
neich deleted the fix/swarm-running-agents branch November 16, 2026 18:51
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