Skip to content

Task conflict resolution: what happens when two agents grab the same task? #5

@cimomo

Description

@cimomo

Currently, if two agents heartbeat at the same time and both see a task with status "ready", they could both mark it "in-progress" and start working on it. With file-based coordination there's no locking mechanism.

The problem

Markdown files have no atomic compare-and-swap. Two agents reading the same project note simultaneously will both see "ready" and both start work. This wastes compute and could produce conflicting results.

Possible approaches

  1. Claim-by-edit race: First agent to successfully write "in-progress" wins. The second agent should check the status again after writing and back off if someone else claimed it. Simple but has a race window.

  2. Agent-scoped assignment: Chief of staff writes the agent slug into the task entry (e.g., "Assigned: billing-dev"). Workers only pick up tasks assigned to them. Eliminates conflict but requires the coordinator to be active.

  3. Lock files: Create a .lock file when claiming a task. Other agents check for the lock. Adds filesystem clutter.

  4. Git-based CAS: If the team directory is a git repo, use commit-and-push as the atomic operation. Merge conflicts = claim conflicts. Elegant but requires git.

Discussion

Which approach fits the "simple markdown" philosophy best? Should the protocol spec take a position, or leave it to implementations?

This becomes more important as teams scale beyond 2-3 agents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    protocolProtocol spec changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions