Commit 696cabc
fix(orchestrator): add local active_agents guard to prevent duplicate dispatch race
The should_skip_dispatch check relied solely on the Gitea API to detect
assigned agents, but when two dispatch paths (webhook + mention poller)
fire within milliseconds of each other, the API can return stale data.
The second path sees the agent as unassigned and spawns a duplicate.
Add a fast local active_agents.contains_key() check at the top of
should_skip_dispatch, before any remote API call. This eliminates the
TOCTOU race because the in-process HashMap is updated synchronously
after spawn_agent inserts the ManagedAgent.
Refs #326
Co-Authored-By: Terraphim AI <noreply@anthropic.com>1 parent 12bab97 commit 696cabc
1 file changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1601 | 1601 | | |
1602 | 1602 | | |
1603 | 1603 | | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
1604 | 1617 | | |
1605 | 1618 | | |
1606 | 1619 | | |
1607 | 1620 | | |
1608 | 1621 | | |
1609 | | - | |
| 1622 | + | |
1610 | 1623 | | |
1611 | 1624 | | |
1612 | 1625 | | |
| |||
0 commit comments